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

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

Issue 19270002: This caused failures in ui_unittests FontListTest.Fonts_GetHeight_GetBaseline (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 5 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
11 #include "base/gtest_prod_util.h"
12 #include "ui/base/ui_export.h" 11 #include "ui/base/ui_export.h"
13 #include "ui/gfx/font.h" 12 #include "ui/gfx/font.h"
14 13
15 namespace gfx { 14 namespace gfx {
16 15
17 // FontList represents a list of fonts either in the form of Font vector or in 16 // FontList represents a list of fonts either in the form of Font vector or in
18 // the form of a string representing font names, styles, and size. 17 // the form of a string representing font names, styles, and size.
19 // 18 //
20 // The string representation is in the form "FAMILY_LIST [STYLE_OPTIONS] SIZE", 19 // The string representation is in the form "FAMILY_LIST [STYLE_OPTIONS] SIZE",
21 // where FAMILY_LIST is a comma separated list of families terminated by a 20 // where FAMILY_LIST is a comma separated list of families terminated by a
(...skipping 29 matching lines...) Expand all
51 50
52 ~FontList(); 51 ~FontList();
53 52
54 // Returns a new FontList with the given |font_style| flags. 53 // Returns a new FontList with the given |font_style| flags.
55 FontList DeriveFontList(int font_style) const; 54 FontList DeriveFontList(int font_style) const;
56 55
57 // Returns a new FontList with the same font names and style but with the 56 // Returns a new FontList with the same font names and style but with the
58 // given font |size| in pixels. 57 // given font |size| in pixels.
59 FontList DeriveFontListWithSize(int size) const; 58 FontList DeriveFontListWithSize(int size) const;
60 59
61 // Returns the height of this font list, which is max(ascent) + max(descent)
62 // for all the fonts in the font list.
63 int GetHeight() const;
64
65 // Returns the baseline of this font list, which is max(baseline) for all the
66 // fonts in the font list.
67 int GetBaseline() const;
68
69 // Returns the |gfx::Font::FontStyle| style flags for this font list. 60 // Returns the |gfx::Font::FontStyle| style flags for this font list.
70 int GetFontStyle() const; 61 int GetFontStyle() const;
71 62
72 // Returns a string representing font names, styles, and size. If the FontList 63 // Returns a string representing font names, styles, and size. If the FontList
73 // is initialized by a vector of Font, use the first font's style and size 64 // is initialized by a vector of Font, use the first font's style and size
74 // for the description. 65 // for the description.
75 const std::string& GetFontDescriptionString() const; 66 const std::string& GetFontDescriptionString() const;
76 67
77 // Returns the Font vector. 68 // Returns the Font vector.
78 const std::vector<Font>& GetFonts() const; 69 const std::vector<Font>& GetFonts() const;
79 70
80 private: 71 private:
81 FRIEND_TEST_ALL_PREFIXES(FontListTest, Fonts_GetHeight_GetBaseline);
82
83 // A vector of Font. If FontList is constructed with font description string, 72 // A vector of Font. If FontList is constructed with font description string,
84 // |fonts_| is not initialized during construction. Instead, it is computed 73 // |fonts_| is not initialized during construction. Instead, it is computed
85 // lazily when user asked to get the font vector. 74 // lazily when user asked to get the font vector.
86 mutable std::vector<Font> fonts_; 75 mutable std::vector<Font> fonts_;
87 76
88 // A string representing font names, styles, and sizes. 77 // A string representing font names, styles, and sizes.
89 // Please refer to the comments before class declaration for details on string 78 // Please refer to the comments before class declaration for details on string
90 // format. 79 // format.
91 // If FontList is constructed with a vector of font, 80 // If FontList is constructed with a vector of font,
92 // |font_description_string_| is not initialized during construction. Instead, 81 // |font_description_string_| is not initialized during construction. Instead,
93 // it is computed lazily when user asked to get the font description string. 82 // it is computed lazily when user asked to get the font description string.
94 mutable std::string font_description_string_; 83 mutable std::string font_description_string_;
95
96 // The cached common height and baseline of the fonts in the font list.
97 mutable int common_height_;
98 mutable int common_baseline_;
99 }; 84 };
100 85
101 } // namespace gfx 86 } // namespace gfx
102 87
103 #endif // UI_GFX_FONT_LIST_H_ 88 #endif // UI_GFX_FONT_LIST_H_
OLDNEW
« no previous file with comments | « trunk/src/build/android/pylib/gtest/filter/ui_unittests_disabled ('k') | trunk/src/ui/gfx/font_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698