Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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_ | 5 #ifndef GFX_PLATFORM_FONT_ |
| 6 #define GFX_PLATFORM_FONT_ | 6 #define GFX_PLATFORM_FONT_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "gfx/native_widget_types.h" | 13 #include "gfx/native_widget_types.h" |
| 14 | 14 |
| 15 namespace gfx { | 15 namespace gfx { |
| 16 | 16 |
| 17 class Font; | 17 class Font; |
| 18 | 18 |
| 19 class PlatformFont : public base::RefCounted<PlatformFont> { | 19 class PlatformFont : public base::RefCounted<PlatformFont> { |
| 20 public: | 20 public: |
| 21 // Create an appropriate PlatformFont implementation. | 21 // Create an appropriate PlatformFont implementation. |
| 22 static PlatformFont* CreateDefault(); | 22 static PlatformFont* CreateDefault(); |
| 23 static PlatformFont* CreateFromFont(const Font& other); | 23 static PlatformFont* CreateFromFont(const Font& other); |
| 24 static PlatformFont* CreateFromNativeFont(NativeFont native_font); | 24 static PlatformFont* CreateFromNativeFont(NativeFont native_font); |
| 25 static PlatformFont* CreateFromNameAndSize(const std::wstring& font_name, | 25 static PlatformFont* CreateFromNameAndSize(const string16& font_name, |
| 26 int font_size); | 26 int font_size); |
| 27 | 27 |
| 28 // Returns a new Font derived from the existing font. | 28 // Returns a new Font derived from the existing font. |
| 29 // size_delta is the size to add to the current font. See the single | 29 // size_delta is the size to add to the current font. See the single |
| 30 // argument version of this method for an example. | 30 // argument version of this method for an example. |
| 31 // The style parameter specifies the new style for the font, and is a | 31 // The style parameter specifies the new style for the font, and is a |
| 32 // bitmask of the values: BOLD, ITALIC and UNDERLINED. | 32 // bitmask of the values: BOLD, ITALIC and UNDERLINED. |
| 33 virtual Font DeriveFont(int size_delta, int style) const = 0; | 33 virtual Font DeriveFont(int size_delta, int style) const = 0; |
| 34 | 34 |
| 35 // Returns the number of vertical pixels needed to display characters from | 35 // Returns the number of vertical pixels needed to display characters from |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 51 | 51 |
| 52 // Returns the expected number of horizontal pixels needed to display the | 52 // Returns the expected number of horizontal pixels needed to display the |
| 53 // specified length of characters. Call GetStringWidth() to retrieve the | 53 // specified length of characters. Call GetStringWidth() to retrieve the |
| 54 // actual number. | 54 // actual number. |
| 55 virtual int GetExpectedTextWidth(int length) const = 0; | 55 virtual int GetExpectedTextWidth(int length) const = 0; |
| 56 | 56 |
| 57 // Returns the style of the font. | 57 // Returns the style of the font. |
| 58 virtual int GetStyle() const = 0; | 58 virtual int GetStyle() const = 0; |
| 59 | 59 |
| 60 // Returns the font name. | 60 // Returns the font name. |
| 61 virtual const std::wstring& GetFontName() const = 0; | 61 virtual const string16& GetFontName() const = 0; |
|
evanm
2011/01/11 21:56:47
Not your problem, but this really shoulda returned
Avi (use Gerrit)
2011/01/11 22:15:28
Done.
| |
| 62 | 62 |
| 63 // Returns the font size in pixels. | 63 // Returns the font size in pixels. |
| 64 virtual int GetFontSize() const = 0; | 64 virtual int GetFontSize() const = 0; |
| 65 | 65 |
| 66 // Returns the native font handle. | 66 // Returns the native font handle. |
| 67 virtual NativeFont GetNativeFont() const = 0; | 67 virtual NativeFont GetNativeFont() const = 0; |
| 68 | 68 |
| 69 protected: | 69 protected: |
| 70 virtual ~PlatformFont() {} | 70 virtual ~PlatformFont() {} |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 friend class base::RefCounted<PlatformFont>; | 73 friend class base::RefCounted<PlatformFont>; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 } // namespace gfx | 76 } // namespace gfx |
| 77 | 77 |
| 78 #endif // GFX_PLATFORM_FONT_ | 78 #endif // GFX_PLATFORM_FONT_ |
| 79 | 79 |
| OLD | NEW |