From 0ba4d4ceb16c1d3d678bcab63506ae6671b87889 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Mon, 20 Jul 2009 00:18:55 +0200 Subject: Font metrics: prefer OS/2 table for ascender/descender If possible, use ascender/descender from the OS/2 TTF table. This is another try to get libass to match VSFilter in regard to vertical font metrics. --- libass/ass_font.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libass/ass_font.c b/libass/ass_font.c index 35d34cf..8a93a4e 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -46,8 +46,8 @@ static void charmap_magic(ass_library_t *library, FT_Face face) FT_CharMap cmap = face->charmaps[i]; unsigned pid = cmap->platform_id; unsigned eid = cmap->encoding_id; - if (pid == 3 /*microsoft */ - && (eid == 1 /*unicode bmp */ + if (pid == 3 /*microsoft */ + && (eid == 1 /*unicode bmp */ || eid == 10 /*full unicode */ )) { FT_Set_Charmap(face, cmap); return; @@ -267,10 +267,16 @@ void ass_font_get_asc_desc(ass_font_t *font, uint32_t ch, int *asc, int i; for (i = 0; i < font->n_faces; ++i) { FT_Face face = font->faces[i]; + TT_OS2 *os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2); if (FT_Get_Char_Index(face, ch)) { int y_scale = face->size->metrics.y_scale; - *asc = FT_MulFix(face->ascender, y_scale); - *desc = FT_MulFix(-face->descender, y_scale); + if (os2) { + *asc = FT_MulFix(os2->usWinAscent, y_scale); + *desc = FT_MulFix(os2->usWinDescent, y_scale); + } else { + *asc = FT_MulFix(face->ascender, y_scale); + *desc = FT_MulFix(-face->descender, y_scale); + } return; } } -- cgit v1.2.3