Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Unified Diff: app/gfx/font.h

Issue 338029: Got the about panel to have its text lined up correctly.
Patch Set: Added pango font metrics cache Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app/gfx/canvas_linux.cc ('k') | app/gfx/font_skia.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/gfx/font.h
diff --git a/app/gfx/font.h b/app/gfx/font.h
index bc8ee92e713d2ea0301cac92695aebf6a8521ffe..4bea19489a5a86105faf8bfc69c0d589f3a3118c 100644
--- a/app/gfx/font.h
+++ b/app/gfx/font.h
@@ -136,6 +136,13 @@ class Font {
// Converts |gfx_font| to a new pango font. Free the returned font with
// pango_font_description_free().
static PangoFontDescription* PangoFontFromGfxFont(const gfx::Font& gfx_font);
+
+ // Position as an offset from the height of the drawn text, used to draw
+ // an underline. This is a negative number, so the underline would be
+ // drawn at y + height + underline_position;
+ double underline_position() const;
+ // The thickness to draw the underline.
+ double underline_thickness() const;
#endif
private:
@@ -207,7 +214,10 @@ class Font {
static Font* default_font_;
// The average width of a character, initialized and cached if needed.
- double avg_width();
+ double avg_width() const;
+
+ // Potentially slow call to get pango metrics (avg width, underline info).
+ void InitPangoMetrics();
// These two both point to the same SkTypeface. We use the SkAutoUnref to
// handle the reference counting, but without @typeface_ we would have to
@@ -224,7 +234,13 @@ class Font {
// Cached metrics, generated at construction
int height_;
int ascent_;
+
+ // The pango metrics are much more expensive so we wait until we need them
+ // to compute them.
+ bool pango_metrics_inited_;
double avg_width_;
+ double underline_position_;
+ double underline_thickness_;
#elif defined(OS_MACOSX)
explicit Font(const std::wstring& font_name, int font_size, int style);
« no previous file with comments | « app/gfx/canvas_linux.cc ('k') | app/gfx/font_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698