From 50d46ca6a281c0f14d75e5428c7ee3d653360fc3 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Thu, 25 Aug 2011 03:48:18 +0200 Subject: 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 --- libass/ass_font.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libass/ass_font.c b/libass/ass_font.c index f047a49..92a2eff 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; } -- cgit v1.2.3