diff options
author | Grigori Goronzy <greg@blackbox> | 2011-08-25 03:48:18 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2011-08-25 04:01:15 +0200 |
commit | 50d46ca6a281c0f14d75e5428c7ee3d653360fc3 (patch) | |
tree | 6aa1a2879111e90118c25819d1d7a0e6ff705b47 /libass/ass_font.c | |
parent | 8351e4d6ec08831f2f2470631f0f5e7d9f3394c0 (diff) | |
download | libass-50d46ca6a281c0f14d75e5428c7ee3d653360fc3.tar.bz2 libass-50d46ca6a281c0f14d75e5428c7ee3d653360fc3.tar.xz |
vertical: improve glyph positioning
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
Diffstat (limited to 'libass/ass_font.c')
-rw-r--r-- | libass/ass_font.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c index f047a497..92a2eff3 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -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; } |