]> granicus.if.org Git - libass/commitdiff
Font metrics: FreeType falls back to sTypoAscender/Descender
authorOleg Oshmyan <chortos@inbox.lv>
Tue, 11 Feb 2014 15:58:14 +0000 (15:58 +0000)
committerOleg Oshmyan <chortos@inbox.lv>
Tue, 11 Feb 2014 16:51:24 +0000 (16:51 +0000)
Fixes libass#8.

libass/ass_font.c

index dd275c10279767e8ffe76119d6897ef0b4fd07cc..c9761a88c6c4c618ff32108088fc61b653d577a2 100644 (file)
@@ -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;