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

Unified Diff: ui/gfx/font_list.h

Issue 21868004: Supports FontList::DeriveFontListWithSizeDeltaAndStyle, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
Index: ui/gfx/font_list.h
diff --git a/ui/gfx/font_list.h b/ui/gfx/font_list.h
index 8c1d0f30bc5fe8934e1474157ac007a337381177..f7c71ac28a8b9f4e62b7c969c77c1b1e3d3a74fe 100644
--- a/ui/gfx/font_list.h
+++ b/ui/gfx/font_list.h
@@ -41,6 +41,11 @@ class UI_EXPORT FontList {
// size.
explicit FontList(const std::string& font_description_string);
+ // Creates a font list from font names, styles and size.
+ FontList(const std::vector<std::string>& font_names,
+ int font_style,
+ int font_size);
+
// Creates a font list from a Font vector.
// All fonts in this vector should have the same style and size.
explicit FontList(const std::vector<Font>& fonts);
@@ -57,6 +62,17 @@ class UI_EXPORT FontList {
// given font |size| in pixels.
FontList DeriveFontListWithSize(int size) const;
+ // Returns a new FontList with the same font names and style but with resized.
msw 2013/08/06 05:10:14 nit: s/but with resized/but resized/ (same on line
Yuki 2013/08/07 14:34:03 Done.
+ // |size_delta| is the size in pixels to add to the current font size.
+ FontList DeriveFontListWithSizeDelta(int size_delta) const;
+
+ // Returns a new FontList with the same font names but with resized and
+ // with the given style. |size_delta| is the size in pixels to add to the
+ // current font size. |font_style| specifies the new style, which is a
+ // bitmask of the values: Font::BOLD, Font::ITALIC and Font::UNDERLINE.
+ FontList DeriveFontListWithSizeDeltaAndStyle(int size_delta,
+ int font_style) const;
+
// Returns the height of this font list, which is max(ascent) + max(descent)
// for all the fonts in the font list.
int GetHeight() const;
@@ -65,6 +81,18 @@ class UI_EXPORT FontList {
// fonts in the font list.
int GetBaseline() const;
+ // Returns the average character width for the font list.
+ int GetAverageCharacterWidth() const;
+
+ // Returns the number of horizontal pixels needed to display the specified
msw 2013/08/06 05:10:14 nit: s/the specified string/|text|/
Yuki 2013/08/07 14:34:03 Done.
+ // string.
+ int GetStringWidth(const base::string16& text) const;
+
+ // Returns the expected number of horizontal pixels needed to display the
+ // specified length of characters. Call GetStringWidth() to retrieve the
+ // actual number.
+ int GetExpectedTextWidth(int length) const;
msw 2013/08/06 05:10:14 Is this necessary? It doesn't seem to be used in y
Yuki 2013/08/07 14:34:03 As we discussed, I removed GetAverageCharacterWidt
+
// Returns the |gfx::Font::FontStyle| style flags for this font list.
int GetFontStyle() const;
@@ -99,6 +127,10 @@ class UI_EXPORT FontList {
// The cached common height and baseline of the fonts in the font list.
mutable int common_height_;
mutable int common_baseline_;
+
+ // Cached font style and size.
+ mutable int font_style_;
+ mutable int font_size_;
};
} // namespace gfx

Powered by Google App Engine
This is Rietveld 408576698