OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef APP_GFX_FONT_H_ | 5 #ifndef APP_GFX_FONT_H_ |
6 #define APP_GFX_FONT_H_ | 6 #define APP_GFX_FONT_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 explicit Font(SkTypeface* typeface, const std::wstring& name, | 212 explicit Font(SkTypeface* typeface, const std::wstring& name, |
213 int size, int style); | 213 int size, int style); |
214 // Calculate and cache the font metrics. | 214 // Calculate and cache the font metrics. |
215 void calculateMetrics(); | 215 void calculateMetrics(); |
216 // Make |this| a copy of |other|. | 216 // Make |this| a copy of |other|. |
217 void CopyFont(const Font& other); | 217 void CopyFont(const Font& other); |
218 | 218 |
219 // The default font, used for the default constructor. | 219 // The default font, used for the default constructor. |
220 static Font* default_font_; | 220 static Font* default_font_; |
221 | 221 |
| 222 // Return the scale factor for fonts that account for DPI. We clamp the |
| 223 // max DPI to prevent large fonts from overflowing UI elements. |
| 224 static float GetPangoScaleFactor(); |
| 225 |
222 // The average width of a character, initialized and cached if needed. | 226 // The average width of a character, initialized and cached if needed. |
223 double avg_width() const; | 227 double avg_width() const; |
224 | 228 |
225 // Potentially slow call to get pango metrics (avg width, underline info). | 229 // Potentially slow call to get pango metrics (avg width, underline info). |
226 void InitPangoMetrics(); | 230 void InitPangoMetrics(); |
227 | 231 |
228 // These two both point to the same SkTypeface. We use the SkAutoUnref to | 232 // These two both point to the same SkTypeface. We use the SkAutoUnref to |
229 // handle the reference counting, but without @typeface_ we would have to | 233 // handle the reference counting, but without @typeface_ we would have to |
230 // cast the SkRefCnt from @typeface_helper_ every time. | 234 // cast the SkRefCnt from @typeface_helper_ every time. |
231 scoped_ptr<SkAutoUnref> typeface_helper_; | 235 scoped_ptr<SkAutoUnref> typeface_helper_; |
(...skipping 29 matching lines...) Expand all Loading... |
261 int height_; | 265 int height_; |
262 int ascent_; | 266 int ascent_; |
263 int avg_width_; | 267 int avg_width_; |
264 #endif | 268 #endif |
265 | 269 |
266 }; | 270 }; |
267 | 271 |
268 } // namespace gfx | 272 } // namespace gfx |
269 | 273 |
270 #endif // APP_GFX_FONT_H_ | 274 #endif // APP_GFX_FONT_H_ |
OLD | NEW |