| 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_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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 10 #include "ui/base/ui_export.h" | 11 #include "ui/base/ui_export.h" |
| 11 #include "ui/gfx/platform_font.h" | 12 #include "ui/gfx/platform_font.h" |
| 12 | 13 |
| 13 namespace gfx { | 14 namespace gfx { |
| 14 | 15 |
| 15 class UI_EXPORT PlatformFontWin : public PlatformFont { | 16 class UI_EXPORT PlatformFontWin : public PlatformFont { |
| 16 public: | 17 public: |
| 17 PlatformFontWin(); | 18 PlatformFontWin(); |
| 18 explicit PlatformFontWin(const Font& other); | 19 explicit PlatformFontWin(const Font& other); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 34 static GetMinimumFontSizeCallback get_minimum_font_size_callback; | 35 static GetMinimumFontSizeCallback get_minimum_font_size_callback; |
| 35 | 36 |
| 36 // Callback that adjusts a LOGFONT to meet suitability requirements of the | 37 // Callback that adjusts a LOGFONT to meet suitability requirements of the |
| 37 // embedding application. Optional. If not specified, no adjustments are | 38 // embedding application. Optional. If not specified, no adjustments are |
| 38 // performed other than clamping to a minimum font height if | 39 // performed other than clamping to a minimum font height if |
| 39 // |get_minimum_font_size_callback| is specified. | 40 // |get_minimum_font_size_callback| is specified. |
| 40 typedef void (*AdjustFontCallback)(LOGFONT* lf); | 41 typedef void (*AdjustFontCallback)(LOGFONT* lf); |
| 41 static AdjustFontCallback adjust_font_callback; | 42 static AdjustFontCallback adjust_font_callback; |
| 42 | 43 |
| 43 // Overridden from PlatformFont: | 44 // Overridden from PlatformFont: |
| 44 virtual Font DeriveFont(int size_delta, int style) const; | 45 virtual Font DeriveFont(int size_delta, int style) const OVERRIDE; |
| 45 virtual int GetHeight() const; | 46 virtual int GetHeight() const OVERRIDE; |
| 46 virtual int GetBaseline() const; | 47 virtual int GetBaseline() const OVERRIDE; |
| 47 virtual int GetAverageCharacterWidth() const; | 48 virtual int GetAverageCharacterWidth() const OVERRIDE; |
| 48 virtual int GetStringWidth(const string16& text) const; | 49 virtual int GetStringWidth(const string16& text) const OVERRIDE; |
| 49 virtual int GetExpectedTextWidth(int length) const; | 50 virtual int GetExpectedTextWidth(int length) const OVERRIDE; |
| 50 virtual int GetStyle() const; | 51 virtual int GetStyle() const OVERRIDE; |
| 51 virtual std::string GetFontName() const; | 52 virtual std::string GetFontName() const OVERRIDE; |
| 52 virtual int GetFontSize() const; | 53 virtual int GetFontSize() const OVERRIDE; |
| 53 virtual NativeFont GetNativeFont() const; | 54 virtual NativeFont GetNativeFont() const OVERRIDE; |
| 54 | 55 |
| 55 private: | 56 private: |
| 56 virtual ~PlatformFontWin() {} | 57 virtual ~PlatformFontWin() {} |
| 57 | 58 |
| 58 // Chrome text drawing bottoms out in the Windows GDI functions that take an | 59 // Chrome text drawing bottoms out in the Windows GDI functions that take an |
| 59 // HFONT (an opaque handle into Windows). To avoid lots of GDI object | 60 // HFONT (an opaque handle into Windows). To avoid lots of GDI object |
| 60 // allocation and destruction, Font indirectly refers to the HFONT by way of | 61 // allocation and destruction, Font indirectly refers to the HFONT by way of |
| 61 // an HFontRef. That is, every Font has an HFontRef, which has an HFONT. | 62 // an HFontRef. That is, every Font has an HFontRef, which has an HFONT. |
| 62 // | 63 // |
| 63 // HFontRef is reference counted. Upon deletion, it deletes the HFONT. | 64 // HFontRef is reference counted. Upon deletion, it deletes the HFONT. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 static HFontRef* base_font_ref_; | 123 static HFontRef* base_font_ref_; |
| 123 | 124 |
| 124 // Indirect reference to the HFontRef, which references the underlying HFONT. | 125 // Indirect reference to the HFontRef, which references the underlying HFONT. |
| 125 scoped_refptr<HFontRef> font_ref_; | 126 scoped_refptr<HFontRef> font_ref_; |
| 126 }; | 127 }; |
| 127 | 128 |
| 128 } // namespace gfx | 129 } // namespace gfx |
| 129 | 130 |
| 130 #endif // UI_GFX_PLATFORM_FONT_WIN_H_ | 131 #endif // UI_GFX_PLATFORM_FONT_WIN_H_ |
| 131 | 132 |
| OLD | NEW |