| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/font_list.h" | 5 #include "ui/gfx/font_list.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 if (common_baseline_ == -1) | 175 if (common_baseline_ == -1) |
| 176 CacheCommonFontHeightAndBaseline(); | 176 CacheCommonFontHeightAndBaseline(); |
| 177 return common_baseline_; | 177 return common_baseline_; |
| 178 } | 178 } |
| 179 | 179 |
| 180 int FontList::GetCapHeight() const { | 180 int FontList::GetCapHeight() const { |
| 181 // Assume the primary font is used to render Latin characters. | 181 // Assume the primary font is used to render Latin characters. |
| 182 return GetPrimaryFont().GetCapHeight(); | 182 return GetPrimaryFont().GetCapHeight(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 int FontList::GetStringWidth(const base::string16& text) const { | 185 float FontList::GetStringWidth(const base::string16& text) const { |
| 186 // Rely on the primary font metrics for the time being. | 186 // Rely on the primary font metrics for the time being. |
| 187 // TODO(yukishiino): Not only the first font, all the fonts in the list should | 187 // TODO(yukishiino): Not only the first font, all the fonts in the list should |
| 188 // be taken into account to compute the pixels needed to display |text|. | 188 // be taken into account to compute the pixels needed to display |text|. |
| 189 // Also this method, including one in Font class, should be deprecated and | 189 // Also this method, including one in Font class, should be deprecated and |
| 190 // client code should call Canvas::GetStringWidth(text, font_list) directly. | 190 // client code should call Canvas::GetStringWidth(text, font_list) directly. |
| 191 // Our plan is as follows: | 191 // Our plan is as follows: |
| 192 // 1. Introduce the FontList version of Canvas::GetStringWidth(). | 192 // 1. Introduce the FontList version of Canvas::GetStringWidth(). |
| 193 // 2. Make client code call Canvas::GetStringWidth(). | 193 // 2. Make client code call Canvas::GetStringWidth(). |
| 194 // 3. Retire {Font,FontList}::GetStringWidth(). | 194 // 3. Retire {Font,FontList}::GetStringWidth(). |
| 195 return GetPrimaryFont().GetStringWidth(text); | 195 return GetPrimaryFont().GetStringWidth(text); |
| 196 } | 196 } |
| 197 | 197 |
| 198 int FontList::GetExpectedTextWidth(int length) const { | 198 float FontList::GetExpectedTextWidth(int length) const { |
| 199 // Rely on the primary font metrics for the time being. | 199 // Rely on the primary font metrics for the time being. |
| 200 return GetPrimaryFont().GetExpectedTextWidth(length); | 200 return GetPrimaryFont().GetExpectedTextWidth(length); |
| 201 } | 201 } |
| 202 | 202 |
| 203 int FontList::GetFontStyle() const { | 203 int FontList::GetFontStyle() const { |
| 204 if (font_style_ == -1) | 204 if (font_style_ == -1) |
| 205 CacheFontStyleAndSize(); | 205 CacheFontStyleAndSize(); |
| 206 return font_style_; | 206 return font_style_; |
| 207 } | 207 } |
| 208 | 208 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 font_style_ = fonts_[0].GetStyle(); | 269 font_style_ = fonts_[0].GetStyle(); |
| 270 font_size_ = fonts_[0].GetFontSize(); | 270 font_size_ = fonts_[0].GetFontSize(); |
| 271 } else { | 271 } else { |
| 272 std::vector<std::string> font_names; | 272 std::vector<std::string> font_names; |
| 273 ParseFontDescriptionString(font_description_string_, &font_names, | 273 ParseFontDescriptionString(font_description_string_, &font_names, |
| 274 &font_style_, &font_size_); | 274 &font_style_, &font_size_); |
| 275 } | 275 } |
| 276 } | 276 } |
| 277 | 277 |
| 278 } // namespace gfx | 278 } // namespace gfx |
| OLD | NEW |