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

Unified Diff: chrome/browser/ui/tab_contents/tab_contents_wrapper.cc

Issue 7748014: Add default per-script CJK fonts on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang error Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/resources/locale_settings_win.grd ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
index 5a27fac8037ec28ccd15c6584945506c1dab3122..6aa7603b2be6b372ed086648212dcdebfdc7c084 100644
--- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
+++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
@@ -118,6 +118,89 @@ void RegisterFontFamilyMap(PrefService* prefs, const char* map_name) {
}
}
+struct PrefResource {
+ const char* pref_name;
+ int resource_id;
+};
+
+// Per-script font pref defaults. The prefs that have defaults vary by
+// platform, since not all platforms have fonts for all scripts for all generic
+// families.
+// TODO(falken): add proper defaults when possible for all
+// platforms/scripts/generic families.
+const PrefResource kPerScriptFontDefaults[] = {
+#if defined(OS_CHROMEOS)
+ { prefs::kWebKitStandardFontFamilyArabic, IDS_STANDARD_FONT_FAMILY_ARABIC },
+ { prefs::kWebKitSerifFontFamilyArabic, IDS_SERIF_FONT_FAMILY_ARABIC },
+ { prefs::kWebKitSansSerifFontFamilyArabic,
+ IDS_SANS_SERIF_FONT_FAMILY_ARABIC },
+ { prefs::kWebKitStandardFontFamilyJapanese,
+ IDS_STANDARD_FONT_FAMILY_JAPANESE },
+ { prefs::kWebKitFixedFontFamilyJapanese, IDS_FIXED_FONT_FAMILY_JAPANESE },
+ { prefs::kWebKitSerifFontFamilyJapanese, IDS_SERIF_FONT_FAMILY_JAPANESE },
+ { prefs::kWebKitSansSerifFontFamilyJapanese,
+ IDS_SANS_SERIF_FONT_FAMILY_JAPANESE },
+ { prefs::kWebKitStandardFontFamilyKorean, IDS_STANDARD_FONT_FAMILY_KOREAN },
+ { prefs::kWebKitFixedFontFamilyKorean, IDS_FIXED_FONT_FAMILY_KOREAN },
+ { prefs::kWebKitSerifFontFamilyKorean, IDS_SERIF_FONT_FAMILY_KOREAN },
+ { prefs::kWebKitSansSerifFontFamilyKorean,
+ IDS_SANS_SERIF_FONT_FAMILY_KOREAN },
+ { prefs::kWebKitStandardFontFamilySimplifiedHan,
+ IDS_STANDARD_FONT_FAMILY_SIMPLIFIED_HAN },
+ { prefs::kWebKitFixedFontFamilySimplifiedHan,
+ IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN },
+ { prefs::kWebKitSerifFontFamilySimplifiedHan,
+ IDS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN },
+ { prefs::kWebKitSansSerifFontFamilySimplifiedHan,
+ IDS_SANS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN },
+ { prefs::kWebKitStandardFontFamilyTraditionalHan,
+ IDS_STANDARD_FONT_FAMILY_TRADITIONAL_HAN },
+ { prefs::kWebKitFixedFontFamilyTraditionalHan,
+ IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN },
+ { prefs::kWebKitSerifFontFamilyTraditionalHan,
+ IDS_SERIF_FONT_FAMILY_TRADITIONAL_HAN },
+ { prefs::kWebKitSansSerifFontFamilyTraditionalHan,
+ IDS_SANS_SERIF_FONT_FAMILY_TRADITIONAL_HAN }
+#elif defined(OS_WIN)
+ { prefs::kWebKitStandardFontFamilyJapanese,
+ IDS_STANDARD_FONT_FAMILY_JAPANESE },
+ { prefs::kWebKitFixedFontFamilyJapanese, IDS_FIXED_FONT_FAMILY_JAPANESE },
+ { prefs::kWebKitSerifFontFamilyJapanese, IDS_SERIF_FONT_FAMILY_JAPANESE },
+ { prefs::kWebKitSansSerifFontFamilyJapanese,
+ IDS_SANS_SERIF_FONT_FAMILY_JAPANESE },
+ { prefs::kWebKitStandardFontFamilyKorean, IDS_STANDARD_FONT_FAMILY_KOREAN },
+ { prefs::kWebKitFixedFontFamilyKorean, IDS_FIXED_FONT_FAMILY_KOREAN },
+ { prefs::kWebKitSerifFontFamilyKorean, IDS_SERIF_FONT_FAMILY_KOREAN },
+ { prefs::kWebKitSansSerifFontFamilyKorean,
+ IDS_SANS_SERIF_FONT_FAMILY_KOREAN },
+ { prefs::kWebKitCursiveFontFamilyKorean, IDS_CURSIVE_FONT_FAMILY_KOREAN },
+ { prefs::kWebKitStandardFontFamilySimplifiedHan,
+ IDS_STANDARD_FONT_FAMILY_SIMPLIFIED_HAN },
+ { prefs::kWebKitFixedFontFamilySimplifiedHan,
+ IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN },
+ { prefs::kWebKitSerifFontFamilySimplifiedHan,
+ IDS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN },
+ { prefs::kWebKitSansSerifFontFamilySimplifiedHan,
+ IDS_SANS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN },
+ { prefs::kWebKitStandardFontFamilyTraditionalHan,
+ IDS_STANDARD_FONT_FAMILY_TRADITIONAL_HAN },
+ { prefs::kWebKitFixedFontFamilyTraditionalHan,
+ IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN },
+ { prefs::kWebKitSerifFontFamilyTraditionalHan,
+ IDS_SERIF_FONT_FAMILY_TRADITIONAL_HAN },
+ { prefs::kWebKitSansSerifFontFamilyTraditionalHan,
+ IDS_SANS_SERIF_FONT_FAMILY_TRADITIONAL_HAN }
+#endif
+};
+
+#if defined(OS_CHROMEOS) || defined(OS_WIN)
+// To avoid Clang warning, only define kPerScriptFontDefaultsLength when it is
+// non-zero. When it is zero, code like
+// for (size_t i = 0; i < kPerScriptFontDefaultsLength; ++i)
+// causes a warning due to comparison of unsigned expression < 0.
+const size_t kPerScriptFontDefaultsLength = arraysize(kPerScriptFontDefaults);
+#endif
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -301,58 +384,18 @@ void TabContentsWrapper::RegisterUserPrefs(PrefService* prefs) {
IDS_FANTASY_FONT_FAMILY,
PrefService::UNSYNCABLE_PREF);
- // Register per-script font prefs that have defaults. Currently defaults are
- // defined only for some scripts and only on Chrome OS to begin with (it is
- // the easiest since we readily know what fonts are available there).
- // TODO(falken): add defaults for all platforms and for scripts that should
- // have defaults.
-#if defined(OS_CHROMEOS)
- prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamilyArabic,
- IDS_STANDARD_FONT_FAMILY_ARABIC, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilyArabic,
- IDS_SERIF_FONT_FAMILY_ARABIC, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamilyArabic,
- IDS_SANS_SERIF_FONT_FAMILY_ARABIC, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamilyJapanese,
- IDS_STANDARD_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamilyJapanese,
- IDS_FIXED_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilyJapanese,
- IDS_SERIF_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamilyJapanese,
- IDS_SANS_SERIF_FONT_FAMILY_JAPANESE, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitStandardFontFamilyKorean,
- IDS_STANDARD_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamilyKorean,
- IDS_FIXED_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilyKorean,
- IDS_SERIF_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitSansSerifFontFamilyKorean,
- IDS_SANS_SERIF_FONT_FAMILY_KOREAN, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(
- prefs::kWebKitStandardFontFamilySimplifiedHan,
- IDS_STANDARD_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitFixedFontFamilySimplifiedHan,
- IDS_FIXED_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(prefs::kWebKitSerifFontFamilySimplifiedHan,
- IDS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(
- prefs::kWebKitSansSerifFontFamilySimplifiedHan,
- IDS_SANS_SERIF_FONT_FAMILY_SIMPLIFIED_HAN, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(
- prefs::kWebKitStandardFontFamilyTraditionalHan,
- IDS_STANDARD_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(
- prefs::kWebKitFixedFontFamilyTraditionalHan,
- IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(
- prefs::kWebKitSerifFontFamilyTraditionalHan,
- IDS_SERIF_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF);
- prefs->RegisterLocalizedStringPref(
- prefs::kWebKitSansSerifFontFamilyTraditionalHan,
- IDS_SANS_SERIF_FONT_FAMILY_TRADITIONAL_HAN, PrefService::UNSYNCABLE_PREF);
+ // Register per-script font prefs that have defaults.
+#if defined(OS_CHROMEOS) || defined(OS_WIN)
+ // As explained by its definition, kPerScriptFontDefaultsLength is only
+ // defined for platforms where it would be non-zero.
+ for (size_t i = 0; i < kPerScriptFontDefaultsLength; ++i) {
+ prefs->RegisterLocalizedStringPref(kPerScriptFontDefaults[i].pref_name,
+ kPerScriptFontDefaults[i].resource_id,
+ PrefService::UNSYNCABLE_PREF);
+ }
#endif
+ // Register the rest of the per-script font prefs.
RegisterFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap);
RegisterFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap);
RegisterFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap);
« no previous file with comments | « chrome/app/resources/locale_settings_win.grd ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698