From 9f7af522830ec5c9ff7ad00a62a2a17485befcbd Mon Sep 17 00:00:00 2001 From: "jshin@chromium.org" Date: Tue, 20 Apr 2010 17:28:06 +0000 Subject: Enable Amharic (am) on Windows XP only if the font (Abyssinica SIL) is present. BUG=36752 TEST=On Windows XP, try run Chrome with '--lang=am' with and without 'Abyssinica SIL font installed. Without it, it should fall back to English UI. With it, it should be in Amharic UI. 'Abyssinica SIL' can be downloaded at http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=SILFontList Review URL: http://codereview.chromium.org/1575037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45047 0039d316-1c4b-4281-b951-d872f2087c98 --- app/l10n_util_win.cc | 27 ++++++++++++++++++++++++--- app/resources/app_locale_settings_am.xtb | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/l10n_util_win.cc b/app/l10n_util_win.cc index 670efaa..350c29a 100644 --- a/app/l10n_util_win.cc +++ b/app/l10n_util_win.cc @@ -35,6 +35,24 @@ void AdjustLogFont(const std::wstring& font_family, } } +bool IsFontPresent(const wchar_t* font_name) { + HFONT hfont = CreateFont(12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + font_name); + if (hfont == NULL) + return false; + HDC dc = GetDC(0); + HGDIOBJ oldFont = static_cast(SelectObject(dc, hfont)); + WCHAR actual_font_name[LF_FACESIZE]; + DWORD size_ret = GetTextFace(dc, LF_FACESIZE, actual_font_name); + actual_font_name[LF_FACESIZE - 1] = 0; + SelectObject(dc, oldFont); + DeleteObject(hfont); + ReleaseDC(0, dc); + // We don't have to worry about East Asian fonts with locale-dependent + // names here. + return wcscmp(font_name, actual_font_name) == 0; +} + } // namespace namespace l10n_util { @@ -63,9 +81,12 @@ void HWNDSetRTLLayout(HWND hwnd) { } bool IsLocaleSupportedByOS(const std::string& locale) { - // Block Amharic on Windows XP. - return win_util::GetWinVersion() >= win_util::WINVERSION_VISTA || - !LowerCaseEqualsASCII(locale, "am"); + // Block Amharic on Windows XP unless 'Abyssinica SIL' font is present. + // On Win XP, no Ethiopic/Amahric font is availabel out of box. We hard-coded + // 'Abyssinica SIL' in the resource bundle to use in the UI. Check + // for its presence to determine whether or not to support Amharic UI on XP. + return (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA || + !LowerCaseEqualsASCII(locale, "am") || IsFontPresent(L"Abyssinica SIL")); } bool NeedOverrideDefaultUIFont(std::wstring* override_font_family, diff --git a/app/resources/app_locale_settings_am.xtb b/app/resources/app_locale_settings_am.xtb index 4d08b65..5691f7e 100644 --- a/app/resources/app_locale_settings_am.xtb +++ b/app/resources/app_locale_settings_am.xtb @@ -1,7 +1,7 @@ -default +abyssinica sil default 100 100 -- cgit v1.1