OLD | NEW |
---|---|
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 #include "wtf/PassOwnPtr.h" | 46 #include "wtf/PassOwnPtr.h" |
47 #include "wtf/StdLibExtras.h" | 47 #include "wtf/StdLibExtras.h" |
48 | 48 |
49 namespace WebCore { | 49 namespace WebCore { |
50 | 50 |
51 #if !ENABLE(GDI_FONTS_ON_WINDOWS) | 51 #if !ENABLE(GDI_FONTS_ON_WINDOWS) |
52 void FontPlatformData::setupPaint(SkPaint* paint) const | 52 void FontPlatformData::setupPaint(SkPaint* paint) const |
53 { | 53 { |
54 const float ts = m_size >= 0 ? m_size : 12; | 54 const float ts = m_size >= 0 ? m_size : 12; |
55 paint->setTextSize(SkFloatToScalar(m_size)); | 55 paint->setTextSize(SkFloatToScalar(m_size)); |
56 paint->setTypeface(m_typeface); | 56 paint->setTypeface(typeface()); |
57 } | 57 } |
58 #endif | 58 #endif |
59 | 59 |
60 // Lookup the current system settings for font smoothing. | 60 // Lookup the current system settings for font smoothing. |
61 // We cache these values for performance, but if the browser has a way to be | 61 // We cache these values for performance, but if the browser has a way to be |
62 // notified when these change, we could re-query them at that time. | 62 // notified when these change, we could re-query them at that time. |
63 static uint32_t getDefaultGDITextFlags() | 63 static uint32_t getDefaultGDITextFlags() |
64 { | 64 { |
65 static bool gInited; | 65 static bool gInited; |
66 static uint32_t gFlags; | 66 static uint32_t gFlags; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 , m_isHashTableDeletedValue(false) | 147 , m_isHashTableDeletedValue(false) |
148 { | 148 { |
149 } | 149 } |
150 | 150 |
151 // FIXME: this constructor is needed for SVG fonts but doesn't seem to do much | 151 // FIXME: this constructor is needed for SVG fonts but doesn't seem to do much |
152 FontPlatformData::FontPlatformData(float size, bool bold, bool oblique) | 152 FontPlatformData::FontPlatformData(float size, bool bold, bool oblique) |
153 : m_font(0) | 153 : m_font(0) |
154 , m_size(size) | 154 , m_size(size) |
155 , m_orientation(Horizontal) | 155 , m_orientation(Horizontal) |
156 , m_scriptCache(0) | 156 , m_scriptCache(0) |
157 , m_typeface(0) | |
157 , m_paintTextFlags(0) | 158 , m_paintTextFlags(0) |
158 , m_isHashTableDeletedValue(false) | 159 , m_isHashTableDeletedValue(false) |
159 { | 160 { |
160 } | 161 } |
161 | 162 |
162 FontPlatformData::FontPlatformData(const FontPlatformData& data) | 163 FontPlatformData::FontPlatformData(const FontPlatformData& data) |
163 : m_font(data.m_font) | 164 : m_font(data.m_font) |
164 , m_size(data.m_size) | 165 , m_size(data.m_size) |
165 , m_orientation(data.m_orientation) | 166 , m_orientation(data.m_orientation) |
166 , m_scriptCache(0) | 167 , m_scriptCache(0) |
167 , m_typeface(data.m_typeface) | 168 , m_typeface(data.m_typeface) |
168 , m_paintTextFlags(data.m_paintTextFlags) | 169 , m_paintTextFlags(data.m_paintTextFlags) |
169 , m_isHashTableDeletedValue(false) | 170 , m_isHashTableDeletedValue(false) |
170 { | 171 { |
171 } | 172 } |
172 | 173 |
173 FontPlatformData::FontPlatformData(const FontPlatformData& data, float textSize) | 174 FontPlatformData::FontPlatformData(const FontPlatformData& data, float textSize) |
174 : m_font(data.m_font) | 175 : m_font(data.m_font) |
175 , m_size(textSize) | 176 , m_size(textSize) |
176 , m_orientation(data.m_orientation) | 177 , m_orientation(data.m_orientation) |
177 , m_scriptCache(0) | 178 , m_scriptCache(0) |
178 , m_typeface(data.m_typeface) | 179 , m_typeface(data.m_typeface) |
179 , m_paintTextFlags(data.m_paintTextFlags) | 180 , m_paintTextFlags(data.m_paintTextFlags) |
180 , m_isHashTableDeletedValue(false) | 181 , m_isHashTableDeletedValue(false) |
181 { | 182 { |
182 } | 183 } |
183 | 184 |
185 FontPlatformData::FontPlatformData(SkTypeface* tf, const char* family, float tex tSize, bool fakeBold, bool fakeItalic, FontOrientation orientation) | |
186 : m_font(0) | |
187 , m_size(textSize) | |
188 , m_orientation(orientation) | |
189 , m_scriptCache(0) | |
190 , m_typeface(tf) | |
191 , m_isHashTableDeletedValue(false) | |
192 { | |
193 // FIXME: This can be removed together with m_font once the last few | |
194 // uses of hfont() has been eliminated. | |
195 LOGFONT logFont; | |
196 SkLOGFONTFromTypeface(tf, &logFont); | |
197 HFONT hFont = CreateFontIndirect(&logFont); | |
bungeman-chromium
2013/08/15 22:24:44
When Skia hands back the logFont here, I don't thi
eae
2013/08/15 22:34:50
Ah, that likely explains my font-sizing problems.
| |
198 if (hFont) | |
199 m_font = RefCountedHFONT::create(hFont); | |
200 m_paintTextFlags = computePaintTextFlags(logFont); | |
201 } | |
202 | |
184 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data) | 203 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data) |
185 { | 204 { |
186 if (this != &data) { | 205 if (this != &data) { |
187 m_font = data.m_font; | 206 m_font = data.m_font; |
188 m_size = data.m_size; | 207 m_size = data.m_size; |
189 m_orientation = data.m_orientation; | 208 m_orientation = data.m_orientation; |
190 m_typeface = data.m_typeface; | 209 m_typeface = data.m_typeface; |
191 m_paintTextFlags = data.m_paintTextFlags; | 210 m_paintTextFlags = data.m_paintTextFlags; |
192 | 211 |
193 // The following fields will get re-computed if necessary. | 212 // The following fields will get re-computed if necessary. |
(...skipping 29 matching lines...) Expand all Loading... | |
223 LOG_ERROR("Unable to get the text metrics after second attempt") ; | 242 LOG_ERROR("Unable to get the text metrics after second attempt") ; |
224 } | 243 } |
225 } | 244 } |
226 | 245 |
227 bool treatAsFixedPitch = !(textMetric.tmPitchAndFamily & TMPF_FIXED_PITCH); | 246 bool treatAsFixedPitch = !(textMetric.tmPitchAndFamily & TMPF_FIXED_PITCH); |
228 | 247 |
229 SelectObject(dc, oldFont); | 248 SelectObject(dc, oldFont); |
230 | 249 |
231 return treatAsFixedPitch; | 250 return treatAsFixedPitch; |
232 #else | 251 #else |
233 return typeface()->isFixedPitch(); | 252 return typeface() && typeface()->isFixedPitch(); |
234 #endif | 253 #endif |
235 } | 254 } |
236 | 255 |
237 FontPlatformData::RefCountedHFONT::~RefCountedHFONT() | 256 FontPlatformData::RefCountedHFONT::~RefCountedHFONT() |
238 { | 257 { |
239 DeleteObject(m_hfont); | 258 DeleteObject(m_hfont); |
240 } | 259 } |
241 | 260 |
242 SCRIPT_FONTPROPERTIES* FontPlatformData::scriptFontProperties() const | 261 SCRIPT_FONTPROPERTIES* FontPlatformData::scriptFontProperties() const |
243 { | 262 { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 | 294 |
276 bool FontPlatformData::ensureFontLoaded(HFONT font) | 295 bool FontPlatformData::ensureFontLoaded(HFONT font) |
277 { | 296 { |
278 WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->san dboxSupport(); | 297 WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->san dboxSupport(); |
279 // if there is no sandbox, then we can assume the font | 298 // if there is no sandbox, then we can assume the font |
280 // was able to be loaded successfully already | 299 // was able to be loaded successfully already |
281 return sandboxSupport ? sandboxSupport->ensureFontLoaded(font) : true; | 300 return sandboxSupport ? sandboxSupport->ensureFontLoaded(font) : true; |
282 } | 301 } |
283 | 302 |
284 } | 303 } |
OLD | NEW |