OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/base/l10n/l10n_util_win.h" | 5 #include "ui/base/l10n/l10n_util_win.h" |
6 | 6 |
7 #include <windowsx.h> | 7 #include <windowsx.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <iterator> | 9 #include <iterator> |
10 | 10 |
11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/win/i18n.h" | 17 #include "base/win/i18n.h" |
18 #include "base/win/windows_version.h" | 18 #include "base/win/windows_version.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/display/win/dpi.h" |
20 #include "ui/gfx/display.h" | 21 #include "ui/gfx/display.h" |
21 #include "ui/gfx/win/dpi.h" | |
22 #include "ui/strings/grit/app_locale_settings.h" | 22 #include "ui/strings/grit/app_locale_settings.h" |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 void AdjustLogFont(const base::string16& font_family, | 26 void AdjustLogFont(const base::string16& font_family, |
27 double font_size_scaler, | 27 double font_size_scaler, |
28 double dpi_scale, | 28 double dpi_scale, |
29 LOGFONT* logfont) { | 29 LOGFONT* logfont) { |
30 DCHECK(font_size_scaler > 0); | 30 DCHECK(font_size_scaler > 0); |
31 font_size_scaler = std::max(std::min(font_size_scaler, 2.0), 0.7); | 31 font_size_scaler = std::max(std::min(font_size_scaler, 2.0), 0.7); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 ui_font_family.empty()) | 148 ui_font_family.empty()) |
149 return false; | 149 return false; |
150 if (override_font_family && font_size_scaler) { | 150 if (override_font_family && font_size_scaler) { |
151 override_font_family->swap(ui_font_family); | 151 override_font_family->swap(ui_font_family); |
152 *font_size_scaler = scaler100 / 100.0; | 152 *font_size_scaler = scaler100 / 100.0; |
153 } | 153 } |
154 return true; | 154 return true; |
155 } | 155 } |
156 | 156 |
157 void AdjustUIFont(LOGFONT* logfont) { | 157 void AdjustUIFont(LOGFONT* logfont) { |
158 float dpi_scale = gfx::GetDPIScale(); | 158 float dpi_scale = display::win::GetDPIScale(); |
159 if (gfx::Display::HasForceDeviceScaleFactor()) { | 159 if (gfx::Display::HasForceDeviceScaleFactor()) { |
160 // If the scale is forced, we don't need to adjust it here. | 160 // If the scale is forced, we don't need to adjust it here. |
161 dpi_scale = 1.0f; | 161 dpi_scale = 1.0f; |
162 } | 162 } |
163 AdjustUIFontForDIP(dpi_scale, logfont); | 163 AdjustUIFontForDIP(dpi_scale, logfont); |
164 } | 164 } |
165 | 165 |
166 void AdjustUIFontForDIP(float dpi_scale, LOGFONT* logfont) { | 166 void AdjustUIFontForDIP(float dpi_scale, LOGFONT* logfont) { |
167 base::string16 ui_font_family = L"default"; | 167 base::string16 ui_font_family = L"default"; |
168 double ui_font_size_scaler = 1; | 168 double ui_font_size_scaler = 1; |
(...skipping 29 matching lines...) Expand all Loading... |
198 } else { | 198 } else { |
199 NOTREACHED() << "Failed to determine the UI language for locale override."; | 199 NOTREACHED() << "Failed to determine the UI language for locale override."; |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 const std::vector<std::string>& GetLocaleOverrides() { | 203 const std::vector<std::string>& GetLocaleOverrides() { |
204 return override_locale_holder.Get().value(); | 204 return override_locale_holder.Get().value(); |
205 } | 205 } |
206 | 206 |
207 } // namespace l10n_util | 207 } // namespace l10n_util |
OLD | NEW |