Commit 154c2288 authored by kojii@chromium.org's avatar kojii@chromium.org

Round glyph width and bounds if !SkPaint.isSubpixelText() in complex path

This patch fixes HarfBuzzFace to round widths and bounds of glyphs
when SkPaint.isSubpixelText() is false.

SimpleFontData::platformWidthForGlyph() and platformBoundsForGlyph()
have this rounding. This difference in HarfBuzzFace caused poor text
positioning only in complex path.

Unlike SimpleFontData that uses round() for glyphBounds, this CL uses
roundOut() to avoid possible glyph rendering outside the visual
overflow rect. The same fix for SimpleFontData is in a separate CL[1].

[1] https://codereview.chromium.org/1326563003/

BUG=452914

Review URL: https://codereview.chromium.org/1316843005

git-svn-id: svn://svn.chromium.org/blink/trunk@201592 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 46246246
...@@ -674,6 +674,20 @@ crbug.com/492664 [ Mac ] imported/csswg-test/css-writing-modes-3/text-baseline-0 ...@@ -674,6 +674,20 @@ crbug.com/492664 [ Mac ] imported/csswg-test/css-writing-modes-3/text-baseline-0
crbug.com/492664 [ Mac ] imported/csswg-test/css-writing-modes-3/text-baseline-008.xht [ ImageOnlyFailure ] crbug.com/492664 [ Mac ] imported/csswg-test/css-writing-modes-3/text-baseline-008.xht [ ImageOnlyFailure ]
crbug.com/492664 [ Mac ] imported/csswg-test/css-writing-modes-3/text-baseline-009.xht [ ImageOnlyFailure ] crbug.com/492664 [ Mac ] imported/csswg-test/css-writing-modes-3/text-baseline-009.xht [ ImageOnlyFailure ]
crbug.com/452914 [ XP Win7 ] fast/text/atsui-multiple-renderers.html [ NeedsRebaseline ]
crbug.com/452914 [ Win ] fast/text/atsui-small-caps-punctuation-size.html [ NeedsRebaseline ]
crbug.com/452914 fast/text/complex-path-with-no-subpixel-fonts.html [ NeedsRebaseline ]
crbug.com/452914 [ Win ] fast/text/international/bidi-listbox-atsui.html [ NeedsRebaseline ]
crbug.com/452914 [ XP Win7 ] fast/text/international/hindi-spacing.html [ NeedsRebaseline ]
crbug.com/452914 [ XP Win7 ] fast/text/international/text-combine-image-test.html [ NeedsRebaseline ]
crbug.com/452914 [ XP Win7 ] fast/text/international/vertical-text-glyph-test.html [ NeedsRebaseline ]
crbug.com/452914 [ Win ] fast/text/justify-ideograph-complex.html [ NeedsRebaseline ]
crbug.com/452914 [ XP Win7 ] fast/text/justify-ideograph-vertical.html [ NeedsRebaseline ]
crbug.com/452914 [ XP Win7 ] fast/text/orientation-sideways.html [ NeedsRebaseline ]
crbug.com/452914 [ Win ] fast/text/sub-pixel/text-scaling-rtl.html [ NeedsRebaseline ]
crbug.com/452914 [ Win ] fast/text/sub-pixel/text-scaling-vertical.html [ NeedsRebaseline ]
crbug.com/452914 [ XP Win7 ] fast/writing-mode/english-lr-text.html [ NeedsRebaseline ]
crbug.com/498845 [ Win ] fast/multicol/vertical-rl/float-content-break.html [ ImageOnlyFailure ] crbug.com/498845 [ Win ] fast/multicol/vertical-rl/float-content-break.html [ ImageOnlyFailure ]
crbug.com/443615 [ Linux Win ] imported/csswg-test/css-shapes-1/shape-outside/supported-shapes/circle/shape-outside-circle-027.html [ ImageOnlyFailure ] crbug.com/443615 [ Linux Win ] imported/csswg-test/css-shapes-1/shape-outside/supported-shapes/circle/shape-outside-circle-027.html [ ImageOnlyFailure ]
......
<!DOCTYPE html>
<style>
div {
font-family:Tahoma;
font-size:14px;
}
.complex {
text-rendering:optimizeLegibility;
}
</style>
<p>All lines should look the same.
<p>This test is intentionally a pixel test, see crbug.com/452914.
<div class=complex>!!!!!!!!!!!!!!<br>!!!!!!!!!!!!!!<br>!!!!!!!!!!!!!!<br>!!!!!!!!!!!!!!</div>
<div>!!!!!!!!!!!!!!<br>!!!!!!!!!!!!!!<br>!!!!!!!!!!!!!!<br>!!!!!!!!!!!!!!</div>
...@@ -146,9 +146,19 @@ static void SkiaGetGlyphWidthAndExtents(SkPaint* paint, hb_codepoint_t codepoint ...@@ -146,9 +146,19 @@ static void SkiaGetGlyphWidthAndExtents(SkPaint* paint, hb_codepoint_t codepoint
uint16_t glyph = codepoint; uint16_t glyph = codepoint;
paint->getTextWidths(&glyph, sizeof(glyph), &skWidth, &skBounds); paint->getTextWidths(&glyph, sizeof(glyph), &skWidth, &skBounds);
if (width) if (width) {
if (!paint->isSubpixelText())
skWidth = SkScalarRoundToInt(skWidth);
*width = SkiaScalarToHarfBuzzPosition(skWidth); *width = SkiaScalarToHarfBuzzPosition(skWidth);
}
if (extents) { if (extents) {
if (!paint->isSubpixelText()) {
// Use roundOut() rather than round() to avoid rendering glyphs
// outside the visual overflow rect. crbug.com/452914.
SkIRect ir;
skBounds.roundOut(&ir);
skBounds.set(ir);
}
// Invert y-axis because Skia is y-grows-down but we set up HarfBuzz to be y-grows-up. // Invert y-axis because Skia is y-grows-down but we set up HarfBuzz to be y-grows-up.
extents->x_bearing = SkiaScalarToHarfBuzzPosition(skBounds.fLeft); extents->x_bearing = SkiaScalarToHarfBuzzPosition(skBounds.fLeft);
extents->y_bearing = SkiaScalarToHarfBuzzPosition(-skBounds.fTop); extents->y_bearing = SkiaScalarToHarfBuzzPosition(-skBounds.fTop);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment