| OLD | NEW |
| 1 // Copyright (c) 2011 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 UI_GFX_PLATFORM_FONT_GTK_ | 5 #ifndef UI_GFX_PLATFORM_FONT_GTK_ |
| 6 #define UI_GFX_PLATFORM_FONT_GTK_ | 6 #define UI_GFX_PLATFORM_FONT_GTK_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "third_party/skia/include/core/SkRefCnt.h" | 10 #include "third_party/skia/include/core/SkRefCnt.h" |
| 11 #include "ui/gfx/platform_font.h" | 11 #include "ui/gfx/platform_font.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 UI_EXPORT PlatformFontGtk : public PlatformFont { | 18 class UI_EXPORT PlatformFontPango : public PlatformFont { |
| 19 public: | 19 public: |
| 20 PlatformFontGtk(); | 20 PlatformFontPango(); |
| 21 explicit PlatformFontGtk(const Font& other); | 21 explicit PlatformFontPango(const Font& other); |
| 22 explicit PlatformFontGtk(NativeFont native_font); | 22 explicit PlatformFontPango(NativeFont native_font); |
| 23 PlatformFontGtk(const string16& font_name, | 23 PlatformFontPango(const string16& 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 // Resets and reloads the cached system font used by the default constructor. | 30 // Resets and reloads the cached system font used by the default constructor. |
| 31 // This function is useful when the system font has changed, for example, when | 31 // This function is useful when the system font has changed, for example, when |
| 32 // the locale has changed. | 32 // the locale has changed. |
| 33 static void ReloadDefaultFont(); | 33 static void ReloadDefaultFont(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 47 virtual int GetStringWidth(const string16& text) const; | 47 virtual int GetStringWidth(const string16& text) const; |
| 48 virtual int GetExpectedTextWidth(int length) const; | 48 virtual int GetExpectedTextWidth(int length) const; |
| 49 virtual int GetStyle() const; | 49 virtual int GetStyle() const; |
| 50 virtual string16 GetFontName() const; | 50 virtual string16 GetFontName() const; |
| 51 virtual int GetFontSize() const; | 51 virtual int GetFontSize() const; |
| 52 virtual NativeFont GetNativeFont() const; | 52 virtual NativeFont GetNativeFont() const; |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 // Create a new instance of this object with the specified properties. Called | 55 // Create a new instance of this object with the specified properties. Called |
| 56 // from DeriveFont. | 56 // from DeriveFont. |
| 57 PlatformFontGtk(SkTypeface* typeface, | 57 PlatformFontPango(SkTypeface* typeface, |
| 58 const string16& name, | 58 const string16& name, |
| 59 int size, | 59 int size, |
| 60 int style); | 60 int style); |
| 61 virtual ~PlatformFontGtk(); | 61 virtual ~PlatformFontPango(); |
| 62 | 62 |
| 63 // Initialize this object. | 63 // Initialize this object. |
| 64 void InitWithNameAndSize(const string16& font_name, int font_size); | 64 void InitWithNameAndSize(const string16& font_name, int font_size); |
| 65 void InitWithTypefaceNameSizeAndStyle(SkTypeface* typeface, | 65 void InitWithTypefaceNameSizeAndStyle(SkTypeface* typeface, |
| 66 const string16& name, | 66 const string16& name, |
| 67 int size, | 67 int size, |
| 68 int style); | 68 int style); |
| 69 void InitFromPlatformFont(const PlatformFontGtk* other); | 69 void InitFromPlatformFont(const PlatformFontPango* other); |
| 70 | 70 |
| 71 // Potentially slow call to get pango metrics (average width, underline info). | 71 // Potentially slow call to get pango metrics (average width, underline info). |
| 72 void InitPangoMetrics(); | 72 void InitPangoMetrics(); |
| 73 | 73 |
| 74 // Setup a Skia context to use the current typeface | 74 // Setup a Skia context to use the current typeface |
| 75 void PaintSetup(SkPaint* paint) const; | 75 void PaintSetup(SkPaint* paint) const; |
| 76 | 76 |
| 77 // Make |this| a copy of |other|. | 77 // Make |this| a copy of |other|. |
| 78 void CopyFont(const Font& other); | 78 void CopyFont(const Font& other); |
| 79 | 79 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 103 double underline_position_pixels_; | 103 double underline_position_pixels_; |
| 104 double underline_thickness_pixels_; | 104 double underline_thickness_pixels_; |
| 105 | 105 |
| 106 // The default font, used for the default constructor. | 106 // The default font, used for the default constructor. |
| 107 static Font* default_font_; | 107 static Font* default_font_; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 } // namespace gfx | 110 } // namespace gfx |
| 111 | 111 |
| 112 #endif // UI_GFX_PLATFORM_FONT_GTK_ | 112 #endif // UI_GFX_PLATFORM_FONT_GTK_ |
| OLD | NEW |