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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/font_list.cc
diff --git a/ui/gfx/font_list.cc b/ui/gfx/font_list.cc
index 93bf73e834a0bd5bbeed9c2670e64aaeb7f86add..5a5d6c0205e6cb7c442c6b5d0d494fa6625e73d5 100644
--- a/ui/gfx/font_list.cc
+++ b/ui/gfx/font_list.cc
@@ -146,6 +146,30 @@ FontList FontList::DeriveFontListWithSize(int size) const {
return FontList(BuildFontDescription(font_names, font_style, size));
}
+int FontList::GetHeight() const {
+ int ascent = 0;
+ int descent = 0;
+
+ const std::vector<Font>& fonts = GetFonts();
+ for (std::vector<Font>::const_iterator i = fonts.begin();
+ i != fonts.end(); ++i) {
+ ascent = std::max(ascent, i->GetBaseline());
+ descent = std::max(descent, i->GetHeight() - i->GetBaseline());
+ }
+ 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
+}
+
+int FontList::GetBaseline() const {
+ int baseline = 0;
+
msw 2013/07/11 22:47:29 nit: remove blank line.
Yuki 2013/07/12 08:25:53 Done.
+ const std::vector<Font>& fonts = GetFonts();
+ for (std::vector<Font>::const_iterator i = fonts.begin();
+ i != fonts.end(); ++i) {
+ baseline = std::max(baseline, i->GetBaseline());
+ }
+ return baseline;
+}
+
int FontList::GetFontStyle() const {
if (!fonts_.empty())
return fonts_[0].GetStyle();
« 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