| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_COMMON_GFX_CHROME_FONT_H_ | 5 #ifndef CHROME_COMMON_GFX_CHROME_FONT_H_ |
| 6 #define CHROME_COMMON_GFX_CHROME_FONT_H_ | 6 #define CHROME_COMMON_GFX_CHROME_FONT_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // ChromeFont provides a wrapper around an underlying font. Copy and assignment | 40 // ChromeFont provides a wrapper around an underlying font. Copy and assignment |
| 41 // operators are explicitly allowed, and cheap. | 41 // operators are explicitly allowed, and cheap. |
| 42 class ChromeFont { | 42 class ChromeFont { |
| 43 public: | 43 public: |
| 44 // The following constants indicate the font style. | 44 // The following constants indicate the font style. |
| 45 enum { | 45 enum { |
| 46 NORMAL = 0, | 46 NORMAL = 0, |
| 47 BOLD = 1, | 47 BOLD = 1, |
| 48 ITALIC = 2, | 48 ITALIC = 2, |
| 49 UNDERLINED = 4, | 49 UNDERLINED = 4, |
| 50 WEB = 8, // TODO(agl): what does this mean? | |
| 51 }; | 50 }; |
| 52 | 51 |
| 53 // Creates a ChromeFont given font name (e.g. arial), font size (e.g. 12). | 52 // Creates a ChromeFont given font name (e.g. arial), font size (e.g. 12). |
| 54 static ChromeFont CreateFont(const std::wstring& font_name, int font_size); | 53 static ChromeFont CreateFont(const std::wstring& font_name, int font_size); |
| 55 | 54 |
| 56 ~ChromeFont() { } | 55 ~ChromeFont() { } |
| 57 | 56 |
| 58 // Returns a new Font derived from the existing font. | 57 // Returns a new Font derived from the existing font. |
| 59 // size_deta is the size to add to the current font. For example, a value | 58 // size_deta is the size to add to the current font. For example, a value |
| 60 // of 5 results in a font 5 units bigger than this font. | 59 // of 5 results in a font 5 units bigger than this font. |
| 61 ChromeFont DeriveFont(int size_delta) const { | 60 ChromeFont DeriveFont(int size_delta) const { |
| 62 return DeriveFont(size_delta, style()); | 61 return DeriveFont(size_delta, style()); |
| 63 } | 62 } |
| 64 | 63 |
| 65 // Returns a new Font derived from the existing font. | 64 // Returns a new Font derived from the existing font. |
| 66 // size_deta is the size to add to the current font. See the single | 65 // size_deta is the size to add to the current font. See the single |
| 67 // argument version of this method for an example. | 66 // argument version of this method for an example. |
| 68 // The style parameter specifies the new style for the font, and is a | 67 // The style parameter specifies the new style for the font, and is a |
| 69 // bitmask of the values: BOLD, ITALIC, UNDERLINED and WEB. | 68 // bitmask of the values: BOLD, ITALIC, and UNDERLINED. |
| 70 ChromeFont DeriveFont(int size_delta, int style) const; | 69 ChromeFont DeriveFont(int size_delta, int style) const; |
| 71 | 70 |
| 72 // Returns the number of vertical pixels needed to display characters from | 71 // Returns the number of vertical pixels needed to display characters from |
| 73 // the specified font. | 72 // the specified font. |
| 74 int height() const; | 73 int height() const; |
| 75 | 74 |
| 76 // Returns the baseline, or ascent, of the font. | 75 // Returns the baseline, or ascent, of the font. |
| 77 int baseline() const; | 76 int baseline() const; |
| 78 | 77 |
| 79 // Returns the average character width for the font. | 78 // Returns the average character width for the font. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 224 |
| 226 // Cached metrics, generated at construction | 225 // Cached metrics, generated at construction |
| 227 int height_; | 226 int height_; |
| 228 int ascent_; | 227 int ascent_; |
| 229 int avg_width_; | 228 int avg_width_; |
| 230 #endif | 229 #endif |
| 231 | 230 |
| 232 }; | 231 }; |
| 233 | 232 |
| 234 #endif // CHROME_COMMON_GFX_CHROME_FONT_H_ | 233 #endif // CHROME_COMMON_GFX_CHROME_FONT_H_ |
| OLD | NEW |