summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-17 22:25:23 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-17 22:25:23 +0000
commit21f579df24b83cb11e7211945b83561e0b22da32 (patch)
treef1aa04f242ad2f1e0f178d4b94065c29d2963554 /app
parent3d6202584c5fe55c54a07feeb240f4bdc442aad4 (diff)
downloadchromium_src-21f579df24b83cb11e7211945b83561e0b22da32.zip
chromium_src-21f579df24b83cb11e7211945b83561e0b22da32.tar.gz
chromium_src-21f579df24b83cb11e7211945b83561e0b22da32.tar.bz2
Changes font_skia to use font bounding box rather than
ascent/descent. This gets us closer to sizes used by pango. It's not ideal, but as we can't switch to pango (startup hit), this is the best I can do. BUG=20823 TEST=see bug Review URL: http://codereview.chromium.org/211003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26509 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r--app/gfx/font_skia.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/app/gfx/font_skia.cc b/app/gfx/font_skia.cc
index 4308bf6..1779635 100644
--- a/app/gfx/font_skia.cc
+++ b/app/gfx/font_skia.cc
@@ -5,10 +5,8 @@
#include "app/gfx/font.h"
#include "app/gfx/canvas.h"
-
#include "base/logging.h"
#include "base/sys_string_conversions.h"
-
#include "third_party/skia/include/core/SkTypeface.h"
#include "third_party/skia/include/core/SkPaint.h"
@@ -41,9 +39,18 @@ void Font::calculateMetrics() {
PaintSetup(&paint);
paint.getFontMetrics(&metrics);
- ascent_ = SkScalarRound(-metrics.fAscent);
- height_ = SkScalarRound(-metrics.fAscent + metrics.fDescent +
- metrics.fLeading);
+ // NOTE: we don't use the ascent/descent as it doesn't match with how pango
+ // ends up drawing the text, in particular if we clip to the ascent/descent
+ // the text is clipped. This algorithm doesn't give us an exact match with
+ // the numbers returned from pango (we are off by 1 in some cases), but it
+ // is close enough that you won't notice clipping.
+ //
+ // NOTE2: I tried converting this to use Pango exclusively for measuring the
+ // text but it causes a startup regression. The best I could get it was
+ // ~10% slow down. Slow down appeared to be entirely in libfontconfig.
+ ascent_ = SkScalarCeil(-metrics.fTop);
+ height_ = SkScalarCeil(-metrics.fTop) + SkScalarCeil(metrics.fBottom) +
+ SkScalarCeil(metrics.fLeading);
if (metrics.fAvgCharWidth) {
avg_width_ = SkScalarRound(metrics.fAvgCharWidth);