Index: third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp |
diff --git a/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp b/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp |
index 136998d0b3f5484dc9d93b37b9bdff9796e13c56..55662ca66843899c8f322fe8ea6595279b40d3f7 100644 |
--- a/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp |
+++ b/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp |
@@ -133,30 +133,38 @@ void SimpleFontData::platformInit(bool subpixelAscentDescent) { |
if (isVDMXValid) { |
ascent = vdmxAscent; |
descent = -vdmxDescent; |
- } else { |
+ } else if (subpixelAscentDescent && |
+ (-metrics.fAscent < 3 || |
+ -metrics.fAscent + metrics.fDescent < 2)) { |
// For tiny fonts, the rounding of fAscent and fDescent results in equal |
// baseline for different types of text baselines (crbug.com/338908). |
// Please see CanvasRenderingContext2D::getFontBaseline for the heuristic. |
- if (subpixelAscentDescent && |
- (-metrics.fAscent < 3 || -metrics.fAscent + metrics.fDescent < 2)) { |
- ascent = -metrics.fAscent; |
- descent = metrics.fDescent; |
- } else { |
- ascent = SkScalarRoundToScalar(-metrics.fAscent); |
- descent = SkScalarRoundToScalar(metrics.fDescent); |
- } |
+ ascent = -metrics.fAscent; |
+ descent = metrics.fDescent; |
+ } else { |
+ ascent = SkScalarRoundToScalar(-metrics.fAscent); |
+ descent = SkScalarRoundToScalar(metrics.fDescent); |
+ |
+ int overflowInflationForAscent = ascent < -metrics.fAscent ? 1 : 0; |
+ int overflowInflationForDescent = descent < metrics.fDescent ? 1 : 0; |
+ if (overflowInflationForDescent) { |
#if OS(LINUX) || OS(ANDROID) |
- // When subpixel positioning is enabled, if the descent is rounded down, the |
- // descent part of the glyph may be truncated when displayed in a 'overflow: |
- // hidden' container. To avoid that, borrow 1 unit from the ascent when |
- // possible. |
- // FIXME: This can be removed if sub-pixel ascent/descent is supported. |
- if (platformData().getFontRenderStyle().useSubpixelPositioning && |
- descent < SkScalarToFloat(metrics.fDescent) && ascent >= 1) { |
- ++descent; |
- --ascent; |
- } |
+ // When subpixel positioning is enabled, if the descent is rounded down, |
+ // the descent part of the glyph may be truncated when displayed in a |
+ // 'overflow: hidden' container. To avoid that, borrow 1 unit from the |
+ // ascent when possible. |
+ if (platformData().getFontRenderStyle().useSubpixelPositioning && |
+ ascent >= 1) { |
+ ++descent; |
+ --ascent; |
+ // We should inflate overflow 1 more pixel for ascent instead. |
+ overflowInflationForDescent = 0; |
eae
2017/04/07 17:41:57
Why? The decent has already been inflated to accou
Xianzhu
2017/04/07 18:02:53
The descent is incremented above (line 158) so it'
|
+ ++overflowInflationForAscent; |
+ } |
#endif |
+ } |
+ m_fontMetrics.setVisualOverflowInflations(overflowInflationForAscent, |
+ overflowInflationForDescent); |
} |
#if OS(MACOSX) |