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

Unified Diff: ui/gfx/font_list.h

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Alexei's issues Created 4 years, 8 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 2b67c4a13e2cf2e5b7bc6e93c93eac128ef5a3fa..24297dfd1ddccec3947adbfa602a3e4df94e87e2 100644
--- a/ui/gfx/font_list.h
+++ b/ui/gfx/font_list.h
@@ -28,21 +28,23 @@ class FontListImpl;
// The format is "<FONT_FAMILY_LIST>,[STYLES] <SIZE>", where:
// - FONT_FAMILY_LIST is a comma-separated list of font family names,
// - STYLES is an optional space-separated list of style names (case-sensitive
-// "Bold" and "Italic" are supported), and
-// - SIZE is an integer font size in pixels with the suffix "px".
+// "Italic" "Ultra-Light" "Light" "Normal" "Semi-Bold" "Bold" "Ultra-Bold"
+// "Heavy" are supported), and
+// - SIZE is an integer font size in pixels with the suffix "px"
//
// Here are examples of valid font description strings:
-// - "Arial, Helvetica, Bold Italic 14px"
+// - "Arial, Helvetica, Italic Semi-Bold 14px"
// - "Arial, 14px"
class GFX_EXPORT FontList {
public:
// Parses a FontList description string into |families_out|, |style_out| (a
- // bitfield of gfx::Font::Style values), and |size_pixels_out|. Returns true
- // if the string is properly-formed.
+ // bitfield of gfx::Font::Style values), |size_pixels_out| and |weight_out|.
+ // Returns true if the string is properly-formed.
static bool ParseDescription(const std::string& description,
std::vector<std::string>* families_out,
int* style_out,
- int* size_pixels_out);
+ int* size_pixels_out,
+ gfx::Font::Weight* weight_out);
Alexei Svitkine (slow) 2016/04/05 16:38:50 Remove gfx::
// Creates a font list with default font names, size and style, which are
// specified by SetDefaultFontDescription().
@@ -55,10 +57,11 @@ class GFX_EXPORT FontList {
// size.
explicit FontList(const std::string& font_description_string);
- // Creates a font list from font names, styles and size.
+ // Creates a font list from font names, styles, size and weight.
FontList(const std::vector<std::string>& font_names,
int font_style,
- int font_size);
+ int font_size,
+ Font::Weight font_weight);
// Creates a font list from a Font vector.
// All fonts in this vector should have the same style and size.
@@ -83,20 +86,27 @@ class GFX_EXPORT FontList {
static void SetDefaultFontDescription(const std::string& font_description);
// Returns a new FontList with the same font names but resized and 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 Derive(int size_delta, int font_style) const;
+ // style and weight. |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::ITALIC and Font::UNDERLINE. |weight| is the requested font
+ // weight.
+ FontList Derive(int size_delta,
+ int font_style,
+ gfx::Font::Weight weight) const;
Alexei Svitkine (slow) 2016/04/05 16:38:50 Remove gfx::
// Returns a new FontList with the same font names and style but resized.
// |size_delta| is the size in pixels to add to the current font size.
FontList DeriveWithSizeDelta(int size_delta) const;
- // Returns a new FontList with the same font names and size but the given
- // style. |font_style| specifies the new style, which is a bitmask of the
- // values: Font::BOLD, Font::ITALIC and Font::UNDERLINE.
+ // Returns a new FontList with the same font names, weight and size but the
+ // given style. |font_style| specifies the new style, which is a bitmask of
+ // the values: Font::ITALIC and Font::UNDERLINE.
FontList DeriveWithStyle(int font_style) const;
+ // Returns a new FontList with the same font name, size and style but with
+ // the given weight.
+ FontList DeriveWithWeight(gfx::Font::Weight weight) const;
Alexei Svitkine (slow) 2016/04/05 16:38:50 Remove gfx::
+
// Shrinks the font size until the font list fits within |height| while
// having its cap height vertically centered. Returns a new FontList with
// the correct height.
@@ -145,6 +155,9 @@ class GFX_EXPORT FontList {
// Returns the font size in pixels.
int GetFontSize() const;
+ // Returns the font weight.
+ gfx::Font::Weight GetFontWeight() const;
Alexei Svitkine (slow) 2016/04/05 16:38:50 Remove gfx::
+
// Returns the Font vector.
const std::vector<Font>& GetFonts() const;

Powered by Google App Engine
This is Rietveld 408576698