Title: [101343] trunk/Source/WebCore
- Revision
- 101343
- Author
- [email protected]
- Date
- 2011-11-29 01:42:34 -0800 (Tue, 29 Nov 2011)
Log Message
[GTK] Improve FontMetrics accuracy
https://bugs.webkit.org/show_bug.cgi?id=72614
Reviewed by Martin Robinson.
Patch by Nikolas Zimmermann.
* platform/graphics/freetype/FontPlatformDataFreeType.cpp:
(WebCore::setCairoFontOptionsFromFontConfigPattern):
* platform/graphics/freetype/SimpleFontDataFreeType.cpp:
(WebCore::SimpleFontData::platformInit):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (101342 => 101343)
--- trunk/Source/WebCore/ChangeLog 2011-11-29 09:40:51 UTC (rev 101342)
+++ trunk/Source/WebCore/ChangeLog 2011-11-29 09:42:34 UTC (rev 101343)
@@ -1,3 +1,16 @@
+2011-11-25 Philippe Normand <[email protected]>
+
+ [GTK] Improve FontMetrics accuracy
+ https://bugs.webkit.org/show_bug.cgi?id=72614
+
+ Reviewed by Martin Robinson.
+ Patch by Nikolas Zimmermann.
+
+ * platform/graphics/freetype/FontPlatformDataFreeType.cpp:
+ (WebCore::setCairoFontOptionsFromFontConfigPattern):
+ * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
+ (WebCore::SimpleFontData::platformInit):
+
2011-11-29 Nikolas Zimmermann <[email protected]>
SVG <path> DRT dumps have rounding problems across platforms
Modified: trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp (101342 => 101343)
--- trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp 2011-11-29 09:40:51 UTC (rev 101342)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp 2011-11-29 09:42:34 UTC (rev 101343)
@@ -98,6 +98,9 @@
cairo_font_options_set_hint_style(options, convertFontConfigHintStyle(integerResult));
if (FcPatternGetBool(pattern, FC_HINTING, 0, &booleanResult) == FcResultMatch && !booleanResult)
cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
+
+ // Turn off text metrics hinting, which quantizes metrics to pixels in device space.
+ cairo_font_options_set_hint_metrics(options, CAIRO_HINT_METRICS_OFF);
}
static cairo_font_options_t* getDefaultFontOptions()
Modified: trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp (101342 => 101343)
--- trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp 2011-11-29 09:40:51 UTC (rev 101342)
+++ trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp 2011-11-29 09:42:34 UTC (rev 101343)
@@ -33,6 +33,7 @@
#include "config.h"
#include "SimpleFontData.h"
+#include "FloatConversion.h"
#include "FloatRect.h"
#include "Font.h"
#include "FontCache.h"
@@ -55,26 +56,22 @@
cairo_text_extents_t text_extents;
cairo_scaled_font_extents(m_platformData.scaledFont(), &font_extents);
- m_fontMetrics.setAscent(font_extents.ascent);
- m_fontMetrics.setDescent(font_extents.descent);
+ float ascent = narrowPrecisionToFloat(font_extents.ascent);
+ float descent = narrowPrecisionToFloat(font_extents.descent);
+ float lineGap = narrowPrecisionToFloat(font_extents.height - font_extents.ascent - 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.
- float lineSpacing = font_extents.height;
- if (lineSpacing < font_extents.ascent + font_extents.descent)
- lineSpacing = font_extents.ascent + font_extents.descent;
+ m_fontMetrics.setAscent(ascent);
+ m_fontMetrics.setDescent(descent);
- m_fontMetrics.setLineSpacing(lroundf(lineSpacing));
- m_fontMetrics.setLineGap(lineSpacing - font_extents.ascent - font_extents.descent);
+ // Match CoreGraphics metrics.
+ m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
+ m_fontMetrics.setLineGap(lineGap);
cairo_scaled_font_text_extents(m_platformData.scaledFont(), "x", &text_extents);
- m_fontMetrics.setXHeight(text_extents.height);
+ m_fontMetrics.setXHeight(narrowPrecisionToFloat(text_extents.height));
cairo_scaled_font_text_extents(m_platformData.scaledFont(), " ", &text_extents);
- m_spaceWidth = static_cast<float>(text_extents.x_advance);
+ m_spaceWidth = narrowPrecisionToFloat(text_extents.x_advance);
m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f;
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes