diff options
author | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-20 20:53:29 +0000 |
---|---|---|
committer | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-20 20:53:29 +0000 |
commit | 2bb1b7efb0d745599287ba2807e6413b88025ba1 (patch) | |
tree | 9ca6cdf8794d14e1569a6a51fadd563d93044275 /ui/gfx/font_list.cc | |
parent | 79fcd382548808dcab8f58e736d4608bbed6c828 (diff) | |
download | chromium_src-2bb1b7efb0d745599287ba2807e6413b88025ba1.zip chromium_src-2bb1b7efb0d745599287ba2807e6413b88025ba1.tar.gz chromium_src-2bb1b7efb0d745599287ba2807e6413b88025ba1.tar.bz2 |
Revert 114953 (breaks cros font sizes, etc.) - 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
TBR=xji@chromium.org
Review URL: http://codereview.chromium.org/9007028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115179 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/font_list.cc')
-rw-r--r-- | ui/gfx/font_list.cc | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/ui/gfx/font_list.cc b/ui/gfx/font_list.cc deleted file mode 100644 index a6c0867..0000000 --- a/ui/gfx/font_list.cc +++ /dev/null @@ -1,115 +0,0 @@ -// 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. - -#include <stdlib.h> - -#include "base/logging.h" -#include "base/string_number_conversions.h" -#include "base/string_split.h" -#include "ui/gfx/font_list.h" - -namespace gfx { - -FontList::FontList() { - fonts_.push_back(Font()); -} - -FontList::FontList(const std::string& font_description_string) - : font_description_string_(font_description_string) { - DCHECK(!font_description_string.empty()); -} - -FontList::FontList(const std::vector<Font>& fonts) - : fonts_(fonts) { - DCHECK(!fonts.empty()); - if (DCHECK_IS_ON()) { - int style = fonts[0].GetStyle(); - int size = fonts[0].GetFontSize(); - for (size_t i = 1; i < fonts.size(); ++i) { - DCHECK_EQ(fonts[i].GetStyle(), style); - DCHECK_EQ(fonts[i].GetFontSize(), size); - } - } -} - -FontList::FontList(const Font& font) { - fonts_.push_back(font); -} - -FontList::~FontList() { -} - -const std::string& FontList::GetFontDescriptionString() const { - if (font_description_string_.empty()) { - DCHECK(!fonts_.empty()); - for (size_t i = 0; i < fonts_.size(); ++i) { - std::string name = fonts_[i].GetFontName(); - font_description_string_ += name; - font_description_string_ += ','; - } - // All fonts have the same style and size. - // TODO(xji): add style for Windows. -#if defined(OS_LINUX) - int style = fonts_[0].GetStyle(); - if (style & Font::BOLD) - font_description_string_ += "PANGO_WEIGHT_BOLD "; - if (style & Font::ITALIC) - font_description_string_ += "PANGO_STYLE_ITALIC "; -#endif - int size = fonts_[0].GetFontSize(); - font_description_string_ += base::IntToString(size); - } - return font_description_string_; -} - -const std::vector<Font>& FontList::GetFonts() const { - if (fonts_.empty()) { - DCHECK(!font_description_string_.empty()); - - std::vector<std::string> name_style_size; - base::SplitString(font_description_string_, ',', &name_style_size); - int item_count = static_cast<int>(name_style_size.size()); - DCHECK_GT(item_count, 1); - - // The last item is [STYLE_OPTIONS] SIZE. - std::vector<std::string> styles_size; - base::SplitString(name_style_size[item_count - 1], ' ', &styles_size); - int size; - DCHECK(!styles_size.empty()); - base::StringToInt(styles_size[styles_size.size() - 1], &size); - DCHECK_GT(size, 0); - - int style = 0; - // TODO(xji): parse style for Windows. -#if defined(OS_LINUX) - // Besides underline (which is supported through StyleRange), Font only - // supports BOLD and ITALIC styles, not other Pango styles. - 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("PANGO_WEIGHT_BOLD")) - style |= Font::BOLD; - else if (!styles_size[i].compare("PANGO_STYLE_ITALIC")) - style |= Font::ITALIC; - else - NOTREACHED(); - } -#endif - - for (int i = 0; i < item_count - 1; ++i) { - DCHECK(!name_style_size[i].empty()); - - Font font(name_style_size[i], size); - if (style == Font::NORMAL) - fonts_.push_back(font); - else - fonts_.push_back(font.DeriveFont(0, style)); - } - } - return fonts_; -} - -} // namespace gfx |