Chromium Code Reviews| Index: ui/gfx/font_list.cc |
| diff --git a/ui/gfx/font_list.cc b/ui/gfx/font_list.cc |
| index f9b34a674e1f7a72d524b854c16d7a4260512f7e..7fadb856602fae844d013500ae71a0f8e9aa47f0 100644 |
| --- a/ui/gfx/font_list.cc |
| +++ b/ui/gfx/font_list.cc |
| @@ -29,10 +29,12 @@ namespace gfx { |
| bool FontList::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) { |
| DCHECK(families_out); |
| DCHECK(style_out); |
| DCHECK(size_pixels_out); |
| + DCHECK(weight_out); |
| *families_out = base::SplitString( |
| description, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| @@ -59,13 +61,30 @@ bool FontList::ParseDescription(const std::string& description, |
| *size_pixels_out <= 0) |
| return false; |
| - // Font supports BOLD and ITALIC; underline is supported via RenderText. |
| + // Font supports ITALIC and weights; underline is supported via RenderText. |
| *style_out = gfx::Font::NORMAL; |
|
Alexei Svitkine (slow)
2016/04/05 16:38:50
Remove gfx:: here and on the lines below.
|
| + *weight_out = gfx::Font::Weight::NORMAL; |
| for (const auto& style_string : styles) { |
| - if (style_string == "Bold") |
| - *style_out |= gfx::Font::BOLD; |
| - else if (style_string == "Italic") |
| + if (style_string == "Italic") |
| *style_out |= gfx::Font::ITALIC; |
| + else if (style_string == "Thin") |
| + *weight_out = gfx::Font::Weight::THIN; |
| + else if (style_string == "Ultra-Light") |
| + *weight_out = gfx::Font::Weight::EXTRA_LIGHT; |
| + else if (style_string == "Light") |
| + *weight_out = gfx::Font::Weight::LIGHT; |
| + else if (style_string == "Normal") |
| + *weight_out = gfx::Font::Weight::NORMAL; |
| + else if (style_string == "Medium") |
| + *weight_out = gfx::Font::Weight::MEDIUM; |
| + else if (style_string == "Semi-Bold") |
| + *weight_out = gfx::Font::Weight::SEMIBOLD; |
| + else if (style_string == "Bold") |
| + *weight_out = gfx::Font::Weight::BOLD; |
| + else if (style_string == "Ultra-Bold") |
| + *weight_out = gfx::Font::Weight::EXTRA_BOLD; |
| + else if (style_string == "Heavy") |
| + *weight_out = gfx::Font::Weight::BLACK; |
| else |
| return false; |
| } |
| @@ -82,8 +101,9 @@ FontList::FontList(const std::string& font_description_string) |
| FontList::FontList(const std::vector<std::string>& font_names, |
| int font_style, |
| - int font_size) |
| - : impl_(new FontListImpl(font_names, font_style, font_size)) {} |
| + int font_size, |
| + Font::Weight font_weight) |
| + : impl_(new FontListImpl(font_names, font_style, font_size, font_weight)) {} |
| FontList::FontList(const std::vector<Font>& fonts) |
| : impl_(new FontListImpl(fonts)) {} |
| @@ -108,16 +128,22 @@ void FontList::SetDefaultFontDescription(const std::string& font_description) { |
| g_default_impl_initialized = false; |
| } |
| -FontList FontList::Derive(int size_delta, int font_style) const { |
| - return FontList(impl_->Derive(size_delta, font_style)); |
| +FontList FontList::Derive(int size_delta, |
| + int font_style, |
| + gfx::Font::Weight weight) const { |
|
Alexei Svitkine (slow)
2016/04/05 16:38:50
Remove gfx::
|
| + return FontList(impl_->Derive(size_delta, font_style, weight)); |
| } |
| FontList FontList::DeriveWithSizeDelta(int size_delta) const { |
| - return Derive(size_delta, GetFontStyle()); |
| + return Derive(size_delta, GetFontStyle(), GetFontWeight()); |
| } |
| FontList FontList::DeriveWithStyle(int font_style) const { |
| - return Derive(0, font_style); |
| + return Derive(0, font_style, GetFontWeight()); |
| +} |
| + |
| +FontList FontList::DeriveWithWeight(gfx::Font::Weight weight) const { |
|
Alexei Svitkine (slow)
2016/04/05 16:38:50
Remove gfx::
|
| + return Derive(0, GetFontStyle(), weight); |
| } |
| gfx::FontList FontList::DeriveWithHeightUpperBound(int height) const { |
| @@ -165,6 +191,10 @@ int FontList::GetFontSize() const { |
| return impl_->GetFontSize(); |
| } |
| +gfx::Font::Weight FontList::GetFontWeight() const { |
|
Alexei Svitkine (slow)
2016/04/05 16:38:50
Remove gfx::
|
| + return impl_->GetFontWeight(); |
| +} |
| + |
| const std::vector<Font>& FontList::GetFonts() const { |
| return impl_->GetFonts(); |
| } |