Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: ui/gfx/font_list.cc

Issue 19666006: Supports FontList in Textfield. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removes ResourceBundle::Delegate::GetFontList. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 font_description_string_ += name; 201 font_description_string_ += name;
202 font_description_string_ += ','; 202 font_description_string_ += ',';
203 } 203 }
204 // All fonts have the same style and size. 204 // All fonts have the same style and size.
205 font_description_string_ += 205 font_description_string_ +=
206 FontStyleAndSizeToString(fonts_[0].GetStyle(), fonts_[0].GetFontSize()); 206 FontStyleAndSizeToString(fonts_[0].GetStyle(), fonts_[0].GetFontSize());
207 } 207 }
208 return font_description_string_; 208 return font_description_string_;
209 } 209 }
210 210
211 int FontList::GetFontSize() const {
212 if (!fonts_.empty())
213 return fonts_[0].GetFontSize();
214
215 std::vector<std::string> font_names;
216 int font_style;
217 int font_size;
218 ParseFontDescriptionString(font_description_string_, &font_names,
219 &font_style, &font_size);
220 return font_size;
221 }
222
211 const std::vector<Font>& FontList::GetFonts() const { 223 const std::vector<Font>& FontList::GetFonts() const {
212 if (fonts_.empty()) { 224 if (fonts_.empty()) {
213 DCHECK(!font_description_string_.empty()); 225 DCHECK(!font_description_string_.empty());
214 226
215 std::vector<std::string> font_names; 227 std::vector<std::string> font_names;
216 int font_style; 228 int font_style;
217 int font_size; 229 int font_size;
218 ParseFontDescriptionString(font_description_string_, &font_names, 230 ParseFontDescriptionString(font_description_string_, &font_names,
219 &font_style, &font_size); 231 &font_style, &font_size);
220 for (size_t i = 0; i < font_names.size(); ++i) { 232 for (size_t i = 0; i < font_names.size(); ++i) {
221 DCHECK(!font_names[i].empty()); 233 DCHECK(!font_names[i].empty());
222 234
223 Font font(font_names[i], font_size); 235 Font font(font_names[i], font_size);
224 if (font_style == Font::NORMAL) 236 if (font_style == Font::NORMAL)
225 fonts_.push_back(font); 237 fonts_.push_back(font);
226 else 238 else
227 fonts_.push_back(font.DeriveFont(0, font_style)); 239 fonts_.push_back(font.DeriveFont(0, font_style));
228 } 240 }
229 } 241 }
230 return fonts_; 242 return fonts_;
231 } 243 }
232 244
245 const Font& FontList::GetPrimaryFont() const {
246 return GetFonts()[0];
247 }
248
233 } // namespace gfx 249 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698