Correct font metrics, bitmap glyph metrics and underline.
Correct ScaleFontMetrics to scale all of the metrics. Also update the test fonts, since they were created with the previously unscaled metrics. Fix the ascent, descent, and underline position for bitmap glyphs with FreeType. Change-Id: I8c2f6e9d6a7e86b0bb08dc619f62ffcce4ad2df2 Reviewed-on: https://skia-review.googlesource.com/108600 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Hal Canary <halcanary@google.com>
This commit is contained in:
parent
ee78dbe529
commit
5423f1f0c5
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user