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

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

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Alexei's issues Created 4 years, 8 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // performed other than clamping to a minimum font height if 43 // performed other than clamping to a minimum font height if
44 // |get_minimum_font_size_callback| is specified. 44 // |get_minimum_font_size_callback| is specified.
45 typedef void (*AdjustFontCallback)(LOGFONT* lf); 45 typedef void (*AdjustFontCallback)(LOGFONT* lf);
46 static AdjustFontCallback adjust_font_callback; 46 static AdjustFontCallback adjust_font_callback;
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|.
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.
56 // GetMinimumFontSize() may impose a font size that is taller than |height|.
57 Font DeriveFontWithHeight(int height, int style);
58
59 // Overridden from PlatformFont: 53 // Overridden from PlatformFont:
60 Font DeriveFont(int size_delta, int style) const override; 54 Font DeriveFont(int size_delta,
55 int style,
56 gfx::Font::Weight weight) const override;
Alexei Svitkine (slow) 2016/04/05 16:38:52 Remove gfx::
61 int GetHeight() override; 57 int GetHeight() override;
58 gfx::Font::Weight GetWeight() const override;
Alexei Svitkine (slow) 2016/04/05 16:38:52 Remove gfx::
62 int GetBaseline() override; 59 int GetBaseline() override;
63 int GetCapHeight() override; 60 int GetCapHeight() override;
64 int GetExpectedTextWidth(int length) override; 61 int GetExpectedTextWidth(int length) override;
65 int GetStyle() const override; 62 int GetStyle() const override;
66 const std::string& GetFontName() const override; 63 const std::string& GetFontName() const override;
67 std::string GetActualFontNameForTesting() const override; 64 std::string GetActualFontNameForTesting() const override;
68 int GetFontSize() const override; 65 int GetFontSize() const override;
69 const FontRenderParams& GetFontRenderParams() override; 66 const FontRenderParams& GetFontRenderParams() override;
70 NativeFont GetNativeFont() const override; 67 NativeFont GetNativeFont() const override;
71 68
(...skipping 27 matching lines...) Expand all
99 class GFX_EXPORT HFontRef : public base::RefCounted<HFontRef> { 96 class GFX_EXPORT HFontRef : public base::RefCounted<HFontRef> {
100 public: 97 public:
101 // This constructor takes control of the HFONT, and will delete it when 98 // This constructor takes control of the HFONT, and will delete it when
102 // the HFontRef is deleted. 99 // the HFontRef is deleted.
103 HFontRef(HFONT hfont, 100 HFontRef(HFONT hfont,
104 int font_size, 101 int font_size,
105 int height, 102 int height,
106 int baseline, 103 int baseline,
107 int cap_height, 104 int cap_height,
108 int ave_char_width, 105 int ave_char_width,
106 gfx::Font::Weight weight,
Alexei Svitkine (slow) 2016/04/05 16:38:52 Remove gfx::
109 int style); 107 int style);
110 108
111 // Accessors 109 // Accessors
112 HFONT hfont() const { return hfont_; } 110 HFONT hfont() const { return hfont_; }
113 int height() const { return height_; } 111 int height() const { return height_; }
114 int baseline() const { return baseline_; } 112 int baseline() const { return baseline_; }
115 int cap_height() const { return cap_height_; } 113 int cap_height() const { return cap_height_; }
116 int ave_char_width() const { return ave_char_width_; } 114 int ave_char_width() const { return ave_char_width_; }
115 gfx::Font::Weight weight() const { return weight_; }
Alexei Svitkine (slow) 2016/04/05 16:38:52 Remove gfx::
117 int style() const { return style_; } 116 int style() const { return style_; }
118 const std::string& font_name() const { return font_name_; } 117 const std::string& font_name() const { return font_name_; }
119 int font_size() const { return font_size_; } 118 int font_size() const { return font_size_; }
120 int requested_font_size() const { return requested_font_size_; } 119 int requested_font_size() const { return requested_font_size_; }
121 120
122 // Returns the average character width in dialog units. 121 // Returns the average character width in dialog units.
123 int GetDluBaseX(); 122 int GetDluBaseX();
124 123
125 // Helper to return the average character width using the text extent 124 // Helper to return the average character width using the text extent
126 // technique mentioned here. http://support.microsoft.com/kb/125681. 125 // technique mentioned here. http://support.microsoft.com/kb/125681.
127 static int GetAverageCharWidthInDialogUnits(HFONT gdi_font); 126 static int GetAverageCharWidthInDialogUnits(HFONT gdi_font);
128 127
129 private: 128 private:
130 friend class base::RefCounted<HFontRef>; 129 friend class base::RefCounted<HFontRef>;
131 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback); 130 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback);
132 FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, Metrics_SkiaVersusGDI); 131 FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, Metrics_SkiaVersusGDI);
133 FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, DirectWriteFontSubstitution); 132 FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, DirectWriteFontSubstitution);
134 133
135 ~HFontRef(); 134 ~HFontRef();
136 135
137 const HFONT hfont_; 136 const HFONT hfont_;
138 const int font_size_; 137 const int font_size_;
139 const int height_; 138 const int height_;
140 const int baseline_; 139 const int baseline_;
141 const int cap_height_; 140 const int cap_height_;
142 const int ave_char_width_; 141 const int ave_char_width_;
142 const gfx::Font::Weight weight_;
Alexei Svitkine (slow) 2016/04/05 16:38:52 Remove gfx::
143 const int style_; 143 const int style_;
144 // Average character width in dialog units. This is queried lazily from the 144 // 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. 145 // system, with an initial value of -1 meaning it hasn't yet been queried.
146 int dlu_base_x_; 146 int dlu_base_x_;
147 std::string font_name_; 147 std::string font_name_;
148 148
149 // If the requested font size is not possible for the font, |font_size_| 149 // 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 150 // 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 151 // so that code that increases the font size in a loop will not cause the
152 // loop to get stuck on the same size. 152 // loop to get stuck on the same size.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 // Pointer to the global IDWriteFactory interface. 201 // Pointer to the global IDWriteFactory interface.
202 static IDWriteFactory* direct_write_factory_; 202 static IDWriteFactory* direct_write_factory_;
203 203
204 DISALLOW_COPY_AND_ASSIGN(PlatformFontWin); 204 DISALLOW_COPY_AND_ASSIGN(PlatformFontWin);
205 }; 205 };
206 206
207 } // namespace gfx 207 } // namespace gfx
208 208
209 #endif // UI_GFX_PLATFORM_FONT_WIN_H_ 209 #endif // UI_GFX_PLATFORM_FONT_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698