summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-09 04:36:52 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-09 04:36:52 +0000
commitc9e1715cfd9e925ece5f94a5028d5bb302765281 (patch)
tree2ab152b05f25f7e7d985f7fd9ab6b9a571bef0c4
parentee70311954923a02bfeaa9e6a57e2614fef97464 (diff)
downloadchromium_src-c9e1715cfd9e925ece5f94a5028d5bb302765281.zip
chromium_src-c9e1715cfd9e925ece5f94a5028d5bb302765281.tar.gz
chromium_src-c9e1715cfd9e925ece5f94a5028d5bb302765281.tar.bz2
Change UI font at startup time if necessary, based on the UI locale.
As of writing, ChromeDroidSans is used as the UI font (see /etc/gtk-2.0/gtkrc). This setting does not work well for Japanese users as Chinese glyphs are used for Kanji characters. For Japanese UI, we should use a Japanese font. Introduce IDS_UI_FONT_FAMILY_CROS to control the UI font based on the UI locale. For now, app_locale_settings_ja.xtb only contains a non-default value: IPAPGothic. Just for the record, I originally tried to use "DroidSans Japanese" but for some reason, this caused space characters (0x20) to be garbled in the wrench menu. Hence, IPAPGotchic is chosen for now. TEST=manually on the netbook, and ubuntu BUG=chromium-os:4038 Review URL: http://codereview.chromium.org/3275008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58913 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/app.gyp3
-rw-r--r--app/resources/app_locale_settings.grd51
-rw-r--r--app/resources/app_locale_settings_ja.xtb1
-rw-r--r--chrome/browser/browser_main.cc18
-rw-r--r--chrome/browser/gtk/gtk_util.cc5
-rw-r--r--chrome/browser/gtk/gtk_util.h3
-rwxr-xr-xchrome/tools/build/repack_locales.py4
7 files changed, 64 insertions, 21 deletions
diff --git a/app/app.gyp b/app/app.gyp
index 4b1fde4..2c8e7f7 100644
--- a/app/app.gyp
+++ b/app/app.gyp
@@ -112,6 +112,9 @@
['use_titlecase_in_grd_files==1', {
'action': ['-D', 'use_titlecase'],
}],
+ ['chromeos==1', {
+ 'action': ['-D', 'chromeos'],
+ }],
],
},
],
diff --git a/app/resources/app_locale_settings.grd b/app/resources/app_locale_settings.grd
index cf799c3..9b900cd 100644
--- a/app/resources/app_locale_settings.grd
+++ b/app/resources/app_locale_settings.grd
@@ -176,29 +176,38 @@
Linux fonts do not have the issue Windows fonts for some locales
(Indian) have. In that case, this need to be enclosed
by platform-dependent if-clause. -->
- <message name="IDS_UI_FONT_FAMILY" use_name_for_id="true">
- default
- </message>
- <!-- For Windows XP -->
- <message name="IDS_UI_FONT_FAMILY_XP" use_name_for_id="true">
- default
- </message>
+ <if expr="os == 'win32'">
+ <message name="IDS_UI_FONT_FAMILY" use_name_for_id="true">
+ default
+ </message>
+ <!-- For Windows XP -->
+ <message name="IDS_UI_FONT_FAMILY_XP" use_name_for_id="true">
+ default
+ </message>
- <!-- To get the actual UI font size for native UI components
- (e.g. menu), the system UI font size is scaled with this value/100.
- This should be 100 for most locales. -->
- <message name="IDS_UI_FONT_SIZE_SCALER" use_name_for_id="true">
- 100
- </message>
- <!-- For Windows XP -->
- <message name="IDS_UI_FONT_SIZE_SCALER_XP" use_name_for_id="true">
- 100
- </message>
+ <!-- To get the actual UI font size for native UI components
+ (e.g. menu), the system UI font size is scaled with this value/100.
+ This should be 100 for most locales. -->
+ <message name="IDS_UI_FONT_SIZE_SCALER" use_name_for_id="true">
+ 100
+ </message>
+ <!-- For Windows XP -->
+ <message name="IDS_UI_FONT_SIZE_SCALER_XP" use_name_for_id="true">
+ 100
+ </message>
- <!-- Limit minimum UI font size to 5 by default. -->
- <message name="IDS_MINIMUM_UI_FONT_SIZE" use_name_for_id="true">
- 5
- </message>
+ <!-- Limit minimum UI font size to 5 by default. -->
+ <message name="IDS_MINIMUM_UI_FONT_SIZE" use_name_for_id="true">
+ 5
+ </message>
+ </if>
+ <!-- For Chrome OS -->
+ <if expr="pp_ifdef('chromeos')">
+ <!-- The font name like: 'Font Name, 10' -->
+ <message name="IDS_UI_FONT_FAMILY_CROS" use_name_for_id="true">
+ default
+ </message>
+ </if>
</messages>
</release>
</grit>
diff --git a/app/resources/app_locale_settings_ja.xtb b/app/resources/app_locale_settings_ja.xtb
index 3a31fb1..933d47d 100644
--- a/app/resources/app_locale_settings_ja.xtb
+++ b/app/resources/app_locale_settings_ja.xtb
@@ -2,4 +2,5 @@
<!DOCTYPE translationbundle>
<translationbundle lang="ja">
<translation id="IDS_MINIMUM_UI_FONT_SIZE">10</translation>
+<translation id="IDS_UI_FONT_FAMILY_CROS">IPAPGothic, 10</translation>
</translationbundle>
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 3915e8b..46d3b0c 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -723,6 +723,21 @@ int GetMinimumFontSize() {
return min_font_size;
}
+#elif defined(OS_CHROMEOS)
+// Changes the UI font if non-default font name is specified in
+// IDS_UI_FONT_FAMILY_CROS. This is necessary as the default font
+// specified in /etc/gtk-2.0/gtrkc may not work well for some languages
+// For instance, ChromeDroidSans does not work well for Japanese users,
+// since Chinese glyphs are used for Kanji characters.
+void MaybeChangeUIFont() {
+ const std::string font_name =
+ l10n_util::GetStringUTF8(IDS_UI_FONT_FAMILY_CROS);
+ // The font name should not be empty here, but just in case.
+ if (font_name == "default" || font_name.empty()) {
+ return;
+ }
+ gtk_util::SetGtkFont(font_name);
+}
#endif
#if defined(TOOLKIT_GTK)
@@ -1072,6 +1087,9 @@ int BrowserMain(const MainFunctionParams& parameters) {
#if defined(OS_CHROMEOS)
// Now that the file thread exists we can record our stats.
chromeos::BootTimesLoader::Get()->RecordChromeMainStats();
+ // Change the UI font if necessary. This has to be done after
+ // InitSharedInstance() is called, as it depends on resource data.
+ MaybeChangeUIFont();
#endif
// Record last shutdown time into a histogram.
diff --git a/chrome/browser/gtk/gtk_util.cc b/chrome/browser/gtk/gtk_util.cc
index 541d2da..9c6bf14 100644
--- a/chrome/browser/gtk/gtk_util.cc
+++ b/chrome/browser/gtk/gtk_util.cc
@@ -1066,4 +1066,9 @@ bool IsWidgetAncestryVisible(GtkWidget* widget) {
return !parent;
}
+void SetGtkFont(const std::string& font_name) {
+ g_object_set(gtk_settings_get_default(),
+ "gtk-font-name", font_name.c_str(), NULL);
+}
+
} // namespace gtk_util
diff --git a/chrome/browser/gtk/gtk_util.h b/chrome/browser/gtk/gtk_util.h
index 95200d4..efc7086 100644
--- a/chrome/browser/gtk/gtk_util.h
+++ b/chrome/browser/gtk/gtk_util.h
@@ -319,6 +319,9 @@ string16 GetStockPreferencesMenuLabel();
// ancestors up to its toplevel are visible.
bool IsWidgetAncestryVisible(GtkWidget* widget);
+// Sets the GTK font from the given font name (ex. "Arial Black, 10").
+void SetGtkFont(const std::string& font_name);
+
} // namespace gtk_util
#endif // CHROME_BROWSER_GTK_GTK_UTIL_H_
diff --git a/chrome/tools/build/repack_locales.py b/chrome/tools/build/repack_locales.py
index c74a23c..ffb99fb 100755
--- a/chrome/tools/build/repack_locales.py
+++ b/chrome/tools/build/repack_locales.py
@@ -66,6 +66,10 @@ def calc_inputs(locale):
inputs.append('%s/app/app_strings/app_strings_%s.pak' % (
SHARE_INT_DIR, locale))
+ #e.g. '<(SHARED_INTERMEDIATE_DIR)/app/app_locale_settings_da.pak',
+ inputs.append('%s/app/app_locale_settings/app_locale_settings_%s.pak' % (
+ SHARE_INT_DIR, locale))
+
#e.g. '<(grit_out_dir)/google_chrome_strings_da.pak'
# or
# '<(grit_out_dir)/chromium_strings_da.pak'