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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 CacheCommonFontHeightAndBaseline(); | 170 CacheCommonFontHeightAndBaseline(); |
171 return common_height_; | 171 return common_height_; |
172 } | 172 } |
173 | 173 |
174 int FontList::GetBaseline() const { | 174 int FontList::GetBaseline() const { |
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::GetStringWidth(const base::string16& text) const { | 180 float FontList::GetStringWidth(const base::string16& text) const { |
181 // Rely on the primary font metrics for the time being. | 181 // Rely on the primary font metrics for the time being. |
182 // TODO(yukishiino): Not only the first font, all the fonts in the list should | 182 // TODO(yukishiino): Not only the first font, all the fonts in the list should |
183 // be taken into account to compute the pixels needed to display |text|. | 183 // be taken into account to compute the pixels needed to display |text|. |
184 // Also this method, including one in Font class, should be deprecated and | 184 // Also this method, including one in Font class, should be deprecated and |
185 // client code should call Canvas::GetStringWidth(text, font_list) directly. | 185 // client code should call Canvas::GetStringWidth(text, font_list) directly. |
186 // Our plan is as follows: | 186 // Our plan is as follows: |
187 // 1. Introduce the FontList version of Canvas::GetStringWidth(). | 187 // 1. Introduce the FontList version of Canvas::GetStringWidth(). |
188 // 2. Make client code call Canvas::GetStringWidth(). | 188 // 2. Make client code call Canvas::GetStringWidth(). |
189 // 3. Retire {Font,FontList}::GetStringWidth(). | 189 // 3. Retire {Font,FontList}::GetStringWidth(). |
190 return GetPrimaryFont().GetStringWidth(text); | 190 return GetPrimaryFont().GetStringWidth(text); |
191 } | 191 } |
192 | 192 |
193 int FontList::GetExpectedTextWidth(int length) const { | 193 float FontList::GetExpectedTextWidth(int length) const { |
194 // Rely on the primary font metrics for the time being. | 194 // Rely on the primary font metrics for the time being. |
195 return GetPrimaryFont().GetExpectedTextWidth(length); | 195 return GetPrimaryFont().GetExpectedTextWidth(length); |
196 } | 196 } |
197 | 197 |
198 int FontList::GetFontStyle() const { | 198 int FontList::GetFontStyle() const { |
199 if (font_style_ == -1) | 199 if (font_style_ == -1) |
200 CacheFontStyleAndSize(); | 200 CacheFontStyleAndSize(); |
201 return font_style_; | 201 return font_style_; |
202 } | 202 } |
203 | 203 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 font_style_ = fonts_[0].GetStyle(); | 264 font_style_ = fonts_[0].GetStyle(); |
265 font_size_ = fonts_[0].GetFontSize(); | 265 font_size_ = fonts_[0].GetFontSize(); |
266 } else { | 266 } else { |
267 std::vector<std::string> font_names; | 267 std::vector<std::string> font_names; |
268 ParseFontDescriptionString(font_description_string_, &font_names, | 268 ParseFontDescriptionString(font_description_string_, &font_names, |
269 &font_style_, &font_size_); | 269 &font_style_, &font_size_); |
270 } | 270 } |
271 } | 271 } |
272 | 272 |
273 } // namespace gfx | 273 } // namespace gfx |
OLD | NEW |