changeset 23983:90038c72d69e

Don't apply windows-like font scaling if hhea or os2 tables contain invalid metrics.
author eugeni
date Fri, 03 Aug 2007 15:39:38 +0000
parents 17b5fa69243c
children 73c9e15e7341
files libass/ass_font.c
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass_font.c	Fri Aug 03 15:22:55 2007 +0000
+++ b/libass/ass_font.c	Fri Aug 03 15:39:38 2007 +0000
@@ -204,8 +204,12 @@
 	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)
-		mscale = ((double)(hori->Ascender - hori->Descender)) / (os2->usWinAscent + os2->usWinDescent);
+	if (hori && os2) {
+		int hori_height = hori->Ascender - hori->Descender;
+		int os2_height = os2->usWinAscent + os2->usWinDescent;
+		if (hori_height && os2_height)
+			mscale = (double)hori_height / os2_height;
+	}
 	memset(&rq, 0, sizeof(rq));
 	rq.type = FT_SIZE_REQUEST_TYPE_REAL_DIM;
 	rq.width = 0;