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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 float FontList::GetStringWidthF(const base::string16& text) const { | |
Alexei Svitkine (slow)
2013/10/07 21:43:39
Do we need this? Or can everything that needs it u
jianli
2013/10/07 23:18:45
Done.
| |
199 // Rely on the primary font metrics for the time being. | |
200 // TODO(yukishiino): Not only the first font, all the fonts in the list should | |
201 // be taken into account to compute the pixels needed to display |text|. | |
202 return GetPrimaryFont().GetStringWidthF(text); | |
203 } | |
204 | |
198 int FontList::GetExpectedTextWidth(int length) const { | 205 int FontList::GetExpectedTextWidth(int length) const { |
199 // Rely on the primary font metrics for the time being. | 206 // Rely on the primary font metrics for the time being. |
200 return GetPrimaryFont().GetExpectedTextWidth(length); | 207 return GetPrimaryFont().GetExpectedTextWidth(length); |
201 } | 208 } |
202 | 209 |
203 int FontList::GetFontStyle() const { | 210 int FontList::GetFontStyle() const { |
204 if (font_style_ == -1) | 211 if (font_style_ == -1) |
205 CacheFontStyleAndSize(); | 212 CacheFontStyleAndSize(); |
206 return font_style_; | 213 return font_style_; |
207 } | 214 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 font_style_ = fonts_[0].GetStyle(); | 276 font_style_ = fonts_[0].GetStyle(); |
270 font_size_ = fonts_[0].GetFontSize(); | 277 font_size_ = fonts_[0].GetFontSize(); |
271 } else { | 278 } else { |
272 std::vector<std::string> font_names; | 279 std::vector<std::string> font_names; |
273 ParseFontDescriptionString(font_description_string_, &font_names, | 280 ParseFontDescriptionString(font_description_string_, &font_names, |
274 &font_style_, &font_size_); | 281 &font_style_, &font_size_); |
275 } | 282 } |
276 } | 283 } |
277 | 284 |
278 } // namespace gfx | 285 } // namespace gfx |
OLD | NEW |