Index: ui/gfx/font_render_params_linux.cc |
diff --git a/ui/gfx/font_render_params_linux.cc b/ui/gfx/font_render_params_linux.cc |
index bba66d43b5271806ab54c0b93e5b33552df5af90..e8e60e3e68ac7061e9ee5b4e4fc20c2eff196dab 100644 |
--- a/ui/gfx/font_render_params_linux.cc |
+++ b/ui/gfx/font_render_params_linux.cc |
@@ -38,12 +38,8 @@ FontRenderParams::SubpixelRendering ConvertFontconfigRgba(int rgba) { |
} |
// Queries Fontconfig for rendering settings and updates |params_out| and |
-// |family_out| (if non-NULL). Returns false on failure. See |
-// GetCustomFontRenderParams() for descriptions of arguments. |
-bool QueryFontconfig(const std::vector<std::string>* family_list, |
- const int* pixel_size, |
- const int* point_size, |
- const int* style, |
+// |family_out| (if non-NULL). Returns false on failure. |
+bool QueryFontconfig(const FontRenderParamsQuery& query, |
FontRenderParams* params_out, |
std::string* family_out) { |
FcPattern* pattern = FcPatternCreate(); |
@@ -51,22 +47,20 @@ bool QueryFontconfig(const std::vector<std::string>* family_list, |
FcPatternAddBool(pattern, FC_SCALABLE, FcTrue); |
- if (family_list) { |
- for (std::vector<std::string>::const_iterator it = family_list->begin(); |
- it != family_list->end(); ++it) { |
- FcPatternAddString( |
- pattern, FC_FAMILY, reinterpret_cast<const FcChar8*>(it->c_str())); |
- } |
+ for (std::vector<std::string>::const_iterator it = query.families.begin(); |
+ it != query.families.end(); ++it) { |
+ FcPatternAddString( |
+ pattern, FC_FAMILY, reinterpret_cast<const FcChar8*>(it->c_str())); |
} |
- if (pixel_size) |
- FcPatternAddDouble(pattern, FC_PIXEL_SIZE, *pixel_size); |
- if (point_size) |
- FcPatternAddInteger(pattern, FC_SIZE, *point_size); |
- if (style) { |
+ if (query.pixel_size > 0) |
+ FcPatternAddDouble(pattern, FC_PIXEL_SIZE, query.pixel_size); |
+ if (query.point_size > 0) |
+ FcPatternAddInteger(pattern, FC_SIZE, query.point_size); |
+ if (query.style >= 0) { |
FcPatternAddInteger(pattern, FC_SLANT, |
- (*style & Font::ITALIC) ? FC_SLANT_ITALIC : FC_SLANT_ROMAN); |
+ (query.style & Font::ITALIC) ? FC_SLANT_ITALIC : FC_SLANT_ROMAN); |
FcPatternAddInteger(pattern, FC_WEIGHT, |
- (*style & Font::BOLD) ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL); |
+ (query.style & Font::BOLD) ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL); |
} |
FcConfigSubstitute(NULL, pattern, FcMatchPattern); |
@@ -120,31 +114,10 @@ bool QueryFontconfig(const std::vector<std::string>* family_list, |
return true; |
} |
-// Returns the system's default settings. |
-FontRenderParams LoadDefaults(bool for_web_contents) { |
- return GetCustomFontRenderParams( |
- for_web_contents, NULL, NULL, NULL, NULL, NULL); |
-} |
- |
} // namespace |
-const FontRenderParams& GetDefaultFontRenderParams() { |
- static FontRenderParams default_params = LoadDefaults(false); |
- return default_params; |
-} |
- |
-const FontRenderParams& GetDefaultWebKitFontRenderParams() { |
- static FontRenderParams default_params = LoadDefaults(true); |
- return default_params; |
-} |
- |
-FontRenderParams GetCustomFontRenderParams( |
- bool for_web_contents, |
- const std::vector<std::string>* family_list, |
- const int* pixel_size, |
- const int* point_size, |
- const int* style, |
- std::string* family_out) { |
+FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query, |
+ std::string* family_out) { |
if (family_out) |
family_out->clear(); |
@@ -153,12 +126,11 @@ FontRenderParams GetCustomFontRenderParams( |
const LinuxFontDelegate* delegate = LinuxFontDelegate::instance(); |
if (delegate) |
params = delegate->GetDefaultFontRenderParams(); |
- QueryFontconfig( |
- family_list, pixel_size, point_size, style, ¶ms, family_out); |
+ QueryFontconfig(query, ¶ms, family_out); |
// Fontconfig doesn't support configuring subpixel positioning; check a flag. |
params.subpixel_positioning = CommandLine::ForCurrentProcess()->HasSwitch( |
- for_web_contents ? |
+ query.for_web_contents ? |
switches::kEnableWebkitTextSubpixelPositioning : |
switches::kEnableBrowserTextSubpixelPositioning); |
@@ -167,9 +139,8 @@ FontRenderParams GetCustomFontRenderParams( |
params.hinting = FontRenderParams::HINTING_NONE; |
// Use the first family from the list if Fontconfig didn't suggest a family. |
- if (family_out && family_out->empty() && |
- family_list && !family_list->empty()) |
- *family_out = (*family_list)[0]; |
+ if (family_out && family_out->empty() && !query.families.empty()) |
+ *family_out = query.families[0]; |
return params; |
} |