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 fbd7abc24615d9ccf030fb99fbf747c994e31ee2..2c66c022bbdf688af773a3aa029358e84ae599a8 100644 |
--- a/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp |
+++ b/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp |
@@ -130,6 +130,13 @@ void SimpleFontData::platformInit(bool subpixelAscentDescent) { |
float ascent; |
float descent; |
+ // 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. |
+ subpixelAscentDescent = |
eae
2016/11/04 18:25:28
Please use a different name here to avoid the appe
zakerinasab
2016/11/07 18:40:26
Done.
|
+ subpixelAscentDescent && |
+ (-metrics.fAscent < 3 || -metrics.fAscent + metrics.fDescent < 2); |
+ |
// Beware those who step here: This code is designed to match Win32 font |
// metrics *exactly* except: |
// - the adjustment of ascent/descent on Linux/Android |
@@ -138,17 +145,10 @@ void SimpleFontData::platformInit(bool subpixelAscentDescent) { |
ascent = vdmxAscent; |
descent = -vdmxDescent; |
} else { |
- // 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 = subpixelAscentDescent ? -metrics.fAscent |
+ : SkScalarRoundToScalar(-metrics.fAscent); |
+ descent = subpixelAscentDescent ? metrics.fDescent |
+ : SkScalarRoundToScalar(metrics.fDescent); |
#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: |
@@ -176,8 +176,11 @@ void SimpleFontData::platformInit(bool subpixelAscentDescent) { |
DEFINE_STATIC_LOCAL(AtomicString, courierName, ("Courier")); |
String familyName = m_platformData.fontFamilyName(); |
if (familyName == timesName || familyName == helveticaName || |
- familyName == courierName) |
- ascent += floorf(((ascent + descent) * 0.15f) + 0.5f); |
+ familyName == courierName) { |
+ ascent += subpixelAscentDescent |
+ ? ((ascent + descent) * 0.15f) |
+ : floorf(((ascent + descent) * 0.15f) + 0.5f); |
+ } |
#endif |
m_fontMetrics.setAscent(ascent); |
@@ -348,6 +351,12 @@ PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData( |
return m_derivedFontData->emphasisMark; |
} |
+PassRefPtr<SimpleFontData> SimpleFontData::subpixelAscentDescentFontData() |
+ const { |
+ return SimpleFontData::create(m_platformData, m_customFontData, |
+ m_isTextOrientationFallback, true); |
+} |
+ |
bool SimpleFontData::isTextOrientationFallbackOf( |
const SimpleFontData* fontData) const { |
if (!isTextOrientationFallback() || !fontData->m_derivedFontData) |