diff --git a/src/core/SkPaintPriv.cpp b/src/core/SkPaintPriv.cpp index ad361a23c1..9cd5e4708d 100644 --- a/src/core/SkPaintPriv.cpp +++ b/src/core/SkPaintPriv.cpp @@ -63,11 +63,15 @@ void SkPaintPriv::ScaleFontMetrics(SkPaint::FontMetrics* metrics, SkScalar scale metrics->fBottom *= scale; metrics->fLeading *= scale; metrics->fAvgCharWidth *= scale; + metrics->fMaxCharWidth *= scale; metrics->fXMin *= scale; metrics->fXMax *= scale; metrics->fXHeight *= scale; + metrics->fCapHeight *= scale; metrics->fUnderlineThickness *= scale; metrics->fUnderlinePosition *= scale; + metrics->fStrikeoutThickness *= scale; + metrics->fStrikeoutPosition *= scale; } bool SkPaintPriv::ShouldDither(const SkPaint& p, SkColorType dstCT) { diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index e5c6afb14f..b00634d1a8 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -1360,13 +1360,20 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* metrics leading = (SkIntToScalar(face->size->metrics.height) / (yppem * 64.0f)) + ascent - descent; xmin = 0.0f; xmax = SkIntToScalar(face->available_sizes[fStrikeIndex].width) / xppem; - ymin = descent + leading; - ymax = ascent - descent; + ymin = descent; + ymax = ascent; underlineThickness = 0; underlinePosition = 0; - metrics->fFlags &= ~SkPaint::FontMetrics::kUnderlineThicknessIsValid_Flag; metrics->fFlags &= ~SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; + + TT_Postscript* post = (TT_Postscript*) FT_Get_Sfnt_Table(face, ft_sfnt_post); + if (post) { + underlineThickness = SkIntToScalar(post->underlineThickness) / upem; + underlinePosition = -SkIntToScalar(post->underlinePosition) / upem; + metrics->fFlags |= SkPaint::FontMetrics::kUnderlineThicknessIsValid_Flag; + metrics->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; + } } else { sk_bzero(metrics, sizeof(*metrics)); return; diff --git a/tools/create_test_font.cpp b/tools/create_test_font.cpp index 4fd8dbbdbb..7b8fd4386a 100644 --- a/tools/create_test_font.cpp +++ b/tools/create_test_font.cpp @@ -430,7 +430,7 @@ static void generate_index(const char* defaultName) { } int main(int , char * const []) { - generate_fonts("/Library/Fonts/"); + generate_fonts("/Library/Fonts/"); // or /usr/share/fonts/truetype/ttf-liberation/ generate_index(DEFAULT_FONT_NAME); return 0; } diff --git a/tools/test_font_monospace.inc b/tools/test_font_monospace.inc index 60bcd6978a..a8e2c4ce5b 100644 --- a/tools/test_font_monospace.inc +++ b/tools/test_font_monospace.inc @@ -1193,9 +1193,8 @@ const SkFixed LiberationMonoNormalWidths[] = { const int LiberationMonoNormalCharCodesCount = (int) SK_ARRAY_COUNT(LiberationMonoNormalCharCodes); const SkPaint::FontMetrics LiberationMonoNormalMetrics = { -0x0000000f, -0.83252f, -0.83252f, 0.300293f, 0.300293f, 0, 0.600098f, 0.00989532f, --0.0244141f, 0.608887f, 0.52832f, 0.0102921f, 0.0410156f, 0.23291f, 0.000778198f, --0.00404358f +0x0000000f, -0.83252f, -0.83252f, 0.300293f, 0.300293f, 0, 0.600098f, 0.633301f, -0.0244141f, +0.608887f, 0.52832f, 0.658691f, 0.0410156f, 0.23291f, 0.0498047f, -0.258789f }; const SkScalar LiberationMonoBoldPoints[] = { @@ -2344,9 +2343,8 @@ const SkFixed LiberationMonoBoldWidths[] = { const int LiberationMonoBoldCharCodesCount = (int) SK_ARRAY_COUNT(LiberationMonoBoldCharCodes); const SkPaint::FontMetrics LiberationMonoBoldMetrics = { -0x0000000f, -0.833496f, -0.833496f, 0.300293f, 0.300293f, 0, 0.600098f, 0.010025f, --0.0268555f, 0.614746f, 0.52832f, 0.0102921f, 0.100098f, 0.23291f, 0.000778198f, --0.00404358f +0x0000000f, -0.833496f, -0.833496f, 0.300293f, 0.300293f, 0, 0.600098f, 0.641602f, -0.0268555f, +0.614746f, 0.52832f, 0.658691f, 0.100098f, 0.23291f, 0.0498047f, -0.258789f }; const SkScalar LiberationMonoItalicPoints[] = { @@ -3611,9 +3609,8 @@ const SkFixed LiberationMonoItalicWidths[] = { const int LiberationMonoItalicCharCodesCount = (int) SK_ARRAY_COUNT(LiberationMonoItalicCharCodes); const SkPaint::FontMetrics LiberationMonoItalicMetrics = { -0x0000000f, -0.833496f, -0.833496f, 0.300293f, 0.300293f, 0, 0.600098f, 0.0124817f, --0.0942383f, 0.70459f, 0.52832f, 0.0102921f, 0.0410156f, 0.23291f, 0.000778198f, --0.00404358f +0x0000000f, -0.833496f, -0.833496f, 0.300293f, 0.300293f, 0, 0.600098f, 0.798828f, -0.0942383f, +0.70459f, 0.52832f, 0.658691f, 0.0410156f, 0.23291f, 0.0498047f, -0.258789f }; const SkScalar LiberationMonoBoldItalicPoints[] = { @@ -4845,8 +4842,7 @@ const SkFixed LiberationMonoBoldItalicWidths[] = { const int LiberationMonoBoldItalicCharCodesCount = (int) SK_ARRAY_COUNT(LiberationMonoBoldItalicCharCodes); const SkPaint::FontMetrics LiberationMonoBoldItalicMetrics = { -0x0000000f, -0.83252f, -0.83252f, 0.300293f, 0.300293f, 0, 0.600098f, 0.0123749f, --0.0942383f, 0.697754f, 0.52832f, 0.0102921f, 0.100098f, 0.23291f, 0.000778198f, --0.00404358f +0x0000000f, -0.83252f, -0.83252f, 0.300293f, 0.300293f, 0, 0.600098f, 0.791992f, -0.0942383f, +0.697754f, 0.52832f, 0.658691f, 0.100098f, 0.23291f, 0.0498047f, -0.258789f }; diff --git a/tools/test_font_sans_serif.inc b/tools/test_font_sans_serif.inc index 2011c5f810..8bdfb33d2d 100644 --- a/tools/test_font_sans_serif.inc +++ b/tools/test_font_sans_serif.inc @@ -1187,9 +1187,8 @@ const SkFixed LiberationSansNormalWidths[] = { const int LiberationSansNormalCharCodesCount = (int) SK_ARRAY_COUNT(LiberationSansNormalCharCodes); const SkPaint::FontMetrics LiberationSansNormalMetrics = { -0x0000000f, -0.910156f, -0.905273f, 0.211914f, 0.303223f, 0.0327148f, 0.589355f, 0.0195847f, --0.203125f, 1.05029f, 0.52832f, 0.0107498f, 0.0732422f, 0.105957f, 0.000778198f, --0.00404358f +0x0000000f, -0.910156f, -0.905273f, 0.211914f, 0.303223f, 0.0327148f, 0.589355f, 1.25342f, +-0.203125f, 1.05029f, 0.52832f, 0.687988f, 0.0732422f, 0.105957f, 0.0498047f, -0.258789f }; const SkScalar LiberationSansBoldPoints[] = { @@ -2352,8 +2351,8 @@ const SkFixed LiberationSansBoldWidths[] = { const int LiberationSansBoldCharCodesCount = (int) SK_ARRAY_COUNT(LiberationSansBoldCharCodes); const SkPaint::FontMetrics LiberationSansBoldMetrics = { -0x0000000f, -1.0332f, -0.905273f, 0.211914f, 0.303223f, 0.0327148f, 0.612305f, 0.0194702f, --0.184082f, 1.06201f, 0.52832f, 0.0107498f, 0.10498f, 0.105957f, 0.000778198f, -0.00404358f +0x0000000f, -1.0332f, -0.905273f, 0.211914f, 0.303223f, 0.0327148f, 0.612305f, 1.24609f, +-0.184082f, 1.06201f, 0.52832f, 0.687988f, 0.10498f, 0.105957f, 0.0498047f, -0.258789f }; const SkScalar LiberationSansItalicPoints[] = { @@ -3593,8 +3592,8 @@ const SkFixed LiberationSansItalicWidths[] = { const int LiberationSansItalicCharCodesCount = (int) SK_ARRAY_COUNT(LiberationSansItalicCharCodes); const SkPaint::FontMetrics LiberationSansItalicMetrics = { -0x0000000f, -1.01416f, -0.905273f, 0.211914f, 0.303223f, 0.0327148f, 0.590332f, 0.0208511f, --0.271973f, 1.0625f, 0.52832f, 0.0107498f, 0.0732422f, 0.105957f, 0.000778198f, -0.00404358f +0x0000000f, -1.01416f, -0.905273f, 0.211914f, 0.303223f, 0.0327148f, 0.590332f, 1.33447f, +-0.271973f, 1.0625f, 0.52832f, 0.687988f, 0.0732422f, 0.105957f, 0.0498047f, -0.258789f }; const SkScalar LiberationSansBoldItalicPoints[] = { @@ -4853,7 +4852,7 @@ const SkFixed LiberationSansBoldItalicWidths[] = { const int LiberationSansBoldItalicCharCodesCount = (int) SK_ARRAY_COUNT(LiberationSansBoldItalicCharCodes); const SkPaint::FontMetrics LiberationSansBoldItalicMetrics = { -0x0000000f, -1.02979f, -0.905273f, 0.211914f, 0.303223f, 0.0327148f, 0.61377f, 0.0208969f, --0.208984f, 1.12842f, 0.52832f, 0.0107498f, 0.10498f, 0.105957f, 0.000778198f, -0.00404358f +0x0000000f, -1.02979f, -0.905273f, 0.211914f, 0.303223f, 0.0327148f, 0.61377f, 1.3374f, +-0.208984f, 1.12842f, 0.52832f, 0.687988f, 0.10498f, 0.105957f, 0.0498047f, -0.258789f }; diff --git a/tools/test_font_serif.inc b/tools/test_font_serif.inc index 8035fb8f26..4c7121c72d 100644 --- a/tools/test_font_serif.inc +++ b/tools/test_font_serif.inc @@ -1264,9 +1264,8 @@ const SkFixed LiberationSerifNormalWidths[] = { const int LiberationSerifNormalCharCodesCount = (int) SK_ARRAY_COUNT(LiberationSerifNormalCharCodes); const SkPaint::FontMetrics LiberationSerifNormalMetrics = { -0x0000000f, -0.981445f, -0.891113f, 0.216309f, 0.303223f, 0.0424805f, 0.567383f, 0.0184937f, --0.176758f, 1.00684f, 0.458984f, 0.010231f, 0.0488281f, 0.108887f, 0.000762939f, --0.00320435f +0x0000000f, -0.981445f, -0.891113f, 0.216309f, 0.303223f, 0.0424805f, 0.567383f, 1.18359f, +-0.176758f, 1.00684f, 0.458984f, 0.654785f, 0.0488281f, 0.108887f, 0.0488281f, -0.205078f }; const SkScalar LiberationSerifBoldPoints[] = { @@ -2515,9 +2514,8 @@ const SkFixed LiberationSerifBoldWidths[] = { const int LiberationSerifBoldCharCodesCount = (int) SK_ARRAY_COUNT(LiberationSerifBoldCharCodes); const SkPaint::FontMetrics LiberationSerifBoldMetrics = { -0x0000000f, -1.00781f, -0.891113f, 0.216309f, 0.303223f, 0.0424805f, 0.59375f, 0.0197983f, --0.182129f, 1.08496f, 0.458984f, 0.010231f, 0.0952148f, 0.108887f, 0.000778198f, --0.00404358f +0x0000000f, -1.00781f, -0.891113f, 0.216309f, 0.303223f, 0.0424805f, 0.59375f, 1.26709f, +-0.182129f, 1.08496f, 0.458984f, 0.654785f, 0.0952148f, 0.108887f, 0.0498047f, -0.258789f }; const SkScalar LiberationSerifItalicPoints[] = { @@ -3834,9 +3832,8 @@ const SkFixed LiberationSerifItalicWidths[] = { const int LiberationSerifItalicCharCodesCount = (int) SK_ARRAY_COUNT(LiberationSerifItalicCharCodes); const SkPaint::FontMetrics LiberationSerifItalicMetrics = { -0x0000000f, -0.980957f, -0.891113f, 0.216309f, 0.303223f, 0.0424805f, 0.559082f, 0.0197601f, --0.176758f, 1.08789f, 0.458984f, 0.010231f, 0.0488281f, 0.108887f, 0.000778198f, --0.00404358f +0x0000000f, -0.980957f, -0.891113f, 0.216309f, 0.303223f, 0.0424805f, 0.559082f, 1.26465f, +-0.176758f, 1.08789f, 0.458984f, 0.654785f, 0.0488281f, 0.108887f, 0.0498047f, -0.258789f }; const SkScalar LiberationSerifBoldItalicPoints[] = { @@ -5147,8 +5144,7 @@ const SkFixed LiberationSerifBoldItalicWidths[] = { const int LiberationSerifBoldItalicCharCodesCount = (int) SK_ARRAY_COUNT(LiberationSerifBoldItalicCharCodes); const SkPaint::FontMetrics LiberationSerifBoldItalicMetrics = { -0x0000000f, -0.980957f, -0.891113f, 0.216309f, 0.303223f, 0.0424805f, 0.578125f, 0.0207596f, --0.178223f, 1.15039f, 0.458984f, 0.010231f, 0.0952148f, 0.108887f, 0.000778198f, --0.00404358f +0x0000000f, -0.980957f, -0.891113f, 0.216309f, 0.303223f, 0.0424805f, 0.578125f, 1.32861f, +-0.178223f, 1.15039f, 0.458984f, 0.654785f, 0.0952148f, 0.108887f, 0.0498047f, -0.258789f };