-// The default instance of gfx::FontList, whose metrics are pre-calculated.
-// The default ctor of gfx::FontList copies the metrics so it won't need to
-// scan the whole font list to calculate the metrics.
-const gfx::FontList* g_default_font_list = NULL;
-
-// Parses font description into |font_names|, |font_style| and |font_size|.
-void ParseFontDescriptionString(const std::string& font_description_string,
- std::vector<std::string>* font_names,
- int* font_style,
- int* font_size) {
- base::SplitString(font_description_string, ',', font_names);
- DCHECK_GT(font_names->size(), 1U);
-
- // The last item is [STYLE_OPTIONS] SIZE.
- std::vector<std::string> styles_size;
- base::SplitString(font_names->back(), ' ', &styles_size);
- DCHECK(!styles_size.empty());
- base::StringToInt(styles_size.back(), font_size);
- DCHECK_GT(*font_size, 0);
- font_names->pop_back();
-
- // Font supports BOLD and ITALIC; underline is supported via RenderText.
- *font_style = 0;
- for (size_t i = 0; i < styles_size.size() - 1; ++i) {
- // Styles are separated by white spaces. base::SplitString splits styles
- // by space, and it inserts empty string for continuous spaces.
- if (styles_size[i].empty())
- continue;
- if (!styles_size[i].compare("Bold"))
- *font_style |= gfx::Font::BOLD;
- else if (!styles_size[i].compare("Italic"))
- *font_style |= gfx::Font::ITALIC;
- else
- NOTREACHED();
- }
-}
-
-// Returns the font style and size as a string.
-std::string FontStyleAndSizeToString(int font_style, int font_size) {
- std::string result;
- if (font_style & gfx::Font::BOLD)
- result += "Bold ";
- if (font_style & gfx::Font::ITALIC)
- result += "Italic ";
- result += base::IntToString(font_size);
- result += "px";
- return result;
-}
-
-// Returns font description from |font_names|, |font_style|, and |font_size|.
-std::string BuildFontDescription(const std::vector<std::string>& font_names,
- int font_style,
- int font_size) {
- std::string description = JoinString(font_names, ',');
- description += "," + FontStyleAndSizeToString(font_style, font_size);
- return description;
-}