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

Unified Diff: chrome/browser/ui/webui/options/font_settings_handler.cc

Issue 2441343003: Allow the default generic font family settings to find the first available font (Closed)
Patch Set: msw review Created 4 years, 2 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/browser/ui/BUILD.gn ('k') | chrome/browser/ui/webui/options/font_settings_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options/font_settings_handler.cc
diff --git a/chrome/browser/ui/webui/options/font_settings_handler.cc b/chrome/browser/ui/webui/options/font_settings_handler.cc
index c044ea3ff10df70c0e8511dfa0b4be99ba7e5fab..a9e028e4b671be11d5ae7921da2be282b49f1fdc 100644
--- a/chrome/browser/ui/webui/options/font_settings_handler.cc
+++ b/chrome/browser/ui/webui/options/font_settings_handler.cc
@@ -38,26 +38,8 @@
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
-#if defined(OS_WIN)
-#include "ui/gfx/font.h"
-#include "ui/gfx/platform_font_win.h"
-#endif
-
namespace {
-// Returns the localized name of a font so that settings can find it within the
-// list of system fonts. On Windows, the list of system fonts has names only
-// for the system locale, but the pref value may be in the English name.
-std::string MaybeGetLocalizedFontName(const std::string& font_name) {
-#if defined(OS_WIN)
- gfx::Font font(font_name, 12); // dummy font size
- return static_cast<gfx::PlatformFontWin*>(font.platform_font())->
- GetLocalizedFontName();
-#else
- return font_name;
-#endif
-}
-
const char kAdvancedFontSettingsExtensionId[] =
"caclkomlalccbpcdllchkeecicepbmbm";
@@ -210,42 +192,46 @@ void FontSettingsHandler::FontsListHasLoaded(
}
base::ListValue selected_values;
+ selected_values.AppendString(FontSettingsUtilities::MaybeGetLocalizedFontName(
+ standard_font_.GetValue()));
selected_values.AppendString(
- MaybeGetLocalizedFontName(standard_font_.GetValue()));
- selected_values.AppendString(
- MaybeGetLocalizedFontName(serif_font_.GetValue()));
- selected_values.AppendString(
- MaybeGetLocalizedFontName(sans_serif_font_.GetValue()));
+ FontSettingsUtilities::MaybeGetLocalizedFontName(serif_font_.GetValue()));
+ selected_values.AppendString(FontSettingsUtilities::MaybeGetLocalizedFontName(
+ sans_serif_font_.GetValue()));
selected_values.AppendString(
- MaybeGetLocalizedFontName(fixed_font_.GetValue()));
+ FontSettingsUtilities::MaybeGetLocalizedFontName(fixed_font_.GetValue()));
web_ui()->CallJavascriptFunctionUnsafe(
"FontSettings.setFontsData", *list.get(), selected_values);
}
void FontSettingsHandler::SetUpStandardFontSample() {
- base::StringValue font_value(standard_font_.GetValue());
+ base::StringValue font_value(
+ FontSettingsUtilities::ResolveFontList(standard_font_.GetValue()));
base::FundamentalValue size_value(default_font_size_.GetValue());
web_ui()->CallJavascriptFunctionUnsafe("FontSettings.setUpStandardFontSample",
font_value, size_value);
}
void FontSettingsHandler::SetUpSerifFontSample() {
- base::StringValue font_value(serif_font_.GetValue());
+ base::StringValue font_value(
+ FontSettingsUtilities::ResolveFontList(serif_font_.GetValue()));
base::FundamentalValue size_value(default_font_size_.GetValue());
web_ui()->CallJavascriptFunctionUnsafe("FontSettings.setUpSerifFontSample",
font_value, size_value);
}
void FontSettingsHandler::SetUpSansSerifFontSample() {
- base::StringValue font_value(sans_serif_font_.GetValue());
+ base::StringValue font_value(
+ FontSettingsUtilities::ResolveFontList(sans_serif_font_.GetValue()));
base::FundamentalValue size_value(default_font_size_.GetValue());
web_ui()->CallJavascriptFunctionUnsafe(
"FontSettings.setUpSansSerifFontSample", font_value, size_value);
}
void FontSettingsHandler::SetUpFixedFontSample() {
- base::StringValue font_value(fixed_font_.GetValue());
+ base::StringValue font_value(
+ FontSettingsUtilities::ResolveFontList(fixed_font_.GetValue()));
base::FundamentalValue size_value(default_fixed_font_size_.GetValue());
web_ui()->CallJavascriptFunctionUnsafe("FontSettings.setUpFixedFontSample",
font_value, size_value);
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/webui/options/font_settings_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698