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

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

Issue 11535014: Replace StyleRange with BreakList; update RenderText, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 10 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
« no previous file with comments | « ui/gfx/font.h ('k') | ui/gfx/pango_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 10 matching lines...) Expand all
21 DCHECK_GT(font_names->size(), 1U); 21 DCHECK_GT(font_names->size(), 1U);
22 22
23 // The last item is [STYLE_OPTIONS] SIZE. 23 // The last item is [STYLE_OPTIONS] SIZE.
24 std::vector<std::string> styles_size; 24 std::vector<std::string> styles_size;
25 base::SplitString(font_names->back(), ' ', &styles_size); 25 base::SplitString(font_names->back(), ' ', &styles_size);
26 DCHECK(!styles_size.empty()); 26 DCHECK(!styles_size.empty());
27 base::StringToInt(styles_size.back(), font_size); 27 base::StringToInt(styles_size.back(), font_size);
28 DCHECK_GT(*font_size, 0); 28 DCHECK_GT(*font_size, 0);
29 font_names->pop_back(); 29 font_names->pop_back();
30 30
31 // Besides underline (which is supported through StyleRange), Font only 31 // Font supports BOLD and ITALIC; underline is supported via RenderText.
32 // supports BOLD and ITALIC, but not other styles.
33 *font_style = 0; 32 *font_style = 0;
34 for (size_t i = 0; i < styles_size.size() - 1; ++i) { 33 for (size_t i = 0; i < styles_size.size() - 1; ++i) {
35 // Styles are separated by white spaces. base::SplitString splits styles 34 // Styles are separated by white spaces. base::SplitString splits styles
36 // by space, and it inserts empty string for continuous spaces. 35 // by space, and it inserts empty string for continuous spaces.
37 if (styles_size[i].empty()) 36 if (styles_size[i].empty())
38 continue; 37 continue;
39 if (!styles_size[i].compare("Bold")) 38 if (!styles_size[i].compare("Bold"))
40 *font_style |= gfx::Font::BOLD; 39 *font_style |= gfx::Font::BOLD;
41 else if (!styles_size[i].compare("Italic")) 40 else if (!styles_size[i].compare("Italic"))
42 *font_style |= gfx::Font::ITALIC; 41 *font_style |= gfx::Font::ITALIC;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (font_style == Font::NORMAL) 189 if (font_style == Font::NORMAL)
191 fonts_.push_back(font); 190 fonts_.push_back(font);
192 else 191 else
193 fonts_.push_back(font.DeriveFont(0, font_style)); 192 fonts_.push_back(font.DeriveFont(0, font_style));
194 } 193 }
195 } 194 }
196 return fonts_; 195 return fonts_;
197 } 196 }
198 197
199 } // namespace gfx 198 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font.h ('k') | ui/gfx/pango_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698