| 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 logFont.lfHeight = -textSize; |
| 198 HFONT hFont = CreateFontIndirect(&logFont); |
| 199 if (hFont) |
| 200 m_font = RefCountedHFONT::create(hFont); |
| 201 m_paintTextFlags = computePaintTextFlags(logFont); |
| 202 } |
| 203 |
| 184 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data) | 204 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data) |
| 185 { | 205 { |
| 186 if (this != &data) { | 206 if (this != &data) { |
| 187 m_font = data.m_font; | 207 m_font = data.m_font; |
| 188 m_size = data.m_size; | 208 m_size = data.m_size; |
| 189 m_orientation = data.m_orientation; | 209 m_orientation = data.m_orientation; |
| 190 m_typeface = data.m_typeface; | 210 m_typeface = data.m_typeface; |
| 191 m_paintTextFlags = data.m_paintTextFlags; | 211 m_paintTextFlags = data.m_paintTextFlags; |
| 192 | 212 |
| 193 // The following fields will get re-computed if necessary. | 213 // 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")
; | 243 LOG_ERROR("Unable to get the text metrics after second attempt")
; |
| 224 } | 244 } |
| 225 } | 245 } |
| 226 | 246 |
| 227 bool treatAsFixedPitch = !(textMetric.tmPitchAndFamily & TMPF_FIXED_PITCH); | 247 bool treatAsFixedPitch = !(textMetric.tmPitchAndFamily & TMPF_FIXED_PITCH); |
| 228 | 248 |
| 229 SelectObject(dc, oldFont); | 249 SelectObject(dc, oldFont); |
| 230 | 250 |
| 231 return treatAsFixedPitch; | 251 return treatAsFixedPitch; |
| 232 #else | 252 #else |
| 233 return typeface()->isFixedPitch(); | 253 return typeface() && typeface()->isFixedPitch(); |
| 234 #endif | 254 #endif |
| 235 } | 255 } |
| 236 | 256 |
| 237 FontPlatformData::RefCountedHFONT::~RefCountedHFONT() | 257 FontPlatformData::RefCountedHFONT::~RefCountedHFONT() |
| 238 { | 258 { |
| 239 DeleteObject(m_hfont); | 259 DeleteObject(m_hfont); |
| 240 } | 260 } |
| 241 | 261 |
| 242 SCRIPT_FONTPROPERTIES* FontPlatformData::scriptFontProperties() const | 262 SCRIPT_FONTPROPERTIES* FontPlatformData::scriptFontProperties() const |
| 243 { | 263 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 295 |
| 276 bool FontPlatformData::ensureFontLoaded(HFONT font) | 296 bool FontPlatformData::ensureFontLoaded(HFONT font) |
| 277 { | 297 { |
| 278 WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->san
dboxSupport(); | 298 WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->san
dboxSupport(); |
| 279 // if there is no sandbox, then we can assume the font | 299 // if there is no sandbox, then we can assume the font |
| 280 // was able to be loaded successfully already | 300 // was able to be loaded successfully already |
| 281 return sandboxSupport ? sandboxSupport->ensureFontLoaded(font) : true; | 301 return sandboxSupport ? sandboxSupport->ensureFontLoaded(font) : true; |
| 282 } | 302 } |
| 283 | 303 |
| 284 } | 304 } |
| OLD | NEW |