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

Side by Side Diff: ui/gfx/font_list_impl.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_FONT_LIST_IMPL_H_ 5 #ifndef UI_GFX_FONT_LIST_IMPL_H_
6 #define UI_GFX_FONT_LIST_IMPL_H_ 6 #define UI_GFX_FONT_LIST_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "ui/gfx/font.h"
12 13
13 namespace gfx { 14 namespace gfx {
14 15
15 class Font; 16 class Font;
tapted 2016/03/22 04:04:17 nit: this is redundant now
Mikus 2016/03/22 14:19:51 Done.
16 17
17 // FontListImpl is designed to provide the implementation of FontList and 18 // FontListImpl is designed to provide the implementation of FontList and
18 // intended to be used only from FontList. You must not use this class 19 // intended to be used only from FontList. You must not use this class
19 // directly. 20 // directly.
20 // 21 //
21 // FontListImpl represents a list of fonts either in the form of Font vector or 22 // FontListImpl represents a list of fonts either in the form of Font vector or
22 // in the form of a string representing font names, styles, and size. 23 // in the form of a string representing font names, styles, and size.
23 // 24 //
24 // FontListImpl could be initialized either way without conversion to the other 25 // FontListImpl could be initialized either way without conversion to the other
25 // form. The conversion to the other form is done only when asked to get the 26 // form. The conversion to the other form is done only when asked to get the
26 // other form. 27 // other form.
27 // 28 //
28 // For the format of font description string, see font_list.h for details. 29 // For the format of font description string, see font_list.h for details.
29 class FontListImpl : public base::RefCounted<FontListImpl> { 30 class FontListImpl : public base::RefCounted<FontListImpl> {
30 public: 31 public:
31 // Creates a font list from a string representing font names, styles, and 32 // Creates a font list from a string representing font names, styles, and
32 // size. 33 // size.
33 explicit FontListImpl(const std::string& font_description_string); 34 explicit FontListImpl(const std::string& font_description_string);
34 35
35 // Creates a font list from font names, styles and size. 36 // Creates a font list from font names, styles, size and weight.
36 FontListImpl(const std::vector<std::string>& font_names, 37 FontListImpl(const std::vector<std::string>& font_names,
37 int font_style, 38 int font_style,
38 int font_size); 39 int font_size,
40 int font_weight);
39 41
40 // Creates a font list from a Font vector. 42 // Creates a font list from a Font vector.
41 // All fonts in this vector should have the same style and size. 43 // All fonts in this vector should have the same style and size.
42 explicit FontListImpl(const std::vector<Font>& fonts); 44 explicit FontListImpl(const std::vector<Font>& fonts);
43 45
44 // Creates a font list from a Font. 46 // Creates a font list from a Font.
45 explicit FontListImpl(const Font& font); 47 explicit FontListImpl(const Font& font);
46 48
47 // Returns a new FontListImpl with the same font names but resized and the 49 // Returns a new FontListImpl with the same font names but resized and the
msw 2016/03/22 01:53:43 ditto nit: "and with the given style and weight."
48 // given style. |size_delta| is the size in pixels to add to the current font 50 // given style. |size_delta| is the size in pixels to add to the current font
49 // size. |font_style| specifies the new style, which is a bitmask of the 51 // size. |font_style| specifies the new style, which is a bitmask of the
50 // values: Font::BOLD, Font::ITALIC and Font::UNDERLINE. 52 // values: Font::ITALIC and Font::UNDERLINE.
51 FontListImpl* Derive(int size_delta, int font_style) const; 53 FontListImpl* Derive(int size_delta,
54 int font_style,
55 gfx::Font::FontWeight weight) const;
52 56
53 // Returns the height of this font list, which is max(ascent) + max(descent) 57 // Returns the height of this font list, which is max(ascent) + max(descent)
54 // for all the fonts in the font list. 58 // for all the fonts in the font list.
55 int GetHeight() const; 59 int GetHeight() const;
56 60
57 // Returns the baseline of this font list, which is max(baseline) for all the 61 // Returns the baseline of this font list, which is max(baseline) for all the
58 // fonts in the font list. 62 // fonts in the font list.
59 int GetBaseline() const; 63 int GetBaseline() const;
60 64
61 // Returns the cap height of this font list. 65 // Returns the cap height of this font list.
62 // Currently returns the cap height of the primary font. 66 // Currently returns the cap height of the primary font.
63 int GetCapHeight() const; 67 int GetCapHeight() const;
64 68
65 // Returns the expected number of horizontal pixels needed to display the 69 // Returns the expected number of horizontal pixels needed to display the
66 // specified length of characters. Call GetStringWidth() to retrieve the 70 // specified length of characters. Call GetStringWidth() to retrieve the
67 // actual number. 71 // actual number.
68 int GetExpectedTextWidth(int length) const; 72 int GetExpectedTextWidth(int length) const;
69 73
70 // Returns the |gfx::Font::FontStyle| style flags for this font list. 74 // Returns the |gfx::Font::FontStyle| style flags for this font list.
71 int GetFontStyle() const; 75 int GetFontStyle() const;
72 76
73 // Returns the font size in pixels. 77 // Returns the font size in pixels.
74 int GetFontSize() const; 78 int GetFontSize() const;
75 79
80 // Returns the font weight.
81 gfx::Font::FontWeight GetFontWeight() const;
82
76 // Returns the Font vector. 83 // Returns the Font vector.
77 const std::vector<Font>& GetFonts() const; 84 const std::vector<Font>& GetFonts() const;
78 85
79 // Returns the first font in the list. 86 // Returns the first font in the list.
80 const Font& GetPrimaryFont() const; 87 const Font& GetPrimaryFont() const;
81 88
82 private: 89 private:
83 friend class base::RefCounted<FontListImpl>; 90 friend class base::RefCounted<FontListImpl>;
84 91
85 ~FontListImpl(); 92 ~FontListImpl();
(...skipping 20 matching lines...) Expand all
106 // TODO(derat): Remove laziness so that this can be removed. 113 // TODO(derat): Remove laziness so that this can be removed.
107 mutable std::string font_description_string_; 114 mutable std::string font_description_string_;
108 115
109 // The cached common height and baseline of the fonts in the font list. 116 // The cached common height and baseline of the fonts in the font list.
110 mutable int common_height_; 117 mutable int common_height_;
111 mutable int common_baseline_; 118 mutable int common_baseline_;
112 119
113 // Cached font style and size. 120 // Cached font style and size.
114 mutable int font_style_; 121 mutable int font_style_;
115 mutable int font_size_; 122 mutable int font_size_;
123 mutable gfx::Font::FontWeight font_weight_;
116 }; 124 };
117 125
118 } // namespace gfx 126 } // namespace gfx
119 127
120 #endif // UI_GFX_FONT_LIST_IMPL_H_ 128 #endif // UI_GFX_FONT_LIST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698