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

Unified Diff: ui/gfx/platform_font_pango.cc

Issue 413003002: Add FontRenderParamsQuery. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update PlatformFontWin::GetFontRenderParams() to use a static 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
« no previous file with comments | « ui/gfx/font_render_params_win.cc ('k') | ui/gfx/platform_font_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/platform_font_pango.cc
diff --git a/ui/gfx/platform_font_pango.cc b/ui/gfx/platform_font_pango.cc
index 39f0bb8ff9bf6c6a8ac85f552a944b55d88d3798..403b8364bce918dfbf130e97de1b9ebd43b57039 100644
--- a/ui/gfx/platform_font_pango.cc
+++ b/ui/gfx/platform_font_pango.cc
@@ -94,43 +94,40 @@ PlatformFontPango::PlatformFontPango() {
}
PlatformFontPango::PlatformFontPango(NativeFont native_font) {
- std::string font_family;
- std::vector<std::string> family_names;
+ FontRenderParamsQuery query(false);
base::SplitString(pango_font_description_get_family(native_font), ',',
- &family_names);
+ &query.families);
const int pango_size =
pango_font_description_get_size(native_font) / PANGO_SCALE;
- const bool pango_using_pixels =
- pango_font_description_get_size_is_absolute(native_font);
+ if (pango_font_description_get_size_is_absolute(native_font))
+ query.pixel_size = pango_size;
+ else
+ query.point_size = pango_size;
- int style = 0;
- // TODO(davemoore) What should we do about other weights? We currently only
- // support BOLD.
+ query.style = gfx::Font::NORMAL;
+ // TODO(davemoore): Support weights other than bold?
if (pango_font_description_get_weight(native_font) == PANGO_WEIGHT_BOLD)
- style |= gfx::Font::BOLD;
- // TODO(davemoore) What about PANGO_STYLE_OBLIQUE?
+ query.style |= gfx::Font::BOLD;
+ // TODO(davemoore): What about PANGO_STYLE_OBLIQUE?
if (pango_font_description_get_style(native_font) == PANGO_STYLE_ITALIC)
- style |= gfx::Font::ITALIC;
-
- const FontRenderParams params = GetCustomFontRenderParams(
- false, &family_names,
- pango_using_pixels ? &pango_size : NULL /* pixel_size */,
- !pango_using_pixels ? &pango_size : NULL /* point_size */,
- &style, &font_family);
+ query.style |= gfx::Font::ITALIC;
+ std::string font_family;
+ const FontRenderParams params = gfx::GetFontRenderParams(query, &font_family);
InitFromDetails(skia::RefPtr<SkTypeface>(), font_family,
- gfx::GetPangoFontSizeInPixels(native_font), style, params);
+ gfx::GetPangoFontSizeInPixels(native_font),
+ query.style, params);
}
PlatformFontPango::PlatformFontPango(const std::string& font_name,
int font_size_pixels) {
- const std::vector<std::string> font_list(1, font_name);
- const int style = Font::NORMAL;
- const FontRenderParams params = GetCustomFontRenderParams(
- false, &font_list, &font_size_pixels, NULL, &style, NULL);
+ FontRenderParamsQuery query(false);
+ query.families.push_back(font_name);
+ query.pixel_size = font_size_pixels;
+ query.style = gfx::Font::NORMAL;
InitFromDetails(skia::RefPtr<SkTypeface>(), font_name, font_size_pixels,
- style, params);
+ query.style, gfx::GetFontRenderParams(query, NULL));
}
double PlatformFontPango::underline_position() const {
@@ -171,15 +168,13 @@ Font PlatformFontPango::DeriveFont(int size_delta, int style) const {
skia::RefPtr<SkTypeface> typeface =
(style == style_) ? typeface_ : CreateSkTypeface(style, &new_family);
- const std::vector<std::string> family_list(1, new_family);
- const FontRenderParams render_params = GetCustomFontRenderParams(
- false, &family_list, &new_size, NULL, &style, NULL);
+ FontRenderParamsQuery query(false);
+ query.families.push_back(new_family);
+ query.pixel_size = new_size;
+ query.style = style;
- return Font(new PlatformFontPango(typeface,
- new_family,
- new_size,
- style,
- render_params));
+ return Font(new PlatformFontPango(typeface, new_family, new_size, style,
+ gfx::GetFontRenderParams(query, NULL)));
}
int PlatformFontPango::GetHeight() const {
« no previous file with comments | « ui/gfx/font_render_params_win.cc ('k') | ui/gfx/platform_font_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698