asticode / go-astisub

Manipulate subtitles in GO (.srt, .ssa/.ass, .stl, .ttml, .vtt (webvtt), teletext, etc.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can go-astisub generate ASS/SSA code?

TuringZhu opened this issue · comments

I specify font in style but it not work. e.g.:


[V4 Styles]
Format: Name, Alignment, Angle, BackColour, Bold, BorderStyle, Encoding, Fontname, Fontsize, Italic, MarginL, MarginV, Outline, OutlineColour, PrimaryColour, ScaleX, ScaleY, SecondaryColour, Underline
Style: style_0_0,5,0.000,&H007f7f7f,0,0,134,SimHei,60.000,0,1090,520,0.000,&H007f7f7f,&H64000000,100.000,100.000,&H00ffffff,0
[Events]
Format: Start, End, MarginL, MarginV, Style, Text
Dialogue: 00:00:10.88,00:00:24.04,1090,520,style_0_0,产品计划

after I test ass/ssa code, it worked. e.g.


[V4 Styles]
Format: Name, Alignment, Angle, BackColour, Bold, BorderStyle, Encoding, Fontname, Fontsize, Italic, MarginL, MarginV, Outline, OutlineColour, PrimaryColour, ScaleX, ScaleY, SecondaryColour, Underline
Style: style_0_0,5,0.000,&H007f7f7f,0,0,134,SimHei,60.000,0,1090,520,0.000,&H007f7f7f,&H64000000,100.000,100.000,&H00ffffff,0
[Events]
Format: Start, End, MarginL, MarginV, Style, Text
Dialogue: 00:00:10.88,00:00:24.04,1090,520,style_0_0,{\fnApple Chancery\b0}产品计划

so how can I gengerate code like Dialogue: 00:00:10.88,00:00:24.04,1090,520,style_0_0,{\fnApple Chancery\b0}产品计划

Now I generate like the following code:

Lines: []astisub.Line{{Items: []astisub.LineItem{{Text: fmt.Sprintf("{\\fn%s\\b0}%s", "Apple Chancery", text)}}}

if go-astisub can generate it directly, it is so awesome.

In the first code snippet you shared, text will be printed with the font mentioned in style_0_0 : SimHei

In the second code snippet, font is overridden by the fn effect in your text and the font used will be Apple Chancery.

You have 2 options:

  1. you update the font name in your style from SimHei to Apple Chancery
  2. in your Item, you provide an InlineStyle attribute with SSAEffect set to {\fnApple Chancery\b0}

Does that fix your issue ?

thanks your solution. I know how to do.