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

Side by Side Diff: Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp

Issue 24609002: Implement support for fake bold/italics for non-GDI windows font path (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: patch for landing Created 7 years, 2 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
« no previous file with comments | « Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "wtf/PassOwnPtr.h" 49 #include "wtf/PassOwnPtr.h"
50 #include "wtf/StdLibExtras.h" 50 #include "wtf/StdLibExtras.h"
51 51
52 namespace WebCore { 52 namespace WebCore {
53 53
54 void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext* context) cons t 54 void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext* context) cons t
55 { 55 {
56 const float ts = m_size >= 0 ? m_size : 12; 56 const float ts = m_size >= 0 ? m_size : 12;
57 paint->setTextSize(SkFloatToScalar(m_size)); 57 paint->setTextSize(SkFloatToScalar(m_size));
58 paint->setTypeface(typeface()); 58 paint->setTypeface(typeface());
59 paint->setFakeBoldText(m_fakeBold);
60 paint->setTextSkewX(m_fakeItalic ? -SK_Scalar1 / 4 : 0);
59 61
60 // Only set painting flags when we're actually painting. 62 // Only set painting flags when we're actually painting.
61 if (context) { 63 if (context) {
62 int textFlags = paintTextFlags(); 64 int textFlags = paintTextFlags();
63 if (!context->couldUseLCDRenderedText()) { 65 if (!context->couldUseLCDRenderedText()) {
64 textFlags &= ~SkPaint::kLCDRenderText_Flag; 66 textFlags &= ~SkPaint::kLCDRenderText_Flag;
65 // If we *just* clear our request for LCD, then GDI seems to 67 // If we *just* clear our request for LCD, then GDI seems to
66 // sometimes give us AA text, and sometimes give us BW text. Since t he 68 // sometimes give us AA text, and sometimes give us BW text. Since t he
67 // original intent was LCD, we want to force AA (rather than BW), so we 69 // original intent was LCD, we want to force AA (rather than BW), so we
68 // add a special bit to tell Skia to do its best to avoid the BW: by 70 // add a special bit to tell Skia to do its best to avoid the BW: by
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 *size = height; 163 *size = height;
162 } 164 }
163 if (paintTextFlags) 165 if (paintTextFlags)
164 *paintTextFlags = computePaintTextFlags(info); 166 *paintTextFlags = computePaintTextFlags(info);
165 return adoptRef(SkCreateTypefaceFromLOGFONT(info)); 167 return adoptRef(SkCreateTypefaceFromLOGFONT(info));
166 } 168 }
167 169
168 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) 170 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
169 : m_font(0) 171 : m_font(0)
170 , m_size(-1) 172 , m_size(-1)
173 , m_fakeBold(false)
174 , m_fakeItalic(false)
171 , m_orientation(Horizontal) 175 , m_orientation(Horizontal)
172 , m_scriptCache(0) 176 , m_scriptCache(0)
173 , m_typeface(SkTypeface::RefDefault()) 177 , m_typeface(SkTypeface::RefDefault())
174 , m_paintTextFlags(0) 178 , m_paintTextFlags(0)
175 , m_isHashTableDeletedValue(true) 179 , m_isHashTableDeletedValue(true)
176 { 180 {
177 } 181 }
178 182
179 FontPlatformData::FontPlatformData() 183 FontPlatformData::FontPlatformData()
180 : m_font(0) 184 : m_font(0)
181 , m_size(0) 185 , m_size(0)
186 , m_fakeBold(false)
187 , m_fakeItalic(false)
182 , m_orientation(Horizontal) 188 , m_orientation(Horizontal)
183 , m_scriptCache(0) 189 , m_scriptCache(0)
184 , m_typeface(SkTypeface::RefDefault()) 190 , m_typeface(SkTypeface::RefDefault())
185 , m_paintTextFlags(0) 191 , m_paintTextFlags(0)
186 , m_isHashTableDeletedValue(false) 192 , m_isHashTableDeletedValue(false)
187 { 193 {
188 } 194 }
189 195
190 FontPlatformData::FontPlatformData(HFONT font, float size, FontOrientation orien tation) 196 FontPlatformData::FontPlatformData(HFONT font, float size, FontOrientation orien tation)
191 : m_font(RefCountedHFONT::create(font)) 197 : m_font(RefCountedHFONT::create(font))
192 , m_size(size) 198 , m_size(size)
199 , m_fakeBold(false)
200 , m_fakeItalic(false)
193 , m_orientation(orientation) 201 , m_orientation(orientation)
194 , m_scriptCache(0) 202 , m_scriptCache(0)
195 , m_typeface(CreateTypefaceFromHFont(font, 0, &m_paintTextFlags)) 203 , m_typeface(CreateTypefaceFromHFont(font, 0, &m_paintTextFlags))
196 , m_isHashTableDeletedValue(false) 204 , m_isHashTableDeletedValue(false)
197 { 205 {
198 } 206 }
199 207
200 // FIXME: this constructor is needed for SVG fonts but doesn't seem to do much 208 // FIXME: this constructor is needed for SVG fonts but doesn't seem to do much
201 FontPlatformData::FontPlatformData(float size, bool bold, bool oblique) 209 FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
202 : m_font(0) 210 : m_font(0)
203 , m_size(size) 211 , m_size(size)
212 , m_fakeBold(false)
213 , m_fakeItalic(false)
204 , m_orientation(Horizontal) 214 , m_orientation(Horizontal)
205 , m_scriptCache(0) 215 , m_scriptCache(0)
206 , m_typeface(SkTypeface::RefDefault()) 216 , m_typeface(SkTypeface::RefDefault())
207 , m_paintTextFlags(0) 217 , m_paintTextFlags(0)
208 , m_isHashTableDeletedValue(false) 218 , m_isHashTableDeletedValue(false)
209 { 219 {
210 } 220 }
211 221
212 FontPlatformData::FontPlatformData(const FontPlatformData& data) 222 FontPlatformData::FontPlatformData(const FontPlatformData& data)
213 : m_font(data.m_font) 223 : m_font(data.m_font)
214 , m_size(data.m_size) 224 , m_size(data.m_size)
225 , m_fakeBold(false)
226 , m_fakeItalic(false)
215 , m_orientation(data.m_orientation) 227 , m_orientation(data.m_orientation)
216 , m_scriptCache(0) 228 , m_scriptCache(0)
217 , m_typeface(data.m_typeface) 229 , m_typeface(data.m_typeface)
218 , m_paintTextFlags(data.m_paintTextFlags) 230 , m_paintTextFlags(data.m_paintTextFlags)
219 , m_isHashTableDeletedValue(false) 231 , m_isHashTableDeletedValue(false)
220 { 232 {
221 } 233 }
222 234
223 FontPlatformData::FontPlatformData(const FontPlatformData& data, float textSize) 235 FontPlatformData::FontPlatformData(const FontPlatformData& data, float textSize)
224 : m_font(data.m_font) 236 : m_font(data.m_font)
225 , m_size(textSize) 237 , m_size(textSize)
238 , m_fakeBold(false)
239 , m_fakeItalic(false)
226 , m_orientation(data.m_orientation) 240 , m_orientation(data.m_orientation)
227 , m_scriptCache(0) 241 , m_scriptCache(0)
228 , m_typeface(data.m_typeface) 242 , m_typeface(data.m_typeface)
229 , m_paintTextFlags(data.m_paintTextFlags) 243 , m_paintTextFlags(data.m_paintTextFlags)
230 , m_isHashTableDeletedValue(false) 244 , m_isHashTableDeletedValue(false)
231 { 245 {
232 } 246 }
233 247
234 FontPlatformData::FontPlatformData(SkTypeface* tf, const char* family, float tex tSize, bool fakeBold, bool fakeItalic, FontOrientation orientation) 248 FontPlatformData::FontPlatformData(SkTypeface* tf, const char* family, float tex tSize, bool fakeBold, bool fakeItalic, FontOrientation orientation)
235 : m_font(0) 249 : m_font(0)
236 , m_size(textSize) 250 , m_size(textSize)
251 , m_fakeBold(fakeBold)
252 , m_fakeItalic(fakeItalic)
237 , m_orientation(orientation) 253 , m_orientation(orientation)
238 , m_scriptCache(0) 254 , m_scriptCache(0)
239 , m_typeface(tf) 255 , m_typeface(tf)
240 , m_isHashTableDeletedValue(false) 256 , m_isHashTableDeletedValue(false)
241 { 257 {
242 // FIXME: This can be removed together with m_font once the last few 258 // FIXME: This can be removed together with m_font once the last few
243 // uses of hfont() has been eliminated. 259 // uses of hfont() has been eliminated.
244 LOGFONT logFont; 260 LOGFONT logFont;
245 SkLOGFONTFromTypeface(tf, &logFont); 261 SkLOGFONTFromTypeface(tf, &logFont);
246 logFont.lfHeight = -textSize; 262 logFont.lfHeight = -textSize;
247 HFONT hFont = CreateFontIndirect(&logFont); 263 HFONT hFont = CreateFontIndirect(&logFont);
248 if (hFont) 264 if (hFont)
249 m_font = RefCountedHFONT::create(hFont); 265 m_font = RefCountedHFONT::create(hFont);
250 m_paintTextFlags = computePaintTextFlags(logFont); 266 m_paintTextFlags = computePaintTextFlags(logFont);
251 } 267 }
252 268
253 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data) 269 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data)
254 { 270 {
255 if (this != &data) { 271 if (this != &data) {
256 m_font = data.m_font; 272 m_font = data.m_font;
257 m_size = data.m_size; 273 m_size = data.m_size;
274 m_fakeBold = data.m_fakeBold;
275 m_fakeItalic = data.m_fakeItalic;
258 m_orientation = data.m_orientation; 276 m_orientation = data.m_orientation;
259 m_typeface = data.m_typeface; 277 m_typeface = data.m_typeface;
260 m_paintTextFlags = data.m_paintTextFlags; 278 m_paintTextFlags = data.m_paintTextFlags;
261 279
262 // The following fields will get re-computed if necessary. 280 // The following fields will get re-computed if necessary.
263 ScriptFreeCache(&m_scriptCache); 281 ScriptFreeCache(&m_scriptCache);
264 m_scriptCache = 0; 282 m_scriptCache = 0;
265 m_scriptFontProperties.clear(); 283 m_scriptFontProperties.clear();
266 } 284 }
267 return *this; 285 return *this;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 374
357 bool FontPlatformData::ensureFontLoaded(HFONT font) 375 bool FontPlatformData::ensureFontLoaded(HFONT font)
358 { 376 {
359 WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->san dboxSupport(); 377 WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->san dboxSupport();
360 // if there is no sandbox, then we can assume the font 378 // if there is no sandbox, then we can assume the font
361 // was able to be loaded successfully already 379 // was able to be loaded successfully already
362 return sandboxSupport ? sandboxSupport->ensureFontLoaded(font) : true; 380 return sandboxSupport ? sandboxSupport->ensureFontLoaded(font) : true;
363 } 381 }
364 382
365 } 383 }
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698