Disable flaky test ExtensionActionContextMenuTest.RunInspectPopup
[chromium-blink-merge.git] / ui / gfx / font_list.h
blobd070b5b588c2f63f834bc31c0f3dbac15f14d72e
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
3 // found in the LICENSE file.
5 #ifndef UI_GFX_FONT_LIST_H_
6 #define UI_GFX_FONT_LIST_H_
8 #include <string>
9 #include <vector>
11 #include "ui/base/ui_export.h"
12 #include "ui/gfx/font.h"
14 namespace gfx {
16 // FontList represents a list of fonts either in the form of Font vector or in
17 // the form of a string representing font names, styles, and size.
19 // The string representation is in the form "FAMILY_LIST [STYLE_OPTIONS] SIZE",
20 // where FAMILY_LIST is a comma separated list of families terminated by a
21 // comma, STYLE_OPTIONS is a whitespace separated list of words where each word
22 // describes one of style, variant, weight, stretch, or gravity, and SIZE is
23 // a decimal number followed by "px" for absolute size. STYLE_OPTIONS may be
24 // absent.
26 // The string format complies with that of Pango detailed at
27 // http://developer.gnome.org/pango/stable/pango-Fonts.html#pango-font-description-from-string
29 // FontList could be initialized either way without conversion to the other
30 // form. The conversion to the other form is done only when asked to get the
31 // other form.
33 // FontList allows operator= since FontList is a data member type in RenderText,
34 // and operator= is used in RenderText::SetFontList().
35 class UI_EXPORT FontList {
36 public:
37 // Creates a font list with a Font with default name and style.
38 FontList();
40 // Creates a font list from a string representing font names, styles, and
41 // size.
42 explicit FontList(const std::string& font_description_string);
44 // Creates a font list from a Font vector.
45 // All fonts in this vector should have the same style and size.
46 explicit FontList(const std::vector<Font>& fonts);
48 // Creates a font list from a Font.
49 explicit FontList(const Font& font);
51 ~FontList();
53 // Returns a new FontList with the given |font_style| flags.
54 FontList DeriveFontList(int font_style) const;
56 // Returns a new FontList with the same font names and style but with the
57 // given font |size| in pixels.
58 FontList DeriveFontListWithSize(int size) const;
60 // Returns the |gfx::Font::FontStyle| style flags for this font list.
61 int GetFontStyle() const;
63 // Returns a string representing font names, styles, and size. If the FontList
64 // is initialized by a vector of Font, use the first font's style and size
65 // for the description.
66 const std::string& GetFontDescriptionString() const;
68 // Returns the Font vector.
69 const std::vector<Font>& GetFonts() const;
71 private:
72 // A vector of Font. If FontList is constructed with font description string,
73 // |fonts_| is not initialized during construction. Instead, it is computed
74 // lazily when user asked to get the font vector.
75 mutable std::vector<Font> fonts_;
77 // A string representing font names, styles, and sizes.
78 // Please refer to the comments before class declaration for details on string
79 // format.
80 // If FontList is constructed with a vector of font,
81 // |font_description_string_| is not initialized during construction. Instead,
82 // it is computed lazily when user asked to get the font description string.
83 mutable std::string font_description_string_;
86 } // namespace gfx
88 #endif // UI_GFX_FONT_LIST_H_