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

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

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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_H_ 5 #ifndef UI_GFX_PLATFORM_FONT_H_
6 #define UI_GFX_PLATFORM_FONT_H_ 6 #define UI_GFX_PLATFORM_FONT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "ui/gfx/font.h"
13 #include "ui/gfx/gfx_export.h" 14 #include "ui/gfx/gfx_export.h"
14 #include "ui/gfx/native_widget_types.h" 15 #include "ui/gfx/native_widget_types.h"
15 16
16 namespace gfx { 17 namespace gfx {
17 18
18 class Font; 19 class Font;
19 struct FontRenderParams; 20 struct FontRenderParams;
20 21
21 class GFX_EXPORT PlatformFont : public base::RefCounted<PlatformFont> { 22 class GFX_EXPORT PlatformFont : public base::RefCounted<PlatformFont> {
22 public: 23 public:
23 // Creates an appropriate PlatformFont implementation. 24 // Creates an appropriate PlatformFont implementation.
24 static PlatformFont* CreateDefault(); 25 static PlatformFont* CreateDefault();
25 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_IOS) 26 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_IOS)
26 static PlatformFont* CreateFromNativeFont(NativeFont native_font); 27 static PlatformFont* CreateFromNativeFont(NativeFont native_font);
27 #endif 28 #endif
28 // Creates a PlatformFont implementation with the specified |font_name| 29 // Creates a PlatformFont implementation with the specified |font_name|
29 // (encoded in UTF-8) and |font_size| in pixels. 30 // (encoded in UTF-8) and |font_size| in pixels.
30 static PlatformFont* CreateFromNameAndSize(const std::string& font_name, 31 static PlatformFont* CreateFromNameAndSize(const std::string& font_name,
31 int font_size); 32 int font_size);
32 33
33 // Returns a new Font derived from the existing font. 34 // Returns a new Font derived from the existing font.
34 // |size_delta| is the size in pixels to add to the current font. 35 // |size_delta| is the size in pixels to add to the current font.
35 // The style parameter specifies the new style for the font, and is a 36 // The style parameter specifies the new style for the font, and is a
36 // bitmask of the values: BOLD, ITALIC and UNDERLINE. 37 // bitmask of the values: ITALIC and UNDERLINE.
37 virtual Font DeriveFont(int size_delta, int style) const = 0; 38 // The weight parameter specifies the desired weight of the font.
39 virtual Font DeriveFont(int size_delta,
40 int style,
41 gfx::Font::FontWeight weight) const = 0;
38 42
39 // Returns the number of vertical pixels needed to display characters from 43 // Returns the number of vertical pixels needed to display characters from
40 // the specified font. This may include some leading, i.e. height may be 44 // the specified font. This may include some leading, i.e. height may be
41 // greater than just ascent + descent. Specifically, the Windows and Mac 45 // greater than just ascent + descent. Specifically, the Windows and Mac
42 // implementations include leading and the Linux one does not. This may 46 // implementations include leading and the Linux one does not. This may
43 // need to be revisited in the future. 47 // need to be revisited in the future.
44 virtual int GetHeight() = 0; 48 virtual int GetHeight() = 0;
45 49
50 // Returns the font weight.
51 virtual gfx::Font::FontWeight GetWeight() = 0;
tapted 2016/03/22 04:04:17 You'll need a PlatformFontMac change for this too
msw 2016/03/22 18:24:10 Ping! Please address this comment.
Mikus 2016/03/23 17:53:21 Done.
52
46 // Returns the baseline, or ascent, of the font. 53 // Returns the baseline, or ascent, of the font.
47 virtual int GetBaseline() = 0; 54 virtual int GetBaseline() = 0;
48 55
49 // Returns the cap height of the font. 56 // Returns the cap height of the font.
50 virtual int GetCapHeight() = 0; 57 virtual int GetCapHeight() = 0;
51 58
52 // Returns the expected number of horizontal pixels needed to display the 59 // Returns the expected number of horizontal pixels needed to display the
53 // specified length of characters. Call GetStringWidth() to retrieve the 60 // specified length of characters. Call GetStringWidth() to retrieve the
54 // actual number. 61 // actual number.
55 virtual int GetExpectedTextWidth(int length) = 0; 62 virtual int GetExpectedTextWidth(int length) = 0;
(...skipping 21 matching lines...) Expand all
77 protected: 84 protected:
78 virtual ~PlatformFont() {} 85 virtual ~PlatformFont() {}
79 86
80 private: 87 private:
81 friend class base::RefCounted<PlatformFont>; 88 friend class base::RefCounted<PlatformFont>;
82 }; 89 };
83 90
84 } // namespace gfx 91 } // namespace gfx
85 92
86 #endif // UI_GFX_PLATFORM_FONT_H_ 93 #endif // UI_GFX_PLATFORM_FONT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698