OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 GFX_PLATFORM_FONT_GTK_ | 5 #ifndef GFX_PLATFORM_FONT_GTK_ |
6 #define GFX_PLATFORM_FONT_GTK_ | 6 #define GFX_PLATFORM_FONT_GTK_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "gfx/platform_font.h" | 10 #include "gfx/platform_font.h" |
11 #include "third_party/skia/include/core/SkRefCnt.h" | 11 #include "third_party/skia/include/core/SkRefCnt.h" |
12 | 12 |
13 class SkTypeface; | 13 class SkTypeface; |
14 class SkPaint; | 14 class SkPaint; |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 | 17 |
18 class PlatformFontGtk : public PlatformFont { | 18 class PlatformFontGtk : public PlatformFont { |
19 public: | 19 public: |
20 PlatformFontGtk(); | 20 PlatformFontGtk(); |
21 explicit PlatformFontGtk(const Font& other); | 21 explicit PlatformFontGtk(const Font& other); |
22 explicit PlatformFontGtk(NativeFont native_font); | 22 explicit PlatformFontGtk(NativeFont native_font); |
23 PlatformFontGtk(const std::wstring& font_name, | 23 PlatformFontGtk(const std::wstring& font_name, |
24 int font_size); | 24 int font_size); |
25 | 25 |
26 // Converts |gfx_font| to a new pango font. Free the returned font with | 26 // Converts |gfx_font| to a new pango font. Free the returned font with |
27 // pango_font_description_free(). | 27 // pango_font_description_free(). |
28 static PangoFontDescription* PangoFontFromGfxFont(const gfx::Font& gfx_font); | 28 static PangoFontDescription* PangoFontFromGfxFont(const gfx::Font& gfx_font); |
29 | 29 |
| 30 // Return the scale factor for fonts that account for DPI. |
| 31 static float GetPangoScaleFactor(); |
| 32 |
30 // Position as an offset from the height of the drawn text, used to draw | 33 // Position as an offset from the height of the drawn text, used to draw |
31 // an underline. This is a negative number, so the underline would be | 34 // an underline. This is a negative number, so the underline would be |
32 // drawn at y + height + underline_position; | 35 // drawn at y + height + underline_position; |
33 double underline_position() const; | 36 double underline_position() const; |
34 // The thickness to draw the underline. | 37 // The thickness to draw the underline. |
35 double underline_thickness() const; | 38 double underline_thickness() const; |
36 | 39 |
37 // Overridden from PlatformFont: | 40 // Overridden from PlatformFont: |
38 virtual Font DeriveFont(int size_delta, int style) const; | 41 virtual Font DeriveFont(int size_delta, int style) const; |
39 virtual int GetHeight() const; | 42 virtual int GetHeight() const; |
40 virtual int GetBaseline() const; | 43 virtual int GetBaseline() const; |
41 virtual int GetAverageCharacterWidth() const; | 44 virtual int GetAverageCharacterWidth() const; |
42 virtual int GetStringWidth(const string16& text) const; | 45 virtual int GetStringWidth(const string16& text) const; |
43 virtual int GetExpectedTextWidth(int length) const; | 46 virtual int GetExpectedTextWidth(int length) const; |
44 virtual int GetStyle() const; | 47 virtual int GetStyle() const; |
45 virtual const std::wstring& GetFontName() const; | 48 virtual const std::wstring& GetFontName() const; |
46 virtual int GetFontSize() const; | 49 virtual int GetFontSize() const; |
47 virtual NativeFont GetNativeFont() const; | 50 virtual NativeFont GetNativeFont() const; |
48 | 51 |
49 // Return the scale factor for fonts that account for DPI. | |
50 static float GetPangoScaleFactor(); | |
51 | |
52 private: | 52 private: |
53 // Create a new instance of this object with the specified properties. Called | 53 // Create a new instance of this object with the specified properties. Called |
54 // from DeriveFont. | 54 // from DeriveFont. |
55 PlatformFontGtk(SkTypeface* typeface, | 55 PlatformFontGtk(SkTypeface* typeface, |
56 const std::wstring& name, | 56 const std::wstring& name, |
57 int size, | 57 int size, |
58 int style); | 58 int style); |
59 virtual ~PlatformFontGtk(); | 59 virtual ~PlatformFontGtk(); |
60 | 60 |
61 // Initialize this object. | 61 // Initialize this object. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 double underline_thickness_; | 102 double underline_thickness_; |
103 | 103 |
104 // The default font, used for the default constructor. | 104 // The default font, used for the default constructor. |
105 static Font* default_font_; | 105 static Font* default_font_; |
106 }; | 106 }; |
107 | 107 |
108 } // namespace gfx | 108 } // namespace gfx |
109 | 109 |
110 #endif // GFX_PLATFORM_FONT_GTK_ | 110 #endif // GFX_PLATFORM_FONT_GTK_ |
111 | 111 |
OLD | NEW |