Chromium Code Reviews| 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..e37f469be9bb807dd02056654e7787a060f26ff4 100644 |
| --- a/ui/gfx/platform_font_pango.cc |
| +++ b/ui/gfx/platform_font_pango.cc |
| @@ -94,43 +94,42 @@ 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; |
| + query.style = gfx::Font::NORMAL; |
| // TODO(davemoore) What should we do about other weights? We currently only |
|
msw
2014/07/23 22:16:35
nit: one-liner "TODO(davemoore) Support weights ot
Daniel Erat
2014/07/23 22:47:18
Done.
|
| // support BOLD. |
| if (pango_font_description_get_weight(native_font) == PANGO_WEIGHT_BOLD) |
| - style |= gfx::Font::BOLD; |
| + 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); |
|
msw
2014/07/23 22:16:35
nit: maybe inline this below?
Daniel Erat
2014/07/23 22:47:18
seems scary since it updates |font_family|, which
msw
2014/07/23 22:54:31
Acknowledged.
|
| 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; |
|
msw
2014/07/23 22:16:35
Should this omit the style from the query if it's
Daniel Erat
2014/07/23 22:47:18
i think that requesting normal here is the right t
msw
2014/07/23 22:54:31
Acknowledged.
|
| + const FontRenderParams params = gfx::GetFontRenderParams(query, NULL); |
|
msw
2014/07/23 22:16:35
nit: maybe inline this below?
Daniel Erat
2014/07/23 22:47:18
Done.
|
| InitFromDetails(skia::RefPtr<SkTypeface>(), font_name, font_size_pixels, |
| - style, params); |
| + query.style, params); |
| } |
| double PlatformFontPango::underline_position() const { |
| @@ -171,9 +170,11 @@ 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; |
| + const FontRenderParams render_params = gfx::GetFontRenderParams(query, NULL); |
|
msw
2014/07/23 22:16:35
nit: maybe inline this below?
Daniel Erat
2014/07/23 22:47:18
Done.
|
| return Font(new PlatformFontPango(typeface, |
| new_family, |