| 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 #ifndef UI_GFX_PLATFORM_FONT_WIN_H_ | 5 #ifndef UI_GFX_PLATFORM_FONT_WIN_H_ |
| 6 #define UI_GFX_PLATFORM_FONT_WIN_H_ | 6 #define UI_GFX_PLATFORM_FONT_WIN_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/gtest_prod_util.h" |
| 11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 12 #include "ui/gfx/gfx_export.h" | 13 #include "ui/gfx/gfx_export.h" |
| 13 #include "ui/gfx/platform_font.h" | 14 #include "ui/gfx/platform_font.h" |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 | 17 |
| 17 class GFX_EXPORT PlatformFontWin : public PlatformFont { | 18 class GFX_EXPORT PlatformFontWin : public PlatformFont { |
| 18 public: | 19 public: |
| 19 PlatformFontWin(); | 20 PlatformFontWin(); |
| 20 explicit PlatformFontWin(NativeFont native_font); | 21 explicit PlatformFontWin(NativeFont native_font); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 virtual int GetCapHeight() const override; | 61 virtual int GetCapHeight() const override; |
| 61 virtual int GetExpectedTextWidth(int length) const override; | 62 virtual int GetExpectedTextWidth(int length) const override; |
| 62 virtual int GetStyle() const override; | 63 virtual int GetStyle() const override; |
| 63 virtual std::string GetFontName() const override; | 64 virtual std::string GetFontName() const override; |
| 64 virtual std::string GetActualFontNameForTesting() const override; | 65 virtual std::string GetActualFontNameForTesting() const override; |
| 65 virtual int GetFontSize() const override; | 66 virtual int GetFontSize() const override; |
| 66 virtual const FontRenderParams& GetFontRenderParams() const override; | 67 virtual const FontRenderParams& GetFontRenderParams() const override; |
| 67 virtual NativeFont GetNativeFont() const override; | 68 virtual NativeFont GetNativeFont() const override; |
| 68 | 69 |
| 69 private: | 70 private: |
| 71 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback); |
| 72 |
| 70 virtual ~PlatformFontWin() {} | 73 virtual ~PlatformFontWin() {} |
| 71 | 74 |
| 72 // Chrome text drawing bottoms out in the Windows GDI functions that take an | 75 // Chrome text drawing bottoms out in the Windows GDI functions that take an |
| 73 // HFONT (an opaque handle into Windows). To avoid lots of GDI object | 76 // HFONT (an opaque handle into Windows). To avoid lots of GDI object |
| 74 // allocation and destruction, Font indirectly refers to the HFONT by way of | 77 // allocation and destruction, Font indirectly refers to the HFONT by way of |
| 75 // an HFontRef. That is, every Font has an HFontRef, which has an HFONT. | 78 // an HFontRef. That is, every Font has an HFontRef, which has an HFONT. |
| 76 // | 79 // |
| 77 // HFontRef is reference counted. Upon deletion, it deletes the HFONT. | 80 // HFontRef is reference counted. Upon deletion, it deletes the HFONT. |
| 78 // By making HFontRef maintain the reference to the HFONT, multiple | 81 // By making HFontRef maintain the reference to the HFONT, multiple |
| 79 // HFontRefs can share the same HFONT, and Font can provide value semantics. | 82 // HFontRefs can share the same HFONT, and Font can provide value semantics. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 98 int style() const { return style_; } | 101 int style() const { return style_; } |
| 99 const std::string& font_name() const { return font_name_; } | 102 const std::string& font_name() const { return font_name_; } |
| 100 int font_size() const { return font_size_; } | 103 int font_size() const { return font_size_; } |
| 101 int requested_font_size() const { return requested_font_size_; } | 104 int requested_font_size() const { return requested_font_size_; } |
| 102 | 105 |
| 103 // Returns the average character width in dialog units. | 106 // Returns the average character width in dialog units. |
| 104 int GetDluBaseX(); | 107 int GetDluBaseX(); |
| 105 | 108 |
| 106 private: | 109 private: |
| 107 friend class base::RefCounted<HFontRef>; | 110 friend class base::RefCounted<HFontRef>; |
| 111 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback); |
| 108 | 112 |
| 109 ~HFontRef(); | 113 ~HFontRef(); |
| 110 | 114 |
| 111 const HFONT hfont_; | 115 const HFONT hfont_; |
| 112 const int font_size_; | 116 const int font_size_; |
| 113 const int height_; | 117 const int height_; |
| 114 const int baseline_; | 118 const int baseline_; |
| 115 const int cap_height_; | 119 const int cap_height_; |
| 116 const int ave_char_width_; | 120 const int ave_char_width_; |
| 117 const int style_; | 121 const int style_; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 164 |
| 161 // Indirect reference to the HFontRef, which references the underlying HFONT. | 165 // Indirect reference to the HFontRef, which references the underlying HFONT. |
| 162 scoped_refptr<HFontRef> font_ref_; | 166 scoped_refptr<HFontRef> font_ref_; |
| 163 | 167 |
| 164 DISALLOW_COPY_AND_ASSIGN(PlatformFontWin); | 168 DISALLOW_COPY_AND_ASSIGN(PlatformFontWin); |
| 165 }; | 169 }; |
| 166 | 170 |
| 167 } // namespace gfx | 171 } // namespace gfx |
| 168 | 172 |
| 169 #endif // UI_GFX_PLATFORM_FONT_WIN_H_ | 173 #endif // UI_GFX_PLATFORM_FONT_WIN_H_ |
| OLD | NEW |