]> granicus.if.org Git - libass/commitdiff
vertical: improve glyph positioning
authorGrigori Goronzy <greg@blackbox>
Thu, 25 Aug 2011 01:48:18 +0000 (03:48 +0200)
committerGrigori Goronzy <greg@blackbox>
Thu, 25 Aug 2011 02:01:15 +0000 (04:01 +0200)
It is a bit crazy, but for vertical layout the sTypoAscender and
sTypoDescender fields of the OS/2 table are supposed to be used for
determining the size of the ideographic EM box [1], so that glyphs
can be centered on the baseline more neatly.

With this change, vertical layout should be completely equal to
VSFilter.

[1] http://www.microsoft.com/typography/otspec150/os2.htm#sta

libass/ass_font.c

index f047a497f588837e8d8be2f85e542698c12a710b..92a2eff369762580d50b50b788d8732f7f3572cf 100644 (file)
@@ -547,10 +547,16 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font,
     // Rotate glyph, if needed
     if (vertical && ch >= VERTICAL_LOWER_BOUND) {
         FT_Matrix m = { 0, double_to_d16(-1.0), double_to_d16(1.0), 0 };
+        TT_OS2 *os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
+        int desc = 0;
+
+        if (os2)
+            desc = FT_MulFix(os2->sTypoDescender, face->size->metrics.y_scale);
+
+        FT_Outline_Translate(&((FT_OutlineGlyph) glyph)->outline, 0, -desc);
         FT_Outline_Transform(&((FT_OutlineGlyph) glyph)->outline, &m);
         FT_Outline_Translate(&((FT_OutlineGlyph) glyph)->outline,
-                             face->glyph->metrics.vertAdvance,
-                             0);
+                             face->glyph->metrics.vertAdvance, desc);
         glyph->advance.x = face->glyph->linearVertAdvance;
     }