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

Side by Side Diff: chrome/common/gfx/chrome_font_win.cc

Issue 62064: UI font localization part 2 (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 | « chrome/browser/views/tabs/tab_renderer.cc ('k') | chrome/common/l10n_util_win.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/common/gfx/chrome_font.h" 5 #include "chrome/common/gfx/chrome_font.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <math.h> 8 #include <math.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/win_util.h" 13 #include "base/win_util.h"
14 #include "chrome/common/l10n_util.h" 14 #include "chrome/common/l10n_util_win.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 #include "grit/locale_settings.h" 16 #include "grit/locale_settings.h"
17 17
18 /*static*/ 18 /*static*/
19 ChromeFont::HFontRef* ChromeFont::base_font_ref_; 19 ChromeFont::HFontRef* ChromeFont::base_font_ref_;
20 20
21 // If the tmWeight field of a TEXTMETRIC structure has a value >= this, the 21 // If the tmWeight field of a TEXTMETRIC structure has a value >= this, the
22 // font is bold. 22 // font is bold.
23 static const int kTextMetricWeightBold = 700; 23 static const int kTextMetricWeightBold = 700;
24 24
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 font_name.c_str()); 71 font_name.c_str());
72 return ChromeFont::CreateFont(hf); 72 return ChromeFont::CreateFont(hf);
73 } 73 }
74 74
75 // static 75 // static
76 ChromeFont::HFontRef* ChromeFont::GetBaseFontRef() { 76 ChromeFont::HFontRef* ChromeFont::GetBaseFontRef() {
77 if (base_font_ref_ == NULL) { 77 if (base_font_ref_ == NULL) {
78 NONCLIENTMETRICS metrics; 78 NONCLIENTMETRICS metrics;
79 win_util::GetNonClientMetrics(&metrics); 79 win_util::GetNonClientMetrics(&metrics);
80 80
81 l10n_util::AdjustUIFont(&metrics.lfMessageFont);
82
81 // See comment in ChromeFont::DeriveFont() about font size. 83 // See comment in ChromeFont::DeriveFont() about font size.
84 // TODO(jungshik): Add a per-locale resource entry for the minimum
85 // font size and actually enforce the lower-bound. 5 is way too small
86 // for CJK, Thai, and Indian locales.
82 DCHECK_GE(abs(metrics.lfMessageFont.lfHeight), 5); 87 DCHECK_GE(abs(metrics.lfMessageFont.lfHeight), 5);
83 HFONT font = CreateFontIndirect(&metrics.lfMessageFont); 88 HFONT font = CreateFontIndirect(&metrics.lfMessageFont);
84 DLOG_ASSERT(font); 89 DLOG_ASSERT(font);
85 base_font_ref_ = ChromeFont::CreateHFontRef(font); 90 base_font_ref_ = ChromeFont::CreateHFontRef(font);
86 // base_font_ref_ is global, up the ref count so it's never deleted. 91 // base_font_ref_ is global, up the ref count so it's never deleted.
87 base_font_ref_->AddRef(); 92 base_font_ref_->AddRef();
88 } 93 }
89 return base_font_ref_; 94 return base_font_ref_;
90 } 95 }
91 96
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 if (font_metrics.tmUnderlined) { 202 if (font_metrics.tmUnderlined) {
198 style |= ChromeFont::UNDERLINED; 203 style |= ChromeFont::UNDERLINED;
199 } 204 }
200 if (font_metrics.tmWeight >= kTextMetricWeightBold) { 205 if (font_metrics.tmWeight >= kTextMetricWeightBold) {
201 style |= ChromeFont::BOLD; 206 style |= ChromeFont::BOLD;
202 } 207 }
203 208
204 return new HFontRef(font, height, baseline, ave_char_width, style, 209 return new HFontRef(font, height, baseline, ave_char_width, style,
205 dlu_base_x); 210 dlu_base_x);
206 } 211 }
OLDNEW
« no previous file with comments | « chrome/browser/views/tabs/tab_renderer.cc ('k') | chrome/common/l10n_util_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698