video: ass subtitle format (WIP)

This commit is contained in:
Thibault Deckers 2021-06-22 16:22:36 +09:00
parent 62a8f05d1a
commit 2e1622fc88
2 changed files with 26 additions and 14 deletions

View file

@ -222,6 +222,13 @@ class AssParser {
if (scale != null) extraStyle = extraStyle.copyWith(scaleY: scale.toDouble() / 100);
break;
}
case 'fsp':
{
// \fsp: letter spacing
final spacing = double.tryParse(param);
textStyle = textStyle.copyWith(letterSpacing: spacing);
break;
}
case 'i':
// \i: italics
textStyle = textStyle.copyWith(fontStyle: param == '1' ? FontStyle.italic : FontStyle.normal);
@ -289,7 +296,6 @@ class AssParser {
case 'org': // \org: rotation origin
// TODO TLAD [subtitles] MAY support the following
case 'fe': // \fe: font encoding
case 'fsp': // \fsp: letter spacing
case 'pbo': // \pbo: baseline offset
case 'q': // \q: wrap style
// border size

View file

@ -102,19 +102,25 @@ class VideoSubtitles extends StatelessWidget {
final spans = kv.value.map((v) {
final span = v.textSpan;
final style = span.style;
return position != null && style != null
? TextSpan(
text: span.text,
style: style.copyWith(
shadows: style.shadows
?.map((v) => Shadow(
color: v.color,
offset: v.offset * viewScale,
blurRadius: v.blurRadius * viewScale,
))
.toList()),
)
: span;
if (position == null || style == null) return span;
final letterSpacing = style.letterSpacing;
final shadows = style.shadows;
return TextSpan(
text: span.text,
style: style.copyWith(
letterSpacing: letterSpacing != null ? letterSpacing * viewScale : null,
shadows: shadows != null
? shadows
.map((v) => Shadow(
color: v.color,
offset: v.offset * viewScale,
blurRadius: v.blurRadius * viewScale,
))
.toList()
: null,
),
);
}).toList();
final drawingPaths = extraStyle.drawingPaths;