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

Side by Side Diff: app/l10n_util_win.cc

Issue 113916: Make the UI font honor the OS settings when the resource bundle is not available. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 | « no previous file | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/l10n_util.h" 5 #include "app/l10n_util.h"
6 #include "app/l10n_util_win.h" 6 #include "app/l10n_util_win.h"
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <windowsx.h> 9 #include <windowsx.h>
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // we need separate ui font specifications. 80 // we need separate ui font specifications.
81 int ui_font_family_id = IDS_UI_FONT_FAMILY; 81 int ui_font_family_id = IDS_UI_FONT_FAMILY;
82 int ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER; 82 int ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER;
83 if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { 83 if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) {
84 ui_font_family_id = IDS_UI_FONT_FAMILY_XP; 84 ui_font_family_id = IDS_UI_FONT_FAMILY_XP;
85 ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER_XP; 85 ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER_XP;
86 } 86 }
87 87
88 std::wstring ui_font_family = GetString(ui_font_family_id); 88 std::wstring ui_font_family = GetString(ui_font_family_id);
89 int scaler100 = StringToInt(l10n_util::GetString(ui_font_size_scaler_id)); 89 int scaler100 = StringToInt(l10n_util::GetString(ui_font_size_scaler_id));
90 if (ui_font_family == L"default" && scaler100 == 100) 90 // We use the OS default in two cases:
91 // 1) The resource bundle has 'default' and '100' for font family and
92 // font scaler.
93 // 2) The resource bundle is not available for some reason and
94 // ui_font_family is empty.
95 if (ui_font_family == L"default" && scaler100 == 100 ||
96 ui_font_family.empty())
91 return false; 97 return false;
92 if (override_font_family && font_size_scaler) { 98 if (override_font_family && font_size_scaler) {
93 override_font_family->swap(ui_font_family); 99 override_font_family->swap(ui_font_family);
94 *font_size_scaler = scaler100 / 100.0; 100 *font_size_scaler = scaler100 / 100.0;
95 } 101 }
96 return true; 102 return true;
97 } 103 }
98 104
99 void AdjustUIFont(LOGFONT* logfont) { 105 void AdjustUIFont(LOGFONT* logfont) {
100 std::wstring ui_font_family; 106 std::wstring ui_font_family;
(...skipping 10 matching lines...) Expand all
111 if (GetObject(GetWindowFont(hwnd), sizeof(logfont), &logfont)) { 117 if (GetObject(GetWindowFont(hwnd), sizeof(logfont), &logfont)) {
112 AdjustLogFont(ui_font_family, ui_font_size_scaler, &logfont); 118 AdjustLogFont(ui_font_family, ui_font_size_scaler, &logfont);
113 HFONT hfont = CreateFontIndirect(&logfont); 119 HFONT hfont = CreateFontIndirect(&logfont);
114 if (hfont) 120 if (hfont)
115 SetWindowFont(hwnd, hfont, FALSE); 121 SetWindowFont(hwnd, hfont, FALSE);
116 } 122 }
117 } 123 }
118 } 124 }
119 125
120 } // namespace l10n_util 126 } // namespace l10n_util
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698