Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Side by Side Diff: app/gfx/chrome_font_skia.cc

Issue 65012: Move skia to DEPS, and put it in third_party. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « app/gfx/chrome_font.h ('k') | app/gfx/color_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "app/gfx/chrome_font.h" 5 #include "app/gfx/chrome_font.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 9
10 #include "skia/include/SkTypeface.h" 10 #include "third_party/skia/include/core/SkTypeface.h"
11 #include "skia/include/SkPaint.h" 11 #include "third_party/skia/include/core/SkPaint.h"
12 12
13 ChromeFont::ChromeFont(const ChromeFont& other) { 13 ChromeFont::ChromeFont(const ChromeFont& other) {
14 CopyChromeFont(other); 14 CopyChromeFont(other);
15 } 15 }
16 16
17 ChromeFont& ChromeFont::operator=(const ChromeFont& other) { 17 ChromeFont& ChromeFont::operator=(const ChromeFont& other) {
18 CopyChromeFont(other); 18 CopyChromeFont(other);
19 return *this; 19 return *this;
20 } 20 }
21 21
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 int ChromeFont::ave_char_width() const { 75 int ChromeFont::ave_char_width() const {
76 return avg_width_; 76 return avg_width_;
77 } 77 }
78 78
79 ChromeFont ChromeFont::CreateFont(const std::wstring& font_family, 79 ChromeFont ChromeFont::CreateFont(const std::wstring& font_family,
80 int font_size) { 80 int font_size) {
81 DCHECK_GT(font_size, 0); 81 DCHECK_GT(font_size, 0);
82 82
83 SkTypeface* tf = SkTypeface::Create(base::SysWideToUTF8(font_family).c_str(), 83 SkTypeface* tf = SkTypeface::CreateFromName(
84 SkTypeface::kNormal); 84 base::SysWideToUTF8(font_family).c_str(), SkTypeface::kNormal);
85 DCHECK(tf) << "Could not find font: " << base::SysWideToUTF8(font_family); 85 DCHECK(tf) << "Could not find font: " << base::SysWideToUTF8(font_family);
86 SkAutoUnref tf_helper(tf); 86 SkAutoUnref tf_helper(tf);
87 87
88 return ChromeFont(tf, font_family, font_size, NORMAL); 88 return ChromeFont(tf, font_family, font_size, NORMAL);
89 } 89 }
90 90
91 ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const { 91 ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const {
92 // If the delta is negative, if must not push the size below 1 92 // If the delta is negative, if must not push the size below 1
93 if (size_delta < 0) { 93 if (size_delta < 0) {
94 DCHECK_LT(-size_delta, font_size_); 94 DCHECK_LT(-size_delta, font_size_);
95 } 95 }
96 96
97 if (style == style_) { 97 if (style == style_) {
98 // Fast path, we just use the same typeface at a different size 98 // Fast path, we just use the same typeface at a different size
99 return ChromeFont(typeface_, font_family_, font_size_ + size_delta, style_); 99 return ChromeFont(typeface_, font_family_, font_size_ + size_delta, style_);
100 } 100 }
101 101
102 // If the style has changed we may need to load a new face 102 // If the style has changed we may need to load a new face
103 int skstyle = SkTypeface::kNormal; 103 int skstyle = SkTypeface::kNormal;
104 if (BOLD & style) 104 if (BOLD & style)
105 skstyle |= SkTypeface::kBold; 105 skstyle |= SkTypeface::kBold;
106 if (ITALIC & style) 106 if (ITALIC & style)
107 skstyle |= SkTypeface::kItalic; 107 skstyle |= SkTypeface::kItalic;
108 108
109 SkTypeface* tf = SkTypeface::Create(base::SysWideToUTF8(font_family_).c_str(), 109 SkTypeface* tf = SkTypeface::CreateFromName(
110 static_cast<SkTypeface::Style>(skstyle)); 110 base::SysWideToUTF8(font_family_).c_str(),
111 static_cast<SkTypeface::Style>(skstyle));
111 SkAutoUnref tf_helper(tf); 112 SkAutoUnref tf_helper(tf);
112 113
113 return ChromeFont(tf, font_family_, font_size_ + size_delta, skstyle); 114 return ChromeFont(tf, font_family_, font_size_ + size_delta, skstyle);
114 } 115 }
115 116
116 void ChromeFont::PaintSetup(SkPaint* paint) const { 117 void ChromeFont::PaintSetup(SkPaint* paint) const {
117 paint->setAntiAlias(false); 118 paint->setAntiAlias(false);
118 paint->setSubpixelText(false); 119 paint->setSubpixelText(false);
119 paint->setTextSize(SkFloatToScalar(font_size_)); 120 paint->setTextSize(SkFloatToScalar(font_size_));
120 paint->setTypeface(typeface_); 121 paint->setTypeface(typeface_);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return font_family_; 155 return font_family_;
155 } 156 }
156 157
157 int ChromeFont::FontSize() { 158 int ChromeFont::FontSize() {
158 return font_size_; 159 return font_size_;
159 } 160 }
160 161
161 NativeFont ChromeFont::nativeFont() const { 162 NativeFont ChromeFont::nativeFont() const {
162 return typeface_; 163 return typeface_;
163 } 164 }
OLDNEW
« no previous file with comments | « app/gfx/chrome_font.h ('k') | app/gfx/color_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698