summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 00:43:02 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 00:43:02 +0000
commitb551829b85f7a473497d9051ffb0edbf4ba1b589 (patch)
tree397b2566fe799fc5e699bb2a6818dfc2ff0b7e76
parent14b27b4a744757f19e09b630a51a411cf53e1982 (diff)
downloadchromium_src-b551829b85f7a473497d9051ffb0edbf4ba1b589.zip
chromium_src-b551829b85f7a473497d9051ffb0edbf4ba1b589.tar.gz
chromium_src-b551829b85f7a473497d9051ffb0edbf4ba1b589.tar.bz2
Skia: remove fHeight (retry)
Skia was previously calculating the leading value incorrectly, leading us to add fHeight to get the height of a line of text. Now that Skia is calculating fLeading correctly, we can remove fHeight. http://codereview.chromium.org/62123 https://bugs.webkit.org/show_bug.cgi?id=25083 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13316 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/gfx/chrome_font_skia.cc2
-rw-r--r--skia/include/SkPaint.h1
-rw-r--r--skia/ports/SkFontHost_FreeType.cpp17
3 files changed, 8 insertions, 12 deletions
diff --git a/chrome/common/gfx/chrome_font_skia.cc b/chrome/common/gfx/chrome_font_skia.cc
index 6c80c8d..0c3b721 100644
--- a/chrome/common/gfx/chrome_font_skia.cc
+++ b/chrome/common/gfx/chrome_font_skia.cc
@@ -42,7 +42,7 @@ void ChromeFont::calculateMetrics() {
height_ = ascent_ + metrics.fVDMXDescent;
} else {
ascent_ = SkScalarRound(-metrics.fAscent);
- height_ = SkScalarRound(metrics.fHeight);
+ height_ = SkScalarRound(metrics.fAscent + metrics.fDescent + metrics.fLeading);
}
if (metrics.fAvgCharWidth) {
diff --git a/skia/include/SkPaint.h b/skia/include/SkPaint.h
index b871bda..d13d090 100644
--- a/skia/include/SkPaint.h
+++ b/skia/include/SkPaint.h
@@ -616,7 +616,6 @@ public:
SkScalar fDescent; //!< The recommended distance below the baseline (will be >= 0)
SkScalar fBottom; //!< The greatest distance below the baseline for any glyph (will be >= 0)
SkScalar fLeading; //!< The recommended distance to add between lines of text (will be >= 0)
- SkScalar fHeight; //!< the vertical distance between two consecutive baselines (>= 0)
SkScalar fAvgCharWidth; //!< the average charactor width (>= 0)
SkScalar fXMin; //!< The minimum bounding box x value for all glyphs
SkScalar fXMax; //!< The maximum bounding box x value for all glyphs
diff --git a/skia/ports/SkFontHost_FreeType.cpp b/skia/ports/SkFontHost_FreeType.cpp
index 8ffb3ca..f1f1569 100644
--- a/skia/ports/SkFontHost_FreeType.cpp
+++ b/skia/ports/SkFontHost_FreeType.cpp
@@ -860,8 +860,8 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
return;
}
- SkPoint pts[7];
- SkFixed ys[7];
+ SkPoint pts[6];
+ SkFixed ys[6];
FT_Face face = fFace;
int upem = face->units_per_EM;
SkFixed scaleY = fScaleY;
@@ -870,7 +870,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
SkScalar xmin = static_cast<SkScalar>(face->bbox.xMin) / upem;
SkScalar xmax = static_cast<SkScalar>(face->bbox.xMax) / upem;
- int leading = face->height - face->ascender + face->descender;
+ int leading = face->height - (face->ascender + -face->descender);
if (leading < 0) {
leading = 0;
}
@@ -884,8 +884,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
ys[2] = -face->descender;
ys[3] = -face->bbox.yMin;
ys[4] = leading;
- ys[5] = face->height;
- ys[6] = os2 ? os2->xAvgCharWidth : 0;
+ ys[5] = os2 ? os2->xAvgCharWidth : 0;
SkScalar x_height;
if (os2 && os2->sxHeight) {
@@ -904,7 +903,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
}
// convert upem-y values into scalar points
- for (int i = 0; i < 7; i++) {
+ for (int i = 0; i < 6; i++) {
SkFixed y = SkMulDiv(scaleY, ys[i], upem);
SkFixed x = SkFixedMul(mxy, y);
y = SkFixedMul(myy, y);
@@ -917,8 +916,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
mx->fDescent = pts[2].fX;
mx->fBottom = pts[3].fX;
mx->fLeading = pts[4].fX;
- mx->fHeight = pts[5].fX;
- mx->fAvgCharWidth = pts[6].fX;
+ mx->fAvgCharWidth = pts[5].fX;
mx->fXMin = xmin;
mx->fXMax = xmax;
mx->fXHeight = x_height;
@@ -933,8 +931,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
my->fDescent = pts[2].fY;
my->fBottom = pts[3].fY;
my->fLeading = pts[4].fY;
- my->fHeight = pts[5].fY;
- my->fAvgCharWidth = pts[6].fY;
+ my->fAvgCharWidth = pts[5].fY;
my->fXMin = xmin;
my->fXMax = xmax;
my->fXHeight = x_height;