< prev index next >

src/java.desktop/share/native/libfontmanager/freetypeScaler.c

Print this page
rev 53953 : 8218854: FontMetrics.getMaxAdvance may be less than the maximum FontMetrics.charWidth
Summary: Consider algorithmic bold in FontMetrics.getMaxAdvance value and update obliqueness.
Reviewed-by: prr, serb

*** 1,7 **** /* ! * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 403,416 **** } return errCode; } ! /* ftsynth.c uses (0x10000, 0x06000, 0x0, 0x10000) matrix to get oblique ! outline. Therefore x coordinate will change by 0x06000*y. ! Note that y coordinate does not change. */ ! #define OBLIQUE_MODIFIER(y) (context->doItalize ? ((y)*6/16) : 0) /* * Class: sun_font_FreetypeFontScaler * Method: getFontMetricsNative * Signature: (Lsun/font/Font2D;J)Lsun/font/StrikeMetrics; --- 403,424 ---- } return errCode; } ! /* ftsynth.c uses (0x10000, 0x0366A, 0x0, 0x10000) matrix to get oblique ! outline. Therefore x coordinate will change by 0x0366A*y. ! Note that y coordinate does not change. These values are based on ! libfreetype version 2.9.1. */ ! #define OBLIQUE_MODIFIER(y) (context->doItalize ? ((y)*0x366A/0x10000) : 0) ! ! /* FT_GlyphSlot_Embolden (ftsynth.c) uses FT_MulFix(units_per_EM, y_scale) / 24 ! * strength value when glyph format is FT_GLYPH_FORMAT_OUTLINE. This value has ! * been taken from libfreetype version 2.6 and remain valid at least up to ! * 2.9.1. */ ! #define BOLD_MODIFIER(units_per_EM, y_scale) \ ! (context->doBold ? FT_MulFix(units_per_EM, y_scale) / 24 : 0) /* * Class: sun_font_FreetypeFontScaler * Method: getFontMetricsNative * Signature: (Lsun/font/Font2D;J)Lsun/font/StrikeMetrics;
*** 493,503 **** (jlong) scalerInfo->face->size->metrics.y_scale)) + ay - dy; /* max advance */ mx = (jfloat) FT26Dot6ToFloat( scalerInfo->face->size->metrics.max_advance + ! OBLIQUE_MODIFIER(scalerInfo->face->size->metrics.height)); my = 0; metrics = (*env)->NewObject(env, sunFontIDs.strikeMetricsClass, sunFontIDs.strikeMetricsCtr, --- 501,513 ---- (jlong) scalerInfo->face->size->metrics.y_scale)) + ay - dy; /* max advance */ mx = (jfloat) FT26Dot6ToFloat( scalerInfo->face->size->metrics.max_advance + ! OBLIQUE_MODIFIER(scalerInfo->face->size->metrics.height) + ! BOLD_MODIFIER(scalerInfo->face->units_per_EM, ! scalerInfo->face->size->metrics.y_scale)); my = 0; metrics = (*env)->NewObject(env, sunFontIDs.strikeMetricsClass, sunFontIDs.strikeMetricsCtr,
< prev index next >