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..4e3b901bf624c72536450270e7158e914103e168 100644 |
--- a/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp |
+++ b/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp |
@@ -133,30 +133,40 @@ 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 overflowAdjustmentForAscent = 0; |
+ if (ascent < SkScalarToFloat(-metrics.fAscent)) |
+ ++overflowAdjustmentForAscent; |
+ int overflowAdjustmentForDescent = 0; |
+ if (descent < SkScalarToFloat(metrics.fDescent)) { |
+ ++overflowAdjustmentForDescent; |
#if OS(LINUX) || OS(ANDROID) |
chrishtr
2017/04/06 21:07:00
This Android/Linux part used to be conditioned on
Xianzhu
2017/04/06 21:20:47
Yes. The condition 'descent < SkScalarToFloat(metr
|
- // 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; |
+ --overflowAdjustmentForDescent; |
+ --ascent; |
+ ++overflowAdjustmentForAscent; |
+ } |
#endif |
+ } |
+ m_fontMetrics.setVisualOverflowAdjustments(overflowAdjustmentForAscent, |
+ overflowAdjustmentForDescent); |
} |
#if OS(MACOSX) |