OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/platform_font_pango.h" | 5 #include "ui/gfx/platform_font_pango.h" |
6 | 6 |
7 #include <pango/pango.h> | 7 #include <pango/pango.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 query.style = gfx::Font::NORMAL; | 107 query.style = gfx::Font::NORMAL; |
108 // TODO(davemoore): Support weights other than bold? | 108 // TODO(davemoore): Support weights other than bold? |
109 if (pango_font_description_get_weight(native_font) == PANGO_WEIGHT_BOLD) | 109 if (pango_font_description_get_weight(native_font) == PANGO_WEIGHT_BOLD) |
110 query.style |= gfx::Font::BOLD; | 110 query.style |= gfx::Font::BOLD; |
111 // TODO(davemoore): What about PANGO_STYLE_OBLIQUE? | 111 // TODO(davemoore): What about PANGO_STYLE_OBLIQUE? |
112 if (pango_font_description_get_style(native_font) == PANGO_STYLE_ITALIC) | 112 if (pango_font_description_get_style(native_font) == PANGO_STYLE_ITALIC) |
113 query.style |= gfx::Font::ITALIC; | 113 query.style |= gfx::Font::ITALIC; |
114 | 114 |
115 std::string font_family; | 115 std::string font_family; |
116 const FontRenderParams params = gfx::GetFontRenderParams(query, &font_family); | 116 const FontRenderParams params = |
| 117 gfx::GetSystemFontRenderParams(query, &font_family); |
117 InitFromDetails(skia::RefPtr<SkTypeface>(), font_family, | 118 InitFromDetails(skia::RefPtr<SkTypeface>(), font_family, |
118 gfx::GetPangoFontSizeInPixels(native_font), | 119 gfx::GetPangoFontSizeInPixels(native_font), |
119 query.style, params); | 120 query.style, params); |
120 } | 121 } |
121 | 122 |
122 PlatformFontPango::PlatformFontPango(const std::string& font_name, | 123 PlatformFontPango::PlatformFontPango(const std::string& font_name, |
123 int font_size_pixels) { | 124 int font_size_pixels) { |
124 FontRenderParamsQuery query(false); | 125 FontRenderParamsQuery query(false); |
125 query.families.push_back(font_name); | 126 query.families.push_back(font_name); |
126 query.pixel_size = font_size_pixels; | 127 query.pixel_size = font_size_pixels; |
127 query.style = gfx::Font::NORMAL; | 128 query.style = gfx::Font::NORMAL; |
128 InitFromDetails(skia::RefPtr<SkTypeface>(), font_name, font_size_pixels, | 129 InitFromDetails(skia::RefPtr<SkTypeface>(), font_name, font_size_pixels, |
129 query.style, gfx::GetFontRenderParams(query, NULL)); | 130 query.style, gfx::GetSystemFontRenderParams(query, NULL)); |
130 } | 131 } |
131 | 132 |
132 //////////////////////////////////////////////////////////////////////////////// | 133 //////////////////////////////////////////////////////////////////////////////// |
133 // PlatformFontPango, PlatformFont implementation: | 134 // PlatformFontPango, PlatformFont implementation: |
134 | 135 |
135 // static | 136 // static |
136 void PlatformFontPango::ReloadDefaultFont() { | 137 void PlatformFontPango::ReloadDefaultFont() { |
137 delete default_font_; | 138 delete default_font_; |
138 default_font_ = NULL; | 139 default_font_ = NULL; |
139 } | 140 } |
(...skipping 15 matching lines...) Expand all Loading... |
155 // If the style changed, we may need to load a new face. | 156 // If the style changed, we may need to load a new face. |
156 std::string new_family = font_family_; | 157 std::string new_family = font_family_; |
157 skia::RefPtr<SkTypeface> typeface = | 158 skia::RefPtr<SkTypeface> typeface = |
158 (style == style_) ? typeface_ : CreateSkTypeface(style, &new_family); | 159 (style == style_) ? typeface_ : CreateSkTypeface(style, &new_family); |
159 | 160 |
160 FontRenderParamsQuery query(false); | 161 FontRenderParamsQuery query(false); |
161 query.families.push_back(new_family); | 162 query.families.push_back(new_family); |
162 query.pixel_size = new_size; | 163 query.pixel_size = new_size; |
163 query.style = style; | 164 query.style = style; |
164 | 165 |
165 return Font(new PlatformFontPango(typeface, new_family, new_size, style, | 166 return Font( |
166 gfx::GetFontRenderParams(query, NULL))); | 167 new PlatformFontPango(typeface, new_family, new_size, style, |
| 168 gfx::GetSystemFontRenderParams(query, NULL))); |
167 } | 169 } |
168 | 170 |
169 int PlatformFontPango::GetHeight() const { | 171 int PlatformFontPango::GetHeight() const { |
170 return height_pixels_; | 172 return height_pixels_; |
171 } | 173 } |
172 | 174 |
173 int PlatformFontPango::GetBaseline() const { | 175 int PlatformFontPango::GetBaseline() const { |
174 return ascent_pixels_; | 176 return ascent_pixels_; |
175 } | 177 } |
176 | 178 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 return new PlatformFontPango(native_font); | 339 return new PlatformFontPango(native_font); |
338 } | 340 } |
339 | 341 |
340 // static | 342 // static |
341 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 343 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
342 int font_size) { | 344 int font_size) { |
343 return new PlatformFontPango(font_name, font_size); | 345 return new PlatformFontPango(font_name, font_size); |
344 } | 346 } |
345 | 347 |
346 } // namespace gfx | 348 } // namespace gfx |
OLD | NEW |