Chromium Code Reviews| Index: ui/gfx/font_list.cc |
| diff --git a/ui/gfx/font_list.cc b/ui/gfx/font_list.cc |
| index c2a9927c3b9c89d0ed9e3864a51b3eba8c2669ac..885d66b441166bf45b8e8428309a1e9032bcdc35 100644 |
| --- a/ui/gfx/font_list.cc |
| +++ b/ui/gfx/font_list.cc |
| @@ -173,27 +173,12 @@ void FontList::SetDefaultFontDescription(const std::string& font_description) { |
| g_default_font_list = NULL; |
| } |
| -FontList FontList::DeriveFontList(int font_style) const { |
| - return DeriveFontListWithSizeDeltaAndStyle(0, font_style); |
| -} |
| - |
| -FontList FontList::DeriveFontListWithSize(int size) const { |
| - DCHECK_GT(size, 0); |
| - return DeriveFontListWithSizeDeltaAndStyle(size - GetFontSize(), |
| - GetFontStyle()); |
| -} |
| - |
| -FontList FontList::DeriveFontListWithSizeDelta(int size_delta) const { |
| - return DeriveFontListWithSizeDeltaAndStyle(size_delta, GetFontStyle()); |
| -} |
| - |
| -FontList FontList::DeriveFontListWithSizeDeltaAndStyle(int size_delta, |
| - int style) const { |
| +FontList FontList::Derive(int size_delta, int font_style) const { |
| // If there is a font vector, derive from that. |
| if (!fonts_.empty()) { |
| std::vector<Font> fonts = fonts_; |
| for (size_t i = 0; i < fonts.size(); ++i) |
| - fonts[i] = fonts[i].DeriveFont(size_delta, style); |
| + fonts[i] = fonts[i].DeriveFont(size_delta, font_style); |
| return FontList(fonts); |
| } |
| @@ -203,9 +188,21 @@ FontList FontList::DeriveFontListWithSizeDeltaAndStyle(int size_delta, |
| int old_style; |
| ParseFontDescriptionString(font_description_string_, &font_names, |
| &old_style, &old_size); |
| - int size = old_size + size_delta; |
| - DCHECK_GT(size, 0); |
| - return FontList(font_names, style, size); |
| + const int size = std::max(1, old_size + size_delta); |
| + return FontList(font_names, font_style, size); |
| +} |
| + |
| +FontList FontList::DeriveWithSizeDelta(int size_delta) const { |
| + return Derive(size_delta, GetFontStyle()); |
| +} |
| + |
| +FontList FontList::DeriveFontListWithSizeDelta(int size_delta) const { |
|
Alexei Svitkine (slow)
2014/01/20 15:38:10
Remove this one since it's equivalent to DeriveWit
Yuki
2014/01/20 16:43:24
Will do after I rewrite all calls to this method.
|
| + return Derive(size_delta, GetFontStyle()); |
| +} |
| + |
| +FontList FontList::DeriveFontListWithSizeDeltaAndStyle(int size_delta, |
| + int font_style) const { |
| + return Derive(size_delta, font_style); |
| } |
| int FontList::GetHeight() const { |
| @@ -225,19 +222,6 @@ int FontList::GetCapHeight() const { |
| return GetPrimaryFont().GetCapHeight(); |
| } |
| -int FontList::GetStringWidth(const base::string16& text) const { |
| - // Rely on the primary font metrics for the time being. |
| - // TODO(yukishiino): Not only the first font, all the fonts in the list should |
| - // be taken into account to compute the pixels needed to display |text|. |
| - // Also this method, including one in Font class, should be deprecated and |
| - // client code should call Canvas::GetStringWidth(text, font_list) directly. |
| - // Our plan is as follows: |
| - // 1. Introduce the FontList version of Canvas::GetStringWidth(). |
| - // 2. Make client code call Canvas::GetStringWidth(). |
| - // 3. Retire {Font,FontList}::GetStringWidth(). |
| - return GetPrimaryFont().GetStringWidth(text); |
| -} |
| - |
| int FontList::GetExpectedTextWidth(int length) const { |
| // Rely on the primary font metrics for the time being. |
| return GetPrimaryFont().GetExpectedTextWidth(length); |