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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 | 47 |
48 // Returns the font name for the system locale. Some fonts, particularly | 48 // Returns the font name for the system locale. Some fonts, particularly |
49 // East Asian fonts, have different names per locale. If the localized font | 49 // East Asian fonts, have different names per locale. If the localized font |
50 // name could not be retrieved, returns GetFontName(). | 50 // name could not be retrieved, returns GetFontName(). |
51 std::string GetLocalizedFontName() const; | 51 std::string GetLocalizedFontName() const; |
52 | 52 |
53 // Returns a derived Font with the specified |style| and maximum |height|. | 53 // Returns a derived Font with the specified |style| and maximum |height|. |
54 // The returned Font will be the largest font size with a height <= |height|, | 54 // The returned Font will be the largest font size with a height <= |height|, |
55 // since a size with the exact specified |height| may not necessarily exist. | 55 // since a size with the exact specified |height| may not necessarily exist. |
56 // GetMinimumFontSize() may impose a font size that is taller than |height|. | 56 // GetMinimumFontSize() may impose a font size that is taller than |height|. |
57 Font DeriveFontWithHeight(int height, int style); | 57 Font DeriveFontWithHeight(int height, |
msw
2016/03/22 01:53:44
This seems to only be called from unit tests. Can
| |
58 int style, | |
59 gfx::Font::FontWeight weight); | |
58 | 60 |
59 // Overridden from PlatformFont: | 61 // Overridden from PlatformFont: |
60 Font DeriveFont(int size_delta, int style) const override; | 62 Font DeriveFont(int size_delta, |
63 int style, | |
64 gfx::Font::FontWeight weight) const override; | |
61 int GetHeight() override; | 65 int GetHeight() override; |
66 gfx::Font::FontWeight GetWeight() override; | |
62 int GetBaseline() override; | 67 int GetBaseline() override; |
63 int GetCapHeight() override; | 68 int GetCapHeight() override; |
64 int GetExpectedTextWidth(int length) override; | 69 int GetExpectedTextWidth(int length) override; |
65 int GetStyle() const override; | 70 int GetStyle() const override; |
66 const std::string& GetFontName() const override; | 71 const std::string& GetFontName() const override; |
67 std::string GetActualFontNameForTesting() const override; | 72 std::string GetActualFontNameForTesting() const override; |
68 int GetFontSize() const override; | 73 int GetFontSize() const override; |
69 const FontRenderParams& GetFontRenderParams() override; | 74 const FontRenderParams& GetFontRenderParams() override; |
70 NativeFont GetNativeFont() const override; | 75 NativeFont GetNativeFont() const override; |
71 | 76 |
(...skipping 27 matching lines...) Expand all Loading... | |
99 class GFX_EXPORT HFontRef : public base::RefCounted<HFontRef> { | 104 class GFX_EXPORT HFontRef : public base::RefCounted<HFontRef> { |
100 public: | 105 public: |
101 // This constructor takes control of the HFONT, and will delete it when | 106 // This constructor takes control of the HFONT, and will delete it when |
102 // the HFontRef is deleted. | 107 // the HFontRef is deleted. |
103 HFontRef(HFONT hfont, | 108 HFontRef(HFONT hfont, |
104 int font_size, | 109 int font_size, |
105 int height, | 110 int height, |
106 int baseline, | 111 int baseline, |
107 int cap_height, | 112 int cap_height, |
108 int ave_char_width, | 113 int ave_char_width, |
114 gfx::Font::FontWeight weight, | |
109 int style); | 115 int style); |
110 | 116 |
111 // Accessors | 117 // Accessors |
112 HFONT hfont() const { return hfont_; } | 118 HFONT hfont() const { return hfont_; } |
113 int height() const { return height_; } | 119 int height() const { return height_; } |
114 int baseline() const { return baseline_; } | 120 int baseline() const { return baseline_; } |
115 int cap_height() const { return cap_height_; } | 121 int cap_height() const { return cap_height_; } |
116 int ave_char_width() const { return ave_char_width_; } | 122 int ave_char_width() const { return ave_char_width_; } |
123 gfx::Font::FontWeight weight() const { return weight_; } | |
117 int style() const { return style_; } | 124 int style() const { return style_; } |
118 const std::string& font_name() const { return font_name_; } | 125 const std::string& font_name() const { return font_name_; } |
119 int font_size() const { return font_size_; } | 126 int font_size() const { return font_size_; } |
120 int requested_font_size() const { return requested_font_size_; } | 127 int requested_font_size() const { return requested_font_size_; } |
121 | 128 |
122 // Returns the average character width in dialog units. | 129 // Returns the average character width in dialog units. |
123 int GetDluBaseX(); | 130 int GetDluBaseX(); |
124 | 131 |
125 // Helper to return the average character width using the text extent | 132 // Helper to return the average character width using the text extent |
126 // technique mentioned here. http://support.microsoft.com/kb/125681. | 133 // technique mentioned here. http://support.microsoft.com/kb/125681. |
127 static int GetAverageCharWidthInDialogUnits(HFONT gdi_font); | 134 static int GetAverageCharWidthInDialogUnits(HFONT gdi_font); |
128 | 135 |
129 private: | 136 private: |
130 friend class base::RefCounted<HFontRef>; | 137 friend class base::RefCounted<HFontRef>; |
131 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback); | 138 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback); |
132 FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, Metrics_SkiaVersusGDI); | 139 FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, Metrics_SkiaVersusGDI); |
133 FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, DirectWriteFontSubstitution); | 140 FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, DirectWriteFontSubstitution); |
134 | 141 |
135 ~HFontRef(); | 142 ~HFontRef(); |
136 | 143 |
137 const HFONT hfont_; | 144 const HFONT hfont_; |
138 const int font_size_; | 145 const int font_size_; |
139 const int height_; | 146 const int height_; |
140 const int baseline_; | 147 const int baseline_; |
141 const int cap_height_; | 148 const int cap_height_; |
142 const int ave_char_width_; | 149 const int ave_char_width_; |
150 const gfx::Font::FontWeight weight_; | |
143 const int style_; | 151 const int style_; |
144 // Average character width in dialog units. This is queried lazily from the | 152 // Average character width in dialog units. This is queried lazily from the |
145 // system, with an initial value of -1 meaning it hasn't yet been queried. | 153 // system, with an initial value of -1 meaning it hasn't yet been queried. |
146 int dlu_base_x_; | 154 int dlu_base_x_; |
147 std::string font_name_; | 155 std::string font_name_; |
148 | 156 |
149 // If the requested font size is not possible for the font, |font_size_| | 157 // If the requested font size is not possible for the font, |font_size_| |
150 // will be different than |requested_font_size_|. This is stored separately | 158 // will be different than |requested_font_size_|. This is stored separately |
151 // so that code that increases the font size in a loop will not cause the | 159 // so that code that increases the font size in a loop will not cause the |
152 // loop to get stuck on the same size. | 160 // loop to get stuck on the same size. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 | 208 |
201 // Pointer to the global IDWriteFactory interface. | 209 // Pointer to the global IDWriteFactory interface. |
202 static IDWriteFactory* direct_write_factory_; | 210 static IDWriteFactory* direct_write_factory_; |
203 | 211 |
204 DISALLOW_COPY_AND_ASSIGN(PlatformFontWin); | 212 DISALLOW_COPY_AND_ASSIGN(PlatformFontWin); |
205 }; | 213 }; |
206 | 214 |
207 } // namespace gfx | 215 } // namespace gfx |
208 | 216 |
209 #endif // UI_GFX_PLATFORM_FONT_WIN_H_ | 217 #endif // UI_GFX_PLATFORM_FONT_WIN_H_ |
OLD | NEW |