From cb437cbfe4e60427683250a9483d39899a80922a Mon Sep 17 00:00:00 2001 From: Mario Torre Date: Wed, 16 Jun 2010 20:46:10 +0200 Subject: [PATCH] 6961732: FontMetrics.getLeading() may be negative in freetype-based OpenJDK builds Fix premature integer roundings to preserve correct height, width and descent values for fonts Reviewed-by: prr --- .../share/native/sun/font/freetypeScaler.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/jdk/src/share/native/sun/font/freetypeScaler.c b/jdk/src/share/native/sun/font/freetypeScaler.c index 39768c46738..c132a4a5a2c 100644 --- a/jdk/src/share/native/sun/font/freetypeScaler.c +++ b/jdk/src/share/native/sun/font/freetypeScaler.c @@ -490,22 +490,23 @@ Java_sun_font_FreetypeFontScaler_getFontMetricsNative( /* ascent */ ax = 0; - ay = -(jfloat) FT26Dot6ToFloat( - scalerInfo->face->size->metrics.ascender + - bmodifier/2); + ay = -(jfloat) FT26Dot6ToFloat(FT_MulFix( + ((jlong) scalerInfo->face->ascender + bmodifier/2), + (jlong) scalerInfo->face->size->metrics.y_scale)); /* descent */ dx = 0; - dy = -(jfloat) FT26Dot6ToFloat( - scalerInfo->face->size->metrics.descender + - bmodifier/2); + dy = -(jfloat) FT26Dot6ToFloat(FT_MulFix( + ((jlong) scalerInfo->face->descender + bmodifier/2), + (jlong) scalerInfo->face->size->metrics.y_scale)); /* baseline */ bx = by = 0; /* leading */ lx = 0; - ly = (jfloat) FT26Dot6ToFloat( - scalerInfo->face->size->metrics.height + - bmodifier) + ay - dy; + ly = (jfloat) FT26Dot6ToFloat(FT_MulFix( + (jlong) scalerInfo->face->height + bmodifier, + (jlong) scalerInfo->face->size->metrics.y_scale)) + + ay - dy; /* max advance */ mx = (jfloat) FT26Dot6ToFloat( scalerInfo->face->size->metrics.max_advance +