| OLD | NEW |
| 1 // Copyright (c) 2010 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_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 //#include "base/string_util.h" | 13 #include "base/win/windows_version.h" |
| 14 #include "base/win_util.h" | |
| 15 | |
| 16 #include "grit/app_locale_settings.h" | 14 #include "grit/app_locale_settings.h" |
| 17 | 15 |
| 18 namespace { | 16 namespace { |
| 19 | 17 |
| 20 void AdjustLogFont(const std::wstring& font_family, | 18 void AdjustLogFont(const std::wstring& font_family, |
| 21 double font_size_scaler, | 19 double font_size_scaler, |
| 22 LOGFONT* logfont) { | 20 LOGFONT* logfont) { |
| 23 DCHECK(font_size_scaler > 0); | 21 DCHECK(font_size_scaler > 0); |
| 24 font_size_scaler = std::max(std::min(font_size_scaler, 2.0), 0.7); | 22 font_size_scaler = std::max(std::min(font_size_scaler, 2.0), 0.7); |
| 25 logfont->lfHeight = static_cast<long>(font_size_scaler * | 23 logfont->lfHeight = static_cast<long>(font_size_scaler * |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // the entire window rect. | 77 // the entire window rect. |
| 80 ::InvalidateRect(hwnd, NULL, true); | 78 ::InvalidateRect(hwnd, NULL, true); |
| 81 } | 79 } |
| 82 } | 80 } |
| 83 | 81 |
| 84 bool IsLocaleSupportedByOS(const std::string& locale) { | 82 bool IsLocaleSupportedByOS(const std::string& locale) { |
| 85 // Block Amharic on Windows XP unless 'Abyssinica SIL' font is present. | 83 // Block Amharic on Windows XP unless 'Abyssinica SIL' font is present. |
| 86 // On Win XP, no Ethiopic/Amahric font is availabel out of box. We hard-coded | 84 // On Win XP, no Ethiopic/Amahric font is availabel out of box. We hard-coded |
| 87 // 'Abyssinica SIL' in the resource bundle to use in the UI. Check | 85 // 'Abyssinica SIL' in the resource bundle to use in the UI. Check |
| 88 // for its presence to determine whether or not to support Amharic UI on XP. | 86 // for its presence to determine whether or not to support Amharic UI on XP. |
| 89 return (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA || | 87 return (base::win::GetVersion() >= base::win::VERSION_VISTA || |
| 90 !LowerCaseEqualsASCII(locale, "am") || IsFontPresent(L"Abyssinica SIL")); | 88 !LowerCaseEqualsASCII(locale, "am") || IsFontPresent(L"Abyssinica SIL")); |
| 91 } | 89 } |
| 92 | 90 |
| 93 bool NeedOverrideDefaultUIFont(std::wstring* override_font_family, | 91 bool NeedOverrideDefaultUIFont(std::wstring* override_font_family, |
| 94 double* font_size_scaler) { | 92 double* font_size_scaler) { |
| 95 // This is rather simple-minded to deal with the UI font size | 93 // This is rather simple-minded to deal with the UI font size |
| 96 // issue for some Indian locales (ml, bn, hi) for which | 94 // issue for some Indian locales (ml, bn, hi) for which |
| 97 // the default Windows fonts are too small to be legible. For those | 95 // the default Windows fonts are too small to be legible. For those |
| 98 // locales, IDS_UI_FONT_FAMILY is set to an actual font family to | 96 // locales, IDS_UI_FONT_FAMILY is set to an actual font family to |
| 99 // use while for other locales, it's set to 'default'. | 97 // use while for other locales, it's set to 'default'. |
| 100 | 98 |
| 101 // XP and Vista or later have different font size issues and | 99 // XP and Vista or later have different font size issues and |
| 102 // we need separate ui font specifications. | 100 // we need separate ui font specifications. |
| 103 int ui_font_family_id = IDS_UI_FONT_FAMILY; | 101 int ui_font_family_id = IDS_UI_FONT_FAMILY; |
| 104 int ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER; | 102 int ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER; |
| 105 if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { | 103 if (base::win::GetVersion() < base::win::VERSION_VISTA) { |
| 106 ui_font_family_id = IDS_UI_FONT_FAMILY_XP; | 104 ui_font_family_id = IDS_UI_FONT_FAMILY_XP; |
| 107 ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER_XP; | 105 ui_font_size_scaler_id = IDS_UI_FONT_SIZE_SCALER_XP; |
| 108 } | 106 } |
| 109 | 107 |
| 110 std::wstring ui_font_family = GetString(ui_font_family_id); | 108 std::wstring ui_font_family = GetString(ui_font_family_id); |
| 111 int scaler100; | 109 int scaler100; |
| 112 if (!base::StringToInt(l10n_util::GetString(ui_font_size_scaler_id), | 110 if (!base::StringToInt(l10n_util::GetString(ui_font_size_scaler_id), |
| 113 &scaler100)) | 111 &scaler100)) |
| 114 return false; | 112 return false; |
| 115 | 113 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 143 if (GetObject(GetWindowFont(hwnd), sizeof(logfont), &logfont)) { | 141 if (GetObject(GetWindowFont(hwnd), sizeof(logfont), &logfont)) { |
| 144 AdjustLogFont(ui_font_family, ui_font_size_scaler, &logfont); | 142 AdjustLogFont(ui_font_family, ui_font_size_scaler, &logfont); |
| 145 HFONT hfont = CreateFontIndirect(&logfont); | 143 HFONT hfont = CreateFontIndirect(&logfont); |
| 146 if (hfont) | 144 if (hfont) |
| 147 SetWindowFont(hwnd, hfont, FALSE); | 145 SetWindowFont(hwnd, hfont, FALSE); |
| 148 } | 146 } |
| 149 } | 147 } |
| 150 } | 148 } |
| 151 | 149 |
| 152 } // namespace l10n_util | 150 } // namespace l10n_util |
| OLD | NEW |