diff options
author | binji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-09 23:21:11 +0000 |
---|---|---|
committer | binji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-09 23:21:11 +0000 |
commit | 4909ecaf28e4b3bbc6171814548cf51e249ad45a (patch) | |
tree | 9b5220653638c509a1cece937d817578455bf174 /ui/gfx/render_text.cc | |
parent | 106b09d97d773b9c0fff77ce2b44f32f43cad34c (diff) | |
download | chromium_src-4909ecaf28e4b3bbc6171814548cf51e249ad45a.zip chromium_src-4909ecaf28e4b3bbc6171814548cf51e249ad45a.tar.gz chromium_src-4909ecaf28e4b3bbc6171814548cf51e249ad45a.tar.bz2 |
Revert 116945 - Enable bold and italic text styles in RenderText*.
To do this, the following changes were made:
Added functions GetStyle() and DeriveFontList(style) to FontList. Changed font list to use strings "Bold" and "Italic" instead of PANGO_STYLE_ITALIC and PANGO_WEIGHT_BOLD - where were actually compile constants for setting attributes and weren't recognized by Pango in a font string. (Whereas "Bold" and "Italic" are recognized).
Add RenderText test that checks that the width of a bold string > the width of a non-bold string.
Add FontList tests for the new functions.
BUG=107893
TEST=Run views_examples_exe "Text Styles" examples and try bold and italic styles (this depends on an unreleased CL). Also, new tests in FontListTest and RenderTextTest.
Review URL: http://codereview.chromium.org/8963027
TBR=asvitkine@chromium.org
Review URL: http://codereview.chromium.org/9147016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116948 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/render_text.cc')
-rw-r--r-- | ui/gfx/render_text.cc | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc index 4695245..d058501 100644 --- a/ui/gfx/render_text.cc +++ b/ui/gfx/render_text.cc @@ -77,16 +77,6 @@ void ApplyStyleRangeImpl(gfx::StyleRanges* style_ranges, style_ranges->insert(i, style_range); } -// Converts |gfx::Font::FontStyle| flags to |SkTypeface::Style| flags. -SkTypeface::Style ConvertFontStyleToSkiaTypefaceStyle(int font_style) { - int skia_style = SkTypeface::kNormal; - if (font_style & gfx::Font::BOLD) - skia_style |= SkTypeface::kBold; - if (font_style & gfx::Font::ITALIC) - skia_style |= SkTypeface::kItalic; - return static_cast<SkTypeface::Style>(skia_style); -} - } // namespace namespace gfx { @@ -114,26 +104,10 @@ void SkiaTextRenderer::SetTextSize(int size) { paint_.setTextSize(size); } -void SkiaTextRenderer::SetFontStyle(int style) { - SkTypeface::Style skia_style = ConvertFontStyleToSkiaTypefaceStyle(style); - SkTypeface* current_typeface = paint_.getTypeface(); - - if (current_typeface->style() == skia_style) - return; - - SkAutoTUnref<SkTypeface> typeface( - SkTypeface::CreateFromTypeface(current_typeface, skia_style)); - if (typeface.get()) { - // |paint_| adds its own ref. So don't |release()| it from the ref ptr here. - SetTypeface(typeface.get()); - } -} - void SkiaTextRenderer::SetFont(const gfx::Font& font) { - SkTypeface::Style skia_style = - ConvertFontStyleToSkiaTypefaceStyle(font.GetStyle()); SkAutoTUnref<SkTypeface> typeface( - SkTypeface::CreateFromName(font.GetFontName().c_str(), skia_style)); + SkTypeface::CreateFromName(font.GetFontName().c_str(), + SkTypeface::kNormal)); if (typeface.get()) { // |paint_| adds its own ref. So don't |release()| it from the ref ptr here. SetTypeface(typeface.get()); @@ -190,7 +164,6 @@ void SkiaTextRenderer::DrawDecorations(int x, int y, int width, StyleRange::StyleRange() : foreground(SK_ColorBLACK), - font_style(gfx::Font::NORMAL), strike(false), underline(false) { } |