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

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

Issue 18848002: Shows Japanese and English mixed queries correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adds a unit test. Created 7 years, 5 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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 int font_style = 0; 139 int font_style = 0;
140 ParseFontDescriptionString(font_description_string_, &font_names, 140 ParseFontDescriptionString(font_description_string_, &font_names,
141 &font_style, &old_size); 141 &font_style, &old_size);
142 142
143 if (old_size == size) 143 if (old_size == size)
144 return FontList(font_description_string_); 144 return FontList(font_description_string_);
145 145
146 return FontList(BuildFontDescription(font_names, font_style, size)); 146 return FontList(BuildFontDescription(font_names, font_style, size));
147 } 147 }
148 148
149 int FontList::GetHeight() const {
150 int ascent = 0;
151 int descent = 0;
152
153 const std::vector<Font>& fonts = GetFonts();
154 for (std::vector<Font>::const_iterator i = fonts.begin();
155 i != fonts.end(); ++i) {
156 ascent = std::max(ascent, i->GetBaseline());
157 descent = std::max(descent, i->GetHeight() - i->GetBaseline());
158 }
159 return ascent + descent;
msw 2013/07/11 22:47:29 Does this meaningfully differ from max(i->GetHeigh
Yuki 2013/07/12 08:25:53 I supposed there could be two fonts. Spec of Fon
msw 2013/07/12 09:36:04 Perfect example and explanation, thanks! But text
Yuki 2013/07/12 10:29:24 I'm optimistic for that case. Most of Latin fonts
msw 2013/07/12 10:41:58 sgtm, we can just followup if any actual defects a
160 }
161
162 int FontList::GetBaseline() const {
163 int baseline = 0;
164
msw 2013/07/11 22:47:29 nit: remove blank line.
Yuki 2013/07/12 08:25:53 Done.
165 const std::vector<Font>& fonts = GetFonts();
166 for (std::vector<Font>::const_iterator i = fonts.begin();
167 i != fonts.end(); ++i) {
168 baseline = std::max(baseline, i->GetBaseline());
169 }
170 return baseline;
171 }
172
149 int FontList::GetFontStyle() const { 173 int FontList::GetFontStyle() const {
150 if (!fonts_.empty()) 174 if (!fonts_.empty())
151 return fonts_[0].GetStyle(); 175 return fonts_[0].GetStyle();
152 176
153 std::vector<std::string> font_names; 177 std::vector<std::string> font_names;
154 int font_style; 178 int font_style;
155 int font_size; 179 int font_size;
156 ParseFontDescriptionString(font_description_string_, &font_names, 180 ParseFontDescriptionString(font_description_string_, &font_names,
157 &font_style, &font_size); 181 &font_style, &font_size);
158 return font_style; 182 return font_style;
(...skipping 30 matching lines...) Expand all
189 if (font_style == Font::NORMAL) 213 if (font_style == Font::NORMAL)
190 fonts_.push_back(font); 214 fonts_.push_back(font);
191 else 215 else
192 fonts_.push_back(font.DeriveFont(0, font_style)); 216 fonts_.push_back(font.DeriveFont(0, font_style));
193 } 217 }
194 } 218 }
195 return fonts_; 219 return fonts_;
196 } 220 }
197 221
198 } // namespace gfx 222 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_list.h ('k') | ui/gfx/font_list_unittest.cc » ('j') | ui/gfx/render_text.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698