libass icon indicating copy to clipboard operation
libass copied to clipboard

@font vertical writing is displayed wrong

Open ch3ewb4cc4 opened this issue 1 year ago • 12 comments

Hi, I created Japanese vertical subtitles in aegisub. But the symbols are displayed horizontally. When I burn the subtitles with ffmpeg, they are displayed horizontally and burned. Does anyone know how to solve this problem? Sorry for my poor English.

ch3ewb4cc4 avatar Jun 08 '23 08:06 ch3ewb4cc4

To render vertical Japanese in ASS, you must do the following:

  1. Specify a Japanese font that supports vertical writing.
  2. Prefix the font name with an @ symbol.
  3. Rotate the line by −90° around the 𝑧 axis.
  4. Most likely, reposition the line on screen by hand, because the default positioning may be wrong and cause part of the text to get cut off.

You can specify the font and rotation using override tags:

Dialogue: 0,0:00:00.00,0:00:10.00,Default,,0,0,0,,{\fn@Meiryo\frz-90}日本語もいい

or in a style definition:

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: VerticalJapanese,@Meiryo,96,&H000000FF,&H000000FF,&H000000FF,&H000000FF,0,0,0,0,100,100,0,-90,1,0,0,3,0,196,0,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:10.00,VerticalJapanese,,0,0,0,,日本語もいい

For positioning, try changing the Alignment (or the \an override tag), MarginL/MarginR and either changing MarginV or adding a \pos(X,Y) override tag that sets explicit coordinates for the alignment point.

astiob avatar Jun 08 '23 16:06 astiob

Thanks for the reply. I did as you advised. The symbols are displayed horizontally; in illustrator they are displayed correctly. Do you know of a solution to this? 4

ch3ewb4cc4 avatar Jun 21 '23 06:06 ch3ewb4cc4

I’m not sure which exact symbols you’re trying to use, but yes, some are unfortunately rotated incorrectly in current libass, and I’m afraid you don’t have any solution for this (other than manually positioning every glyph). You may get a better result using a Windows computer with VSFilter (instead of libass): for example, you could invoke VSFilter via AviSynth and use the AviSynth script as the input for FFmpeg.

This has previously been mentioned in https://github.com/libass/libass/issues/600 and https://code.google.com/archive/p/libass/issues/95 (and elsewhere), but we don’t seem to have a clearly dedicated GitHub issue for it. Maybe I should create one. My most recent idea was to have libass use HarfBuzz’s vertical-writing mode and hope that it solves this.

astiob avatar Jun 21 '23 16:06 astiob

Yeah, if VSFilter/GDI handles this, I would assume it's by using vertical mode for @ fonts, and setting that in harfbuzz should be exactly what we want here.

rcombs avatar Jun 21 '23 16:06 rcombs

The reason I have doubts is because vertical writing support in Windows is pretty old and I couldn’t find clear information on how fonts define it when I first tried (including by looking inside Microsoft’s older fonts). But yeah, it’s my best guess/hope that HarfBuzz should be able to handle it.

astiob avatar Jun 21 '23 16:06 astiob

Well, the core of it's going to be alternate glyphs using an opentype feature or the like, right? So at worst, we might have to experiment with specific flags (vert/vrtr/vrt2).

rcombs avatar Jun 21 '23 17:06 rcombs

Thank you for your advice.I have looked into Harfbuzz and it seems very difficult for me.But I'll try a little harder.

ch3ewb4cc4 avatar Jun 22 '23 03:06 ch3ewb4cc4

Apparently there exists a libass downstream fork for displaying ISDB subtitles and one of its patches seems related to this and may be worth a closer look (at first glance it appears to also automatically rotate, which we don't want): 0p1pp1/libass@ca5cc11e1 + https://github.com/0p1pp1/libass/commit/76704b56dfdba7b86f7716b26222618687321cff

@ch3ewb4cc4 if you’re only burning the subtitles into the video and not distributing the soft subtitles, you may want to use this fork until we have a proper, VSFilter-comaptible fix. (If you do distribute soft subs, do not use the downstream fork as whatever you author will be incompatible with any ASS real renderer, including both current and future fixed libass) However, this fork breaks ABI (inserts a new element in the middle of the ASS_Style struct) so you will also need to relink the programs using libass against the fork.

TheOneric avatar Aug 03 '23 18:08 TheOneric

Some previous investigation that may be relevant: https://github.com/waddou/libass/issues/95

rcombs avatar Aug 05 '23 21:08 rcombs

Oh, someone did archive the Google Code repo on GitHub! That’s good to know. Of course, Google still hosts its own archive, but it’s anonymized.

astiob avatar Aug 05 '23 21:08 astiob

I can't reproduce the issue described here using the text て・ストー with \fn@MS Mincho\frz-90. Are we sure that this is still an issue? Could it be a case of outdated libass? Or maybe it happens in some fonts, but not others?

Please confirm what libass version you're using, and attach a sample ASS file and all associated fonts.

rcombs avatar Aug 05 '23 23:08 rcombs

I don’t think that’s in the picture: it’s too long. (Of course, it’s not MS Mincho, either.) Certainly, an exact text sample would help for reproduction purposes.

astiob avatar Aug 06 '23 02:08 astiob