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

Unified Diff: ui/gfx/font_render_params_linux.cc

Issue 403923002: Make GetCustomFontRenderParams() pass font style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove an extra assignment Created 6 years, 5 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
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 c33e988911e98a4082ebe8896663544a6050d23a..db240b0914581a4abeb79fdfa381c742b0ad6d0e 100644
--- a/ui/gfx/font_render_params_linux.cc
+++ b/ui/gfx/font_render_params_linux.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/logging.h"
+#include "ui/gfx/font.h"
#include "ui/gfx/linux_font_delegate.h"
#include "ui/gfx/switches.h"
@@ -42,6 +43,7 @@ FontRenderParams::SubpixelRendering ConvertFontconfigRgba(int rgba) {
bool QueryFontconfig(const std::vector<std::string>* family_list,
const int* pixel_size,
const int* point_size,
+ const int* style,
FontRenderParams* params_out,
std::string* family_out) {
FcPattern* pattern = FcPatternCreate();
@@ -58,6 +60,12 @@ bool QueryFontconfig(const std::vector<std::string>* family_list,
FcPatternAddDouble(pattern, FC_PIXEL_SIZE, *pixel_size);
if (point_size)
FcPatternAddInteger(pattern, FC_SIZE, *point_size);
+ if (style) {
+ FcPatternAddInteger(pattern, FC_SLANT,
+ (*style & Font::ITALIC) ? FC_SLANT_ITALIC : FC_SLANT_ROMAN);
+ FcPatternAddInteger(pattern, FC_WEIGHT,
+ (*style & Font::BOLD) ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL);
+ }
FcConfigSubstitute(NULL, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
@@ -101,7 +109,8 @@ bool QueryFontconfig(const std::vector<std::string>* family_list,
// Initializes |params| with the system's default settings.
void LoadDefaults(FontRenderParams* params, bool for_web_contents) {
- *params = GetCustomFontRenderParams(for_web_contents, NULL, NULL, NULL, NULL);
+ *params = GetCustomFontRenderParams(
+ for_web_contents, NULL, NULL, NULL, NULL, NULL);
}
} // namespace
@@ -129,6 +138,7 @@ FontRenderParams GetCustomFontRenderParams(
const std::vector<std::string>* family_list,
const int* pixel_size,
const int* point_size,
+ const int* style,
std::string* family_out) {
if (family_out)
family_out->clear();
@@ -138,7 +148,8 @@ FontRenderParams GetCustomFontRenderParams(
const LinuxFontDelegate* delegate = LinuxFontDelegate::instance();
if (delegate)
params = delegate->GetDefaultFontRenderParams();
- QueryFontconfig(family_list, pixel_size, point_size, &params, family_out);
+ QueryFontconfig(
+ family_list, pixel_size, point_size, style, &params, family_out);
// Fontconfig doesn't support configuring subpixel positioning; check a flag.
params.subpixel_positioning = CommandLine::ForCurrentProcess()->HasSwitch(

Powered by Google App Engine
This is Rietveld 408576698