OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef GFX_PLATFORM_FONT_ |
| 6 #define GFX_PLATFORM_FONT_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/ref_counted.h" |
| 12 #include "gfx/native_widget_types.h" |
| 13 |
| 14 namespace gfx { |
| 15 |
| 16 class Font; |
| 17 |
| 18 class PlatformFont : public base::RefCounted<PlatformFont> { |
| 19 public: |
| 20 // Create an appropriate PlatformFont implementation. |
| 21 static PlatformFont* CreateDefault(); |
| 22 static PlatformFont* CreateFromFont(const Font& other); |
| 23 static PlatformFont* CreateFromNativeFont(NativeFont native_font); |
| 24 static PlatformFont* CreateFromNameAndSize(const std::wstring& font_name, |
| 25 int font_size); |
| 26 |
| 27 // Returns a new Font derived from the existing font. |
| 28 // size_delta is the size to add to the current font. See the single |
| 29 // argument version of this method for an example. |
| 30 // The style parameter specifies the new style for the font, and is a |
| 31 // bitmask of the values: BOLD, ITALIC and UNDERLINED. |
| 32 virtual Font DeriveFont(int size_delta, int style) const = 0; |
| 33 |
| 34 // Returns the number of vertical pixels needed to display characters from |
| 35 // the specified font. This may include some leading, i.e. height may be |
| 36 // greater than just ascent + descent. Specifically, the Windows and Mac |
| 37 // implementations include leading and the Linux one does not. This may |
| 38 // need to be revisited in the future. |
| 39 virtual int GetHeight() const = 0; |
| 40 |
| 41 // Returns the baseline, or ascent, of the font. |
| 42 virtual int GetBaseline() const = 0; |
| 43 |
| 44 // Returns the average character width for the font. |
| 45 virtual int GetAverageCharacterWidth() const = 0; |
| 46 |
| 47 // Returns the number of horizontal pixels needed to display the specified |
| 48 // string. |
| 49 virtual int GetStringWidth(const std::wstring& text) const = 0; |
| 50 |
| 51 // Returns the expected number of horizontal pixels needed to display the |
| 52 // specified length of characters. Call GetStringWidth() to retrieve the |
| 53 // actual number. |
| 54 virtual int GetExpectedTextWidth(int length) const = 0; |
| 55 |
| 56 // Returns the style of the font. |
| 57 virtual int GetStyle() const = 0; |
| 58 |
| 59 // Returns the font name. |
| 60 virtual const std::wstring& GetFontName() const = 0; |
| 61 |
| 62 // Returns the font size in pixels. |
| 63 virtual int GetFontSize() const = 0; |
| 64 |
| 65 // Returns the native font handle. |
| 66 virtual NativeFont GetNativeFont() const = 0; |
| 67 |
| 68 protected: |
| 69 virtual ~PlatformFont() {} |
| 70 |
| 71 private: |
| 72 friend class base::RefCounted<PlatformFont>; |
| 73 }; |
| 74 |
| 75 } // namespace gfx |
| 76 |
| 77 #endif // GFX_PLATFORM_FONT_ |
| 78 |
OLD | NEW |