From 502c29e6d7f0deef67a0b7a806b699b6aaefa67c Mon Sep 17 00:00:00 2001 From: Oleg Oshmyan Date: Tue, 11 Feb 2014 15:58:14 +0000 Subject: [PATCH] Font metrics: FreeType falls back to sTypoAscender/Descender Fixes libass#8. --- libass/ass_font.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libass/ass_font.c b/libass/ass_font.c index dd275c1..c9761a8 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -236,12 +236,16 @@ void ass_face_set_size(FT_Face face, double size) FT_Size_Metrics *m = &face->size->metrics; // VSFilter uses metrics from TrueType OS/2 table // The idea was borrowed from asa (http://asa.diac24.net) - if (hori && os2) { - int hori_height = hori->Ascender - hori->Descender; + if (os2) { + int ft_height = 0; + if (hori) + ft_height = hori->Ascender - hori->Descender; + if (!ft_height) + ft_height = os2->sTypoAscender - os2->sTypoDescender; /* sometimes used for signed values despite unsigned in spec */ int os2_height = (short)os2->usWinAscent + (short)os2->usWinDescent; - if (hori_height && os2_height) - mscale = (double) hori_height / os2_height; + if (ft_height && os2_height) + mscale = (double) ft_height / os2_height; } memset(&rq, 0, sizeof(rq)); rq.type = FT_SIZE_REQUEST_TYPE_REAL_DIM; -- 2.40.0