diff options
author | Steve Block <steveblock@google.com> | 2011-05-19 13:21:16 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-25 15:27:43 +0100 |
commit | 741305eba09a1f6a5258684e97bf20c883329829 (patch) | |
tree | aa04569e30259cc9c656c5fb51686ac145538f9b /Source/WebCore/platform/graphics | |
parent | 1db27a13dbd4fb89dc18870bd92cc4ec87a65a62 (diff) | |
download | external_webkit-741305eba09a1f6a5258684e97bf20c883329829.zip external_webkit-741305eba09a1f6a5258684e97bf20c883329829.tar.gz external_webkit-741305eba09a1f6a5258684e97bf20c883329829.tar.bz2 |
Merge WebKit at r78450: Use new FontMetrics
See http://trac.webkit.org/changeset/76442
Note that this change also switches from integer to floating point precision for font metrics.
This is a TODO on other platforms.
Change-Id: I5bcecd5abbe1be8e138aaf25102487b73c936b77
Diffstat (limited to 'Source/WebCore/platform/graphics')
-rw-r--r-- | Source/WebCore/platform/graphics/android/FontDataAndroid.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/Source/WebCore/platform/graphics/android/FontDataAndroid.cpp b/Source/WebCore/platform/graphics/android/FontDataAndroid.cpp index 545dcf7..1f19b6d 100644 --- a/Source/WebCore/platform/graphics/android/FontDataAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/FontDataAndroid.cpp @@ -43,22 +43,20 @@ namespace WebCore { void SimpleFontData::platformInit() { SkPaint paint; - SkPaint::FontMetrics metrics; + SkPaint::FontMetrics skiaFontMetrics; m_platformData.setupPaint(&paint); - (void)paint.getFontMetrics(&metrics); - - // use ceil instead of round to favor descent, given a lot of accidental - // clipping of descenders (e.g. 14pt 'g') in textedit fields - int d = SkScalarCeil(metrics.fDescent); - int s = SkScalarRound(metrics.fDescent - metrics.fAscent); - int a = s - d; - - m_ascent = a; - m_descent = d; - m_xHeight = SkScalarToFloat(-metrics.fAscent) * 0.56f; // hack I stole from the window's port - m_lineSpacing = a + d; - m_lineGap = SkScalarRound(metrics.fLeading); + paint.getFontMetrics(&skiaFontMetrics); + + float d = SkScalarToFloat(skiaFontMetrics.fDescent); + float s = SkScalarToFloat(skiaFontMetrics.fDescent - skiaFontMetrics.fAscent); + float a = s - d; + + m_fontMetrics.setAscent(a); + m_fontMetrics.setDescent(d); + m_fontMetrics.setXHeight(SkScalarToFloat(-skiaFontMetrics.fAscent) * 0.56f); // hack I stole from the window's port + m_fontMetrics.setLineSpacing(a + d); + m_fontMetrics.setLineGap(SkScalarToFloat(skiaFontMetrics.fLeading)); } void SimpleFontData::platformCharWidthInit() |