| 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 33c66ce31cfd02e8763f2318b4c145b209e3b25f..a9b70c6727520d6a29e7e3ef2e3bf4adcb0ad088 100644
|
| --- a/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp
|
| +++ b/third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp
|
| @@ -86,7 +86,7 @@ SimpleFontData::SimpleFontData(PassRefPtr<CustomFontData> customData,
|
| m_hasVerticalGlyphs(false),
|
| m_customFontData(customData) {}
|
|
|
| -void SimpleFontData::platformInit(bool subpixelAscentDescent) {
|
| +void SimpleFontData::platformInit(bool subpixelAscentDescentForSmallSizes) {
|
| if (!m_platformData.size()) {
|
| m_fontMetrics.reset();
|
| m_avgCharWidth = 0;
|
| @@ -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.
|
| + bool subpixelAscentDescentAndFontSmall =
|
| + subpixelAscentDescentForSmallSizes &&
|
| + (-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,12 @@ 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 = subpixelAscentDescentAndFontSmall
|
| + ? -metrics.fAscent
|
| + : SkScalarRoundToScalar(-metrics.fAscent);
|
| + descent = subpixelAscentDescentAndFontSmall
|
| + ? 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 +178,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 += subpixelAscentDescentAndFontSmall
|
| + ? ((ascent + descent) * 0.15f)
|
| + : floorf(((ascent + descent) * 0.15f) + 0.5f);
|
| + }
|
| #endif
|
|
|
| m_fontMetrics.setAscent(ascent);
|
| @@ -348,6 +353,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)
|
|
|