diff options
author | xji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-19 04:09:01 +0000 |
---|---|---|
committer | xji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-19 04:09:01 +0000 |
commit | 732ef6737ef6e1346255be7230032dcaf4e9ad03 (patch) | |
tree | c9663673eba42c9f33c413a909c16a37d7bd2ebb /ui/gfx/font_list.h | |
parent | 963c1b96abd9baa3ccddb7bc59da8a93e0c2ae93 (diff) | |
download | chromium_src-732ef6737ef6e1346255be7230032dcaf4e9ad03.zip chromium_src-732ef6737ef6e1346255be7230032dcaf4e9ad03.tar.gz chromium_src-732ef6737ef6e1346255be7230032dcaf4e9ad03.tar.bz2 |
specify locale-dependent font list for UI on ChromeOS, so that those fonts have higher priority over the fallback fonts Pango picks up.
BUG=103860
TEST=build aura, start chromium in 'ar' locale. type in Arabic and check the Arabic text's shapes. remove IDS_UI_FONT_FAMILY_CROS from 'ar' resource file, build aura again, start chromium in 'ar', type in Arabic and the Arabic text's shapes should be different.
Review URL: http://codereview.chromium.org/8770034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/font_list.h')
-rw-r--r-- | ui/gfx/font_list.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/ui/gfx/font_list.h b/ui/gfx/font_list.h new file mode 100644 index 0000000..ef6b357 --- /dev/null +++ b/ui/gfx/font_list.h @@ -0,0 +1,79 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_GFX_FONT_LIST_H_ +#define UI_GFX_FONT_LIST_H_ +#pragma once + +#include <string> +#include <vector> + +#include "base/gtest_prod_util.h" +#include "ui/base/ui_export.h" +#include "ui/gfx/font.h" + +namespace gfx { + +// FontList represents a list of fonts either in the form of Font vector or in +// the form of a string representing font names, styles, and size. +// +// The string representation is in the form "FAMILY_LIST [STYLE_OPTIONS] SIZE", +// where FAMILY_LIST is a comma separated list of families terminated by a +// comma, STYLE_OPTIONS is a whitespace separated list of words where each word +// describes one of style, variant, weight, stretch, or gravity, and SIZE is +// a decimal number (size in points). STYLE_OPTIONS may be absent. +// +// The string format complies with that of Pango detailed at +// http://developer.gnome.org/pango/stable/pango-Fonts.html#pango-font-description-from-string +// +// FontList could be initialized either way without conversion to the other +// form. The conversion to the other form is done only when asked to get the +// other form. +// +// FontList allows operator= since FontList is a data member type in RenderText, +// and operator= is used in RenderText::SetFontList(). +class UI_EXPORT FontList { + public: + // Creates a font list with a Font with default name and style. + FontList(); + + // Creates a font list from a string representing font names, styles, and + // size. + explicit FontList(const std::string& font_description_string); + + // Creates a font list from a Font vector. + // All fonts in this vector should have the same style and size. + explicit FontList(const std::vector<Font>& fonts); + + // Creates a font list from a Font. + explicit FontList(const Font& font); + + ~FontList(); + + // Returns a string representing font names, styles, and size. If the FontList + // is initialized by a vector of Font, use the first font's style and size + // for the description. + const std::string& GetFontDescriptionString() const; + + // Returns the Font vector. + const std::vector<Font>& GetFonts() const; + + private: + // A vector of Font. If FontList is constructed with font description string, + // |fonts_| is not initialized during construction. Instead, it is computed + // lazily when user asked to get the font vector. + mutable std::vector<Font> fonts_; + + // A string representing font names, styles, and sizes. + // Please refer to the comments before class declaration for details on string + // format. + // If FontList is constructed with a vector of font, + // |font_description_string_| is not initialized during construction. Instead, + // it is computed lazily when user asked to get the font description string. + mutable std::string font_description_string_; +}; + +} // namespace gfx + +#endif // UI_GFX_FONT_LIST_H_ |