Changeset 101343 in webkit
- Timestamp:
- Nov 29, 2011 1:42:34 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r101342 r101343 1 2011-11-25 Philippe Normand <pnormand@igalia.com> 2 3 [GTK] Improve FontMetrics accuracy 4 https://bugs.webkit.org/show_bug.cgi?id=72614 5 6 Reviewed by Martin Robinson. 7 Patch by Nikolas Zimmermann. 8 9 * platform/graphics/freetype/FontPlatformDataFreeType.cpp: 10 (WebCore::setCairoFontOptionsFromFontConfigPattern): 11 * platform/graphics/freetype/SimpleFontDataFreeType.cpp: 12 (WebCore::SimpleFontData::platformInit): 13 1 14 2011-11-29 Nikolas Zimmermann <nzimmermann@rim.com> 2 15 -
trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp
r96941 r101343 99 99 if (FcPatternGetBool(pattern, FC_HINTING, 0, &booleanResult) == FcResultMatch && !booleanResult) 100 100 cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE); 101 102 // Turn off text metrics hinting, which quantizes metrics to pixels in device space. 103 cairo_font_options_set_hint_metrics(options, CAIRO_HINT_METRICS_OFF); 101 104 } 102 105 -
trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
r90041 r101343 34 34 #include "SimpleFontData.h" 35 35 36 #include "FloatConversion.h" 36 37 #include "FloatRect.h" 37 38 #include "Font.h" … … 56 57 cairo_scaled_font_extents(m_platformData.scaledFont(), &font_extents); 57 58 58 m_fontMetrics.setAscent(font_extents.ascent); 59 m_fontMetrics.setDescent(font_extents.descent); 59 float ascent = narrowPrecisionToFloat(font_extents.ascent); 60 float descent = narrowPrecisionToFloat(font_extents.descent); 61 float lineGap = narrowPrecisionToFloat(font_extents.height - font_extents.ascent - font_extents.descent); 60 62 61 // There seems to be some rounding error in cairo (or in how we 62 // use cairo) with some fonts, like DejaVu Sans Mono, which makes 63 // cairo report a height smaller than ascent + descent, which is 64 // wrong and confuses WebCore's layout system. Workaround this 65 // while we figure out what's going on. 66 float lineSpacing = font_extents.height; 67 if (lineSpacing < font_extents.ascent + font_extents.descent) 68 lineSpacing = font_extents.ascent + font_extents.descent; 63 m_fontMetrics.setAscent(ascent); 64 m_fontMetrics.setDescent(descent); 69 65 70 m_fontMetrics.setLineSpacing(lroundf(lineSpacing)); 71 m_fontMetrics.setLineGap(lineSpacing - font_extents.ascent - font_extents.descent); 66 // Match CoreGraphics metrics. 67 m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap)); 68 m_fontMetrics.setLineGap(lineGap); 72 69 73 70 cairo_scaled_font_text_extents(m_platformData.scaledFont(), "x", &text_extents); 74 m_fontMetrics.setXHeight( text_extents.height);71 m_fontMetrics.setXHeight(narrowPrecisionToFloat(text_extents.height)); 75 72 76 73 cairo_scaled_font_text_extents(m_platformData.scaledFont(), " ", &text_extents); 77 m_spaceWidth = static_cast<float>(text_extents.x_advance);74 m_spaceWidth = narrowPrecisionToFloat(text_extents.x_advance); 78 75 79 76 m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f;
Note: See TracChangeset
for help on using the changeset viewer.