Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: ui/gfx/platform_font_win.h

Issue 853553002: Relanding this with font test fixes for gdi. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DeriveFontWithHeight starts with a font matching the minimum size Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // performed other than clamping to a minimum font height if 42 // performed other than clamping to a minimum font height if
43 // |get_minimum_font_size_callback| is specified. 43 // |get_minimum_font_size_callback| is specified.
44 typedef void (*AdjustFontCallback)(LOGFONT* lf); 44 typedef void (*AdjustFontCallback)(LOGFONT* lf);
45 static AdjustFontCallback adjust_font_callback; 45 static AdjustFontCallback adjust_font_callback;
46 46
47 // Returns the font name for the system locale. Some fonts, particularly 47 // Returns the font name for the system locale. Some fonts, particularly
48 // East Asian fonts, have different names per locale. If the localized font 48 // East Asian fonts, have different names per locale. If the localized font
49 // name could not be retrieved, returns GetFontName(). 49 // name could not be retrieved, returns GetFontName().
50 std::string GetLocalizedFontName() const; 50 std::string GetLocalizedFontName() const;
51 51
52 // Returns a derived Font with the specified |style| and with height at most 52 // Returns a derived Font with the specified |style| and maximum |height|.
53 // |height|. If the height and style of the receiver already match, it is 53 // The returned Font will be the largest font size with a height <= |height|,
54 // returned. Otherwise, the returned Font will have the largest size such that 54 // since a size with the exact specified |height| may not necessarily exist.
55 // its height is less than or equal to |height| (since there may not exist a 55 // GetMinimumFontSize() may impose a font size that is taller than |height|
msw 2015/01/13 23:54:59 nit: trailing period.
ananta 2015/01/14 00:17:23 Done.
56 // size that matches the exact |height| specified).
57 Font DeriveFontWithHeight(int height, int style); 56 Font DeriveFontWithHeight(int height, int style);
58 57
59 // Overridden from PlatformFont: 58 // Overridden from PlatformFont:
60 virtual Font DeriveFont(int size_delta, int style) const override; 59 virtual Font DeriveFont(int size_delta, int style) const override;
61 virtual int GetHeight() const override; 60 virtual int GetHeight() const override;
62 virtual int GetBaseline() const override; 61 virtual int GetBaseline() const override;
63 virtual int GetCapHeight() const override; 62 virtual int GetCapHeight() const override;
64 virtual int GetExpectedTextWidth(int length) const override; 63 virtual int GetExpectedTextWidth(int length) const override;
65 virtual int GetStyle() const override; 64 virtual int GetStyle() const override;
66 virtual std::string GetFontName() const override; 65 virtual std::string GetFontName() const override;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 static HFontRef* GetBaseFontRef(); 164 static HFontRef* GetBaseFontRef();
166 165
167 // Creates and returns a new HFontRef from the specified HFONT. 166 // Creates and returns a new HFontRef from the specified HFONT.
168 static HFontRef* CreateHFontRef(HFONT font); 167 static HFontRef* CreateHFontRef(HFONT font);
169 168
170 // Creates and returns a new HFontRef from the specified HFONT. Uses provided 169 // Creates and returns a new HFontRef from the specified HFONT. Uses provided
171 // |font_metrics| instead of calculating new one. 170 // |font_metrics| instead of calculating new one.
172 static HFontRef* CreateHFontRefFromGDI(HFONT font, 171 static HFontRef* CreateHFontRefFromGDI(HFONT font,
173 const TEXTMETRIC& font_metrics); 172 const TEXTMETRIC& font_metrics);
174 173
175 // Returns a largest derived Font whose height does not exceed the height of
176 // |base_font|.
177 static Font DeriveWithCorrectedSize(HFONT base_font);
178
179 // Creates and returns a new HFontRef from the specified HFONT using metrics 174 // Creates and returns a new HFontRef from the specified HFONT using metrics
180 // from skia. Currently this is only used if we use DirectWrite for font 175 // from skia. Currently this is only used if we use DirectWrite for font
181 // metrics. 176 // metrics.
182 // |gdi_font| : Handle to the GDI font created via CreateFontIndirect. 177 // |gdi_font| : Handle to the GDI font created via CreateFontIndirect.
183 // |font_metrics| : The GDI font metrics retrieved via the GetTextMetrics 178 // |font_metrics| : The GDI font metrics retrieved via the GetTextMetrics
184 // API. This is currently used to calculate the correct height of the font 179 // API. This is currently used to calculate the correct height of the font
185 // in case we get a font created with a positive height. 180 // in case we get a font created with a positive height.
186 // A positive height represents the cell height (ascent + descent). 181 // A positive height represents the cell height (ascent + descent).
187 // A negative height represents the character Em height which is cell 182 // A negative height represents the character Em height which is cell
188 // height minus the internal leading value. 183 // height minus the internal leading value.
189 static PlatformFontWin::HFontRef* CreateHFontRefFromSkia( 184 static PlatformFontWin::HFontRef* CreateHFontRefFromSkia(
190 HFONT gdi_font, 185 HFONT gdi_font,
191 const TEXTMETRIC& font_metrics); 186 const TEXTMETRIC& font_metrics);
192 187
193 // Creates a new PlatformFontWin with the specified HFontRef. Used when 188 // Creates a new PlatformFontWin with the specified HFontRef. Used when
194 // constructing a Font from a HFONT we don't want to copy. 189 // constructing a Font from a HFONT we don't want to copy.
195 explicit PlatformFontWin(HFontRef* hfont_ref); 190 explicit PlatformFontWin(HFontRef* hfont_ref);
196 191
192 // Returns a HFONT with the specified |style| and maximum |height|.
193 // The returned HFONT will be the largest font size with a
msw 2015/01/13 23:54:59 nit: s/HFONT/font/ to fix line wrapping.
ananta 2015/01/14 00:17:23 Removed this function.
194 // height <= |height|, since a size with the exact specified |height| may
195 // not necessarily exist.
196 // GetMinimumFontSize() may impose a font size that is taller than |height|
msw 2015/01/13 23:54:59 nit: trailing period.
ananta 2015/01/14 00:17:23 Removed this function
197 HFONT CreateFontWithHeight(int height, int style);
198
197 // Reference to the base font all fonts are derived from. 199 // Reference to the base font all fonts are derived from.
198 static HFontRef* base_font_ref_; 200 static HFontRef* base_font_ref_;
199 201
200 // Indirect reference to the HFontRef, which references the underlying HFONT. 202 // Indirect reference to the HFontRef, which references the underlying HFONT.
201 scoped_refptr<HFontRef> font_ref_; 203 scoped_refptr<HFontRef> font_ref_;
202 204
203 // Pointer to the global IDWriteFactory interface. 205 // Pointer to the global IDWriteFactory interface.
204 static IDWriteFactory* direct_write_factory_; 206 static IDWriteFactory* direct_write_factory_;
205 207
206 DISALLOW_COPY_AND_ASSIGN(PlatformFontWin); 208 DISALLOW_COPY_AND_ASSIGN(PlatformFontWin);
207 }; 209 };
208 210
209 } // namespace gfx 211 } // namespace gfx
210 212
211 #endif // UI_GFX_PLATFORM_FONT_WIN_H_ 213 #endif // UI_GFX_PLATFORM_FONT_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698