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

Side by Side Diff: Source/platform/fonts/win/FontPlatformDataWin.cpp

Issue 138273018: Use synthetic bold/italic terminology consistently (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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 | « Source/platform/fonts/win/FontPlatformDataWin.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Apple Computer, Inc. 2 * Copyright (C) 2006, 2007 Apple Computer, Inc.
3 * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved. 3 * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include <objidl.h> 48 #include <objidl.h>
49 #include <windows.h> 49 #include <windows.h>
50 50
51 namespace WebCore { 51 namespace WebCore {
52 52
53 void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext* context) cons t 53 void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext* context) cons t
54 { 54 {
55 const float ts = m_textSize >= 0 ? m_textSize : 12; 55 const float ts = m_textSize >= 0 ? m_textSize : 12;
56 paint->setTextSize(SkFloatToScalar(m_textSize)); 56 paint->setTextSize(SkFloatToScalar(m_textSize));
57 paint->setTypeface(typeface()); 57 paint->setTypeface(typeface());
58 paint->setFakeBoldText(m_fakeBold); 58 paint->setFakeBoldText(m_syntheticBold);
59 paint->setTextSkewX(m_fakeItalic ? -SK_Scalar1 / 4 : 0); 59 paint->setTextSkewX(m_syntheticItalic ? -SK_Scalar1 / 4 : 0);
60 paint->setSubpixelText(m_useSubpixelPositioning); 60 paint->setSubpixelText(m_useSubpixelPositioning);
61 61
62 int textFlags = paintTextFlags(); 62 int textFlags = paintTextFlags();
63 // Only set painting flags when we're actually painting. 63 // Only set painting flags when we're actually painting.
64 if (context && !context->couldUseLCDRenderedText()) { 64 if (context && !context->couldUseLCDRenderedText()) {
65 textFlags &= ~SkPaint::kLCDRenderText_Flag; 65 textFlags &= ~SkPaint::kLCDRenderText_Flag;
66 // If we *just* clear our request for LCD, then GDI seems to 66 // If we *just* clear our request for LCD, then GDI seems to
67 // sometimes give us AA text, and sometimes give us BW text. Since the 67 // sometimes give us AA text, and sometimes give us BW text. Since the
68 // original intent was LCD, we want to force AA (rather than BW), so we 68 // original intent was LCD, we want to force AA (rather than BW), so we
69 // add a special bit to tell Skia to do its best to avoid the BW: by 69 // add a special bit to tell Skia to do its best to avoid the BW: by
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 if (height < 0) 137 if (height < 0)
138 height = -height; 138 height = -height;
139 *size = height; 139 *size = height;
140 } 140 }
141 return adoptRef(SkCreateTypefaceFromLOGFONT(info)); 141 return adoptRef(SkCreateTypefaceFromLOGFONT(info));
142 } 142 }
143 #endif 143 #endif
144 144
145 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) 145 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
146 : m_textSize(-1) 146 : m_textSize(-1)
147 , m_fakeBold(false) 147 , m_syntheticBold(false)
148 , m_fakeItalic(false) 148 , m_syntheticItalic(false)
149 , m_orientation(Horizontal) 149 , m_orientation(Horizontal)
150 , m_typeface(adoptRef(SkTypeface::RefDefault())) 150 , m_typeface(adoptRef(SkTypeface::RefDefault()))
151 , m_isHashTableDeletedValue(true) 151 , m_isHashTableDeletedValue(true)
152 , m_useSubpixelPositioning(false) 152 , m_useSubpixelPositioning(false)
153 { 153 {
154 #if !USE(HARFBUZZ) 154 #if !USE(HARFBUZZ)
155 m_font = 0; 155 m_font = 0;
156 m_scriptCache = 0; 156 m_scriptCache = 0;
157 #endif 157 #endif
158 } 158 }
159 159
160 FontPlatformData::FontPlatformData() 160 FontPlatformData::FontPlatformData()
161 : m_textSize(0) 161 : m_textSize(0)
162 , m_fakeBold(false) 162 , m_syntheticBold(false)
163 , m_fakeItalic(false) 163 , m_syntheticItalic(false)
164 , m_orientation(Horizontal) 164 , m_orientation(Horizontal)
165 , m_typeface(adoptRef(SkTypeface::RefDefault())) 165 , m_typeface(adoptRef(SkTypeface::RefDefault()))
166 , m_isHashTableDeletedValue(false) 166 , m_isHashTableDeletedValue(false)
167 , m_useSubpixelPositioning(false) 167 , m_useSubpixelPositioning(false)
168 { 168 {
169 #if !USE(HARFBUZZ) 169 #if !USE(HARFBUZZ)
170 m_font = 0; 170 m_font = 0;
171 m_scriptCache = 0; 171 m_scriptCache = 0;
172 #endif 172 #endif
173 } 173 }
174 174
175 #if ENABLE(GDI_FONTS_ON_WINDOWS) && !USE(HARFBUZZ) 175 #if ENABLE(GDI_FONTS_ON_WINDOWS) && !USE(HARFBUZZ)
176 FontPlatformData::FontPlatformData(HFONT font, float size, FontOrientation orien tation) 176 FontPlatformData::FontPlatformData(HFONT font, float size, FontOrientation orien tation)
177 : m_font(RefCountedHFONT::create(font)) 177 : m_font(RefCountedHFONT::create(font))
178 , m_textSize(size) 178 , m_textSize(size)
179 , m_fakeBold(false) 179 , m_syntheticBold(false)
180 , m_fakeItalic(false) 180 , m_syntheticItalic(false)
181 , m_orientation(orientation) 181 , m_orientation(orientation)
182 , m_scriptCache(0) 182 , m_scriptCache(0)
183 , m_typeface(CreateTypefaceFromHFont(font, 0)) 183 , m_typeface(CreateTypefaceFromHFont(font, 0))
184 , m_isHashTableDeletedValue(false) 184 , m_isHashTableDeletedValue(false)
185 , m_useSubpixelPositioning(false) 185 , m_useSubpixelPositioning(false)
186 { 186 {
187 } 187 }
188 #endif 188 #endif
189 189
190 // FIXME: this constructor is needed for SVG fonts but doesn't seem to do much 190 // FIXME: this constructor is needed for SVG fonts but doesn't seem to do much
191 FontPlatformData::FontPlatformData(float size, bool bold, bool oblique) 191 FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
192 : m_textSize(size) 192 : m_textSize(size)
193 , m_fakeBold(false) 193 , m_syntheticBold(false)
194 , m_fakeItalic(false) 194 , m_syntheticItalic(false)
195 , m_orientation(Horizontal) 195 , m_orientation(Horizontal)
196 , m_typeface(adoptRef(SkTypeface::RefDefault())) 196 , m_typeface(adoptRef(SkTypeface::RefDefault()))
197 , m_isHashTableDeletedValue(false) 197 , m_isHashTableDeletedValue(false)
198 , m_useSubpixelPositioning(false) 198 , m_useSubpixelPositioning(false)
199 { 199 {
200 #if !USE(HARFBUZZ) 200 #if !USE(HARFBUZZ)
201 m_font = 0; 201 m_font = 0;
202 m_scriptCache = 0; 202 m_scriptCache = 0;
203 #endif 203 #endif
204 } 204 }
205 205
206 FontPlatformData::FontPlatformData(const FontPlatformData& data) 206 FontPlatformData::FontPlatformData(const FontPlatformData& data)
207 : m_textSize(data.m_textSize) 207 : m_textSize(data.m_textSize)
208 , m_fakeBold(data.m_fakeBold) 208 , m_syntheticBold(data.m_syntheticBold)
209 , m_fakeItalic(data.m_fakeItalic) 209 , m_syntheticItalic(data.m_syntheticItalic)
210 , m_orientation(data.m_orientation) 210 , m_orientation(data.m_orientation)
211 , m_typeface(data.m_typeface) 211 , m_typeface(data.m_typeface)
212 , m_isHashTableDeletedValue(false) 212 , m_isHashTableDeletedValue(false)
213 , m_useSubpixelPositioning(data.m_useSubpixelPositioning) 213 , m_useSubpixelPositioning(data.m_useSubpixelPositioning)
214 { 214 {
215 #if !USE(HARFBUZZ) 215 #if !USE(HARFBUZZ)
216 m_font = data.m_font; 216 m_font = data.m_font;
217 m_scriptCache = 0; 217 m_scriptCache = 0;
218 #endif 218 #endif
219 } 219 }
220 220
221 FontPlatformData::FontPlatformData(const FontPlatformData& data, float textSize) 221 FontPlatformData::FontPlatformData(const FontPlatformData& data, float textSize)
222 : m_textSize(textSize) 222 : m_textSize(textSize)
223 , m_fakeBold(data.m_fakeBold) 223 , m_syntheticBold(data.m_syntheticBold)
224 , m_fakeItalic(data.m_fakeItalic) 224 , m_syntheticItalic(data.m_syntheticItalic)
225 , m_orientation(data.m_orientation) 225 , m_orientation(data.m_orientation)
226 , m_typeface(data.m_typeface) 226 , m_typeface(data.m_typeface)
227 , m_isHashTableDeletedValue(false) 227 , m_isHashTableDeletedValue(false)
228 , m_useSubpixelPositioning(data.m_useSubpixelPositioning) 228 , m_useSubpixelPositioning(data.m_useSubpixelPositioning)
229 { 229 {
230 #if !USE(HARFBUZZ) 230 #if !USE(HARFBUZZ)
231 m_font = data.m_font; 231 m_font = data.m_font;
232 m_scriptCache = 0; 232 m_scriptCache = 0;
233 #endif 233 #endif
234 } 234 }
235 235
236 FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf, const char* family , 236 FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf, const char* family ,
237 float textSize, bool fakeBold, bool fakeItalic, FontOrientation orientation, 237 float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation or ientation,
238 bool useSubpixelPositioning) 238 bool useSubpixelPositioning)
239 : m_textSize(textSize) 239 : m_textSize(textSize)
240 , m_fakeBold(fakeBold) 240 , m_syntheticBold(syntheticBold)
241 , m_fakeItalic(fakeItalic) 241 , m_syntheticItalic(syntheticItalic)
242 , m_orientation(orientation) 242 , m_orientation(orientation)
243 , m_typeface(tf) 243 , m_typeface(tf)
244 , m_isHashTableDeletedValue(false) 244 , m_isHashTableDeletedValue(false)
245 , m_useSubpixelPositioning(useSubpixelPositioning) 245 , m_useSubpixelPositioning(useSubpixelPositioning)
246 { 246 {
247 // FIXME: This can be removed together with m_font once the last few 247 // FIXME: This can be removed together with m_font once the last few
248 // uses of hfont() has been eliminated. 248 // uses of hfont() has been eliminated.
249 LOGFONT logFont; 249 LOGFONT logFont;
250 SkLOGFONTFromTypeface(m_typeface.get(), &logFont); 250 SkLOGFONTFromTypeface(m_typeface.get(), &logFont);
251 logFont.lfHeight = -textSize; 251 logFont.lfHeight = -textSize;
252 252
253 #if !USE(HARFBUZZ) 253 #if !USE(HARFBUZZ)
254 HFONT hFont = CreateFontIndirect(&logFont); 254 HFONT hFont = CreateFontIndirect(&logFont);
255 m_font = hFont ? RefCountedHFONT::create(hFont) : 0; 255 m_font = hFont ? RefCountedHFONT::create(hFont) : 0;
256 m_scriptCache = 0; 256 m_scriptCache = 0;
257 #endif 257 #endif
258 } 258 }
259 259
260 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data) 260 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data)
261 { 261 {
262 if (this != &data) { 262 if (this != &data) {
263 m_textSize = data.m_textSize; 263 m_textSize = data.m_textSize;
264 m_fakeBold = data.m_fakeBold; 264 m_syntheticBold = data.m_syntheticBold;
265 m_fakeItalic = data.m_fakeItalic; 265 m_syntheticItalic = data.m_syntheticItalic;
266 m_orientation = data.m_orientation; 266 m_orientation = data.m_orientation;
267 m_typeface = data.m_typeface; 267 m_typeface = data.m_typeface;
268 268
269 #if !USE(HARFBUZZ) 269 #if !USE(HARFBUZZ)
270 m_font = data.m_font; 270 m_font = data.m_font;
271 // The following fields will get re-computed if necessary. 271 // The following fields will get re-computed if necessary.
272 ScriptFreeCache(&m_scriptCache); 272 ScriptFreeCache(&m_scriptCache);
273 m_scriptCache = 0; 273 m_scriptCache = 0;
274 m_scriptFontProperties.clear(); 274 m_scriptFontProperties.clear();
275 #endif 275 #endif
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 return treatAsFixedPitch; 333 return treatAsFixedPitch;
334 #else 334 #else
335 return typeface() && typeface()->isFixedPitch(); 335 return typeface() && typeface()->isFixedPitch();
336 #endif 336 #endif
337 } 337 }
338 338
339 bool FontPlatformData::operator==(const FontPlatformData& a) const 339 bool FontPlatformData::operator==(const FontPlatformData& a) const
340 { 340 {
341 return SkTypeface::Equal(m_typeface.get(), a.m_typeface.get()) 341 return SkTypeface::Equal(m_typeface.get(), a.m_typeface.get())
342 && m_textSize == a.m_textSize 342 && m_textSize == a.m_textSize
343 && m_fakeBold == a.m_fakeBold 343 && m_syntheticBold == a.m_syntheticBold
344 && m_fakeItalic == a.m_fakeItalic 344 && m_syntheticItalic == a.m_syntheticItalic
345 && m_orientation == a.m_orientation 345 && m_orientation == a.m_orientation
346 && m_isHashTableDeletedValue == a.m_isHashTableDeletedValue; 346 && m_isHashTableDeletedValue == a.m_isHashTableDeletedValue;
347 } 347 }
348 348
349 #if USE(HARFBUZZ) 349 #if USE(HARFBUZZ)
350 HarfBuzzFace* FontPlatformData::harfBuzzFace() const 350 HarfBuzzFace* FontPlatformData::harfBuzzFace() const
351 { 351 {
352 if (!m_harfBuzzFace) 352 if (!m_harfBuzzFace)
353 m_harfBuzzFace = HarfBuzzFace::create(const_cast<FontPlatformData*>(this ), uniqueID()); 353 m_harfBuzzFace = HarfBuzzFace::create(const_cast<FontPlatformData*>(this ), uniqueID());
354 354
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 407 }
408 408
409 #ifndef NDEBUG 409 #ifndef NDEBUG
410 String FontPlatformData::description() const 410 String FontPlatformData::description() const
411 { 411 {
412 return String(); 412 return String();
413 } 413 }
414 #endif 414 #endif
415 415
416 } // namespace WebCore 416 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/fonts/win/FontPlatformDataWin.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698