diff options
author | Steve Block <steveblock@google.com> | 2011-05-18 13:36:51 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-24 15:38:28 +0100 |
commit | 2fc2651226baac27029e38c9d6ef883fa32084db (patch) | |
tree | e396d4bf89dcce6ed02071be66212495b1df1dec /Source/WebCore/platform/graphics/freetype | |
parent | b3725cedeb43722b3b175aaeff70552e562d2c94 (diff) | |
download | external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.zip external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.gz external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.bz2 |
Merge WebKit at r78450: Initial merge by git.
Change-Id: I6d3e5f1f868ec266a0aafdef66182ddc3f265dc1
Diffstat (limited to 'Source/WebCore/platform/graphics/freetype')
-rw-r--r-- | Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp | 2 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp | 21 |
2 files changed, 15 insertions, 8 deletions
diff --git a/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp index c547224..841c8a3 100644 --- a/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp +++ b/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp @@ -59,7 +59,7 @@ FontCustomPlatformData::~FontCustomPlatformData() cairo_font_face_destroy(m_fontFace); } -FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontRenderingMode) +FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontWidthVariant, FontRenderingMode) { return FontPlatformData(m_fontFace, size, bold, italic); } diff --git a/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp index 97fd81a..6290eeb 100644 --- a/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp +++ b/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp @@ -50,21 +50,28 @@ void SimpleFontData::platformInit() cairo_font_extents_t font_extents; cairo_text_extents_t text_extents; cairo_scaled_font_extents(m_platformData.scaledFont(), &font_extents); - m_ascent = static_cast<int>(lroundf(font_extents.ascent)); - m_descent = static_cast<int>(lroundf(font_extents.descent)); - m_lineSpacing = static_cast<int>(lroundf(font_extents.height)); + + m_fontMetrics.setAscent(font_extents.ascent); + m_fontMetrics.setDescent(font_extents.descent); + // There seems to be some rounding error in cairo (or in how we // use cairo) with some fonts, like DejaVu Sans Mono, which makes // cairo report a height smaller than ascent + descent, which is // wrong and confuses WebCore's layout system. Workaround this // while we figure out what's going on. - if (m_lineSpacing < m_ascent + m_descent) - m_lineSpacing = m_ascent + m_descent; + float lineSpacing = font_extents.height; + if (lineSpacing < font_extents.ascent + font_extents.descent) + lineSpacing = font_extents.ascent + font_extents.descent; + + m_fontMetrics.setLineSpacing(lroundf(lineSpacing)); + m_fontMetrics.setLineGap(lineSpacing - font_extents.ascent - font_extents.descent); + cairo_scaled_font_text_extents(m_platformData.scaledFont(), "x", &text_extents); - m_xHeight = text_extents.height; + m_fontMetrics.setXHeight(text_extents.height); + cairo_scaled_font_text_extents(m_platformData.scaledFont(), " ", &text_extents); m_spaceWidth = static_cast<float>(text_extents.x_advance); - m_lineGap = m_lineSpacing - m_ascent - m_descent; + m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f; } |