OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <windowsx.h> | 8 #include <windowsx.h> |
9 | 9 |
10 #include "app/l10n_util_win.h" | 10 #include "app/l10n_util_win.h" |
11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
12 #include "base/string_util.h" | 12 #include "base/string_number_conversions.h" |
| 13 //#include "base/string_util.h" |
13 #include "base/win_util.h" | 14 #include "base/win_util.h" |
14 | 15 |
15 #include "grit/app_locale_settings.h" | 16 #include "grit/app_locale_settings.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 void AdjustLogFont(const std::wstring& font_family, | 20 void AdjustLogFont(const std::wstring& font_family, |
20 double font_size_scaler, | 21 double font_size_scaler, |
21 LOGFONT* logfont) { | 22 LOGFONT* logfont) { |
22 DCHECK(font_size_scaler > 0); | 23 DCHECK(font_size_scaler > 0); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // XP and Vista or later have different font size issues and | 101 // XP and Vista or later have different font size issues and |
101 // we need separate ui font specifications. | 102 // we need separate ui font specifications. |
102 int ui_font_family_id = IDS_UI_FONT_FAMILY; | 103 int ui_font_family_id = IDS_UI_FONT_FAMILY; |
103 int ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER; | 104 int ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER; |
104 if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { | 105 if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { |
105 ui_font_family_id = IDS_UI_FONT_FAMILY_XP; | 106 ui_font_family_id = IDS_UI_FONT_FAMILY_XP; |
106 ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER_XP; | 107 ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER_XP; |
107 } | 108 } |
108 | 109 |
109 std::wstring ui_font_family = GetString(ui_font_family_id); | 110 std::wstring ui_font_family = GetString(ui_font_family_id); |
110 int scaler100 = StringToInt(l10n_util::GetString(ui_font_size_scaler_id)); | 111 int scaler100; |
| 112 if (!base::StringToInt(l10n_util::GetString(ui_font_size_scaler_id), |
| 113 &scaler100)) |
| 114 return false; |
| 115 |
111 // We use the OS default in two cases: | 116 // We use the OS default in two cases: |
112 // 1) The resource bundle has 'default' and '100' for font family and | 117 // 1) The resource bundle has 'default' and '100' for font family and |
113 // font scaler. | 118 // font scaler. |
114 // 2) The resource bundle is not available for some reason and | 119 // 2) The resource bundle is not available for some reason and |
115 // ui_font_family is empty. | 120 // ui_font_family is empty. |
116 if (ui_font_family == L"default" && scaler100 == 100 || | 121 if (ui_font_family == L"default" && scaler100 == 100 || |
117 ui_font_family.empty()) | 122 ui_font_family.empty()) |
118 return false; | 123 return false; |
119 if (override_font_family && font_size_scaler) { | 124 if (override_font_family && font_size_scaler) { |
120 override_font_family->swap(ui_font_family); | 125 override_font_family->swap(ui_font_family); |
(...skipping 17 matching lines...) Expand all Loading... |
138 if (GetObject(GetWindowFont(hwnd), sizeof(logfont), &logfont)) { | 143 if (GetObject(GetWindowFont(hwnd), sizeof(logfont), &logfont)) { |
139 AdjustLogFont(ui_font_family, ui_font_size_scaler, &logfont); | 144 AdjustLogFont(ui_font_family, ui_font_size_scaler, &logfont); |
140 HFONT hfont = CreateFontIndirect(&logfont); | 145 HFONT hfont = CreateFontIndirect(&logfont); |
141 if (hfont) | 146 if (hfont) |
142 SetWindowFont(hwnd, hfont, FALSE); | 147 SetWindowFont(hwnd, hfont, FALSE); |
143 } | 148 } |
144 } | 149 } |
145 } | 150 } |
146 | 151 |
147 } // namespace l10n_util | 152 } // namespace l10n_util |
OLD | NEW |