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

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

Issue 21868004: Supports FontList::DeriveFontListWithSizeDeltaAndStyle, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
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_FONT_LIST_H_ 5 #ifndef UI_GFX_FONT_LIST_H_
6 #define UI_GFX_FONT_LIST_H_ 6 #define UI_GFX_FONT_LIST_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 23 matching lines...) Expand all
34 // and operator= is used in RenderText::SetFontList(). 34 // and operator= is used in RenderText::SetFontList().
35 class UI_EXPORT FontList { 35 class UI_EXPORT FontList {
36 public: 36 public:
37 // Creates a font list with a Font with default name and style. 37 // Creates a font list with a Font with default name and style.
38 FontList(); 38 FontList();
39 39
40 // Creates a font list from a string representing font names, styles, and 40 // Creates a font list from a string representing font names, styles, and
41 // size. 41 // size.
42 explicit FontList(const std::string& font_description_string); 42 explicit FontList(const std::string& font_description_string);
43 43
44 // Creates a font list from font names, styles and size.
45 FontList(const std::vector<std::string>& font_names,
46 int font_style,
47 int font_size);
48
44 // Creates a font list from a Font vector. 49 // Creates a font list from a Font vector.
45 // All fonts in this vector should have the same style and size. 50 // All fonts in this vector should have the same style and size.
46 explicit FontList(const std::vector<Font>& fonts); 51 explicit FontList(const std::vector<Font>& fonts);
47 52
48 // Creates a font list from a Font. 53 // Creates a font list from a Font.
49 explicit FontList(const Font& font); 54 explicit FontList(const Font& font);
50 55
51 ~FontList(); 56 ~FontList();
52 57
53 // Returns a new FontList with the given |font_style| flags. 58 // Returns a new FontList with the given |font_style| flags.
54 FontList DeriveFontList(int font_style) const; 59 FontList DeriveFontList(int font_style) const;
55 60
56 // Returns a new FontList with the same font names and style but with the 61 // Returns a new FontList with the same font names and style but with the
57 // given font |size| in pixels. 62 // given font |size| in pixels.
58 FontList DeriveFontListWithSize(int size) const; 63 FontList DeriveFontListWithSize(int size) const;
59 64
65 // Returns a new FontList with the same font names and style but with resized.
msw 2013/08/06 05:10:14 nit: s/but with resized/but resized/ (same on line
Yuki 2013/08/07 14:34:03 Done.
66 // |size_delta| is the size in pixels to add to the current font size.
67 FontList DeriveFontListWithSizeDelta(int size_delta) const;
68
69 // Returns a new FontList with the same font names but with resized and
70 // with the given style. |size_delta| is the size in pixels to add to the
71 // current font size. |font_style| specifies the new style, which is a
72 // bitmask of the values: Font::BOLD, Font::ITALIC and Font::UNDERLINE.
73 FontList DeriveFontListWithSizeDeltaAndStyle(int size_delta,
74 int font_style) const;
75
60 // Returns the height of this font list, which is max(ascent) + max(descent) 76 // Returns the height of this font list, which is max(ascent) + max(descent)
61 // for all the fonts in the font list. 77 // for all the fonts in the font list.
62 int GetHeight() const; 78 int GetHeight() const;
63 79
64 // Returns the baseline of this font list, which is max(baseline) for all the 80 // Returns the baseline of this font list, which is max(baseline) for all the
65 // fonts in the font list. 81 // fonts in the font list.
66 int GetBaseline() const; 82 int GetBaseline() const;
67 83
84 // Returns the average character width for the font list.
85 int GetAverageCharacterWidth() const;
86
87 // Returns the number of horizontal pixels needed to display the specified
msw 2013/08/06 05:10:14 nit: s/the specified string/|text|/
Yuki 2013/08/07 14:34:03 Done.
88 // string.
89 int GetStringWidth(const base::string16& text) const;
90
91 // Returns the expected number of horizontal pixels needed to display the
92 // specified length of characters. Call GetStringWidth() to retrieve the
93 // actual number.
94 int GetExpectedTextWidth(int length) const;
msw 2013/08/06 05:10:14 Is this necessary? It doesn't seem to be used in y
Yuki 2013/08/07 14:34:03 As we discussed, I removed GetAverageCharacterWidt
95
68 // Returns the |gfx::Font::FontStyle| style flags for this font list. 96 // Returns the |gfx::Font::FontStyle| style flags for this font list.
69 int GetFontStyle() const; 97 int GetFontStyle() const;
70 98
71 // Returns a string representing font names, styles, and size. If the FontList 99 // Returns a string representing font names, styles, and size. If the FontList
72 // is initialized by a vector of Font, use the first font's style and size 100 // is initialized by a vector of Font, use the first font's style and size
73 // for the description. 101 // for the description.
74 const std::string& GetFontDescriptionString() const; 102 const std::string& GetFontDescriptionString() const;
75 103
76 // Returns the font size in pixels. 104 // Returns the font size in pixels.
77 int GetFontSize() const; 105 int GetFontSize() const;
(...skipping 14 matching lines...) Expand all
92 // Please refer to the comments before class declaration for details on string 120 // Please refer to the comments before class declaration for details on string
93 // format. 121 // format.
94 // If FontList is constructed with a vector of font, 122 // If FontList is constructed with a vector of font,
95 // |font_description_string_| is not initialized during construction. Instead, 123 // |font_description_string_| is not initialized during construction. Instead,
96 // it is computed lazily when user asked to get the font description string. 124 // it is computed lazily when user asked to get the font description string.
97 mutable std::string font_description_string_; 125 mutable std::string font_description_string_;
98 126
99 // The cached common height and baseline of the fonts in the font list. 127 // The cached common height and baseline of the fonts in the font list.
100 mutable int common_height_; 128 mutable int common_height_;
101 mutable int common_baseline_; 129 mutable int common_baseline_;
130
131 // Cached font style and size.
132 mutable int font_style_;
133 mutable int font_size_;
102 }; 134 };
103 135
104 } // namespace gfx 136 } // namespace gfx
105 137
106 #endif // UI_GFX_FONT_LIST_H_ 138 #endif // UI_GFX_FONT_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698