OLD | NEW |
1 /* | 1 /* |
2 * This file is part of the internal font implementation. | 2 * This file is part of the internal font implementation. |
3 * | 3 * |
4 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. | 4 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. |
5 * Copyright (c) 2010 Google Inc. All rights reserved. | 5 * Copyright (c) 2010 Google Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 | 72 |
73 FontPlatformData:: ~FontPlatformData() | 73 FontPlatformData:: ~FontPlatformData() |
74 { | 74 { |
75 if (m_font && m_font != reinterpret_cast<NSFont *>(-1)) | 75 if (m_font && m_font != reinterpret_cast<NSFont *>(-1)) |
76 CFRelease(m_font); | 76 CFRelease(m_font); |
77 } | 77 } |
78 | 78 |
79 void FontPlatformData::platformDataInit(const FontPlatformData& f) | 79 void FontPlatformData::platformDataInit(const FontPlatformData& f) |
80 { | 80 { |
81 m_font = f.m_font && f.m_font != reinterpret_cast<NSFont *>(-1) ? const_cast
<NSFont *>(static_cast<const NSFont *>(CFRetain(f.m_font))) : f.m_font; | 81 m_font = f.m_font && f.m_font != reinterpret_cast<NSFont *>(-1) ? [f.m_font
retain] : f.m_font; |
82 | 82 |
83 m_cgFont = f.m_cgFont; | 83 m_cgFont = f.m_cgFont; |
84 m_CTFont = f.m_CTFont; | 84 m_CTFont = f.m_CTFont; |
85 | 85 |
86 #if OS(DARWIN) | 86 #if OS(DARWIN) |
87 m_inMemoryFont = f.m_inMemoryFont; | 87 m_inMemoryFont = f.m_inMemoryFont; |
88 m_harfBuzzFace = f.m_harfBuzzFace; | 88 m_harfBuzzFace = f.m_harfBuzzFace; |
89 #endif | 89 #endif |
90 } | 90 } |
91 | 91 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 226 |
227 const void* keys[] = { kCTFontFeatureSettingsAttribute }; | 227 const void* keys[] = { kCTFontFeatureSettingsAttribute }; |
228 const void* values[] = { featureSettings.get() }; | 228 const void* values[] = { featureSettings.get() }; |
229 RetainPtr<CFDictionaryRef> attributes(AdoptCF, CFDictionaryCreate(kCFAllocat
orDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks)); | 229 RetainPtr<CFDictionaryRef> attributes(AdoptCF, CFDictionaryCreate(kCFAllocat
orDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks)); |
230 | 230 |
231 descriptor = CTFontDescriptorCreateCopyWithAttributes(cascadeToLastResortFon
tDescriptor(), attributes.get()); | 231 descriptor = CTFontDescriptorCreateCopyWithAttributes(cascadeToLastResortFon
tDescriptor(), attributes.get()); |
232 | 232 |
233 return descriptor; | 233 return descriptor; |
234 } | 234 } |
235 | 235 |
236 // Adding a cascade list breaks the font on Leopard | |
237 static bool canSetCascadeListForCustomFont() | |
238 { | |
239 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
240 return true; | |
241 #else | |
242 return false; | |
243 #endif | |
244 } | |
245 | |
246 CTFontRef FontPlatformData::ctFont() const | 236 CTFontRef FontPlatformData::ctFont() const |
247 { | 237 { |
248 if (m_CTFont) | 238 if (m_CTFont) |
249 return m_CTFont.get(); | 239 return m_CTFont.get(); |
250 | 240 |
251 if (m_inMemoryFont) { | 241 if (m_inMemoryFont) { |
252 m_CTFont.adoptCF(CTFontCreateWithGraphicsFont(m_inMemoryFont->cgFont(),
m_size, 0, canSetCascadeListForCustomFont() ? cascadeToLastResortFontDescriptor(
) : 0)); | 242 m_CTFont.adoptCF(CTFontCreateWithGraphicsFont(m_inMemoryFont->cgFont(),
m_size, 0, cascadeToLastResortFontDescriptor())); |
253 return m_CTFont.get(); | 243 return m_CTFont.get(); |
254 } | 244 } |
255 | 245 |
256 m_CTFont = toCTFontRef(m_font); | 246 m_CTFont = toCTFontRef(m_font); |
257 if (m_CTFont) { | 247 if (m_CTFont) { |
258 CTFontDescriptorRef fontDescriptor; | 248 CTFontDescriptorRef fontDescriptor; |
259 RetainPtr<CFStringRef> postScriptName(AdoptCF, CTFontCopyPostScriptName(
m_CTFont.get())); | 249 RetainPtr<CFStringRef> postScriptName(AdoptCF, CTFontCopyPostScriptName(
m_CTFont.get())); |
260 // Hoefler Text Italic has line-initial and -final swashes enabled by de
fault, so disable them. | 250 // Hoefler Text Italic has line-initial and -final swashes enabled by de
fault, so disable them. |
261 if (CFEqual(postScriptName.get(), CFSTR("HoeflerText-Italic")) || CFEqua
l(postScriptName.get(), CFSTR("HoeflerText-BlackItalic"))) | 251 if (CFEqual(postScriptName.get(), CFSTR("HoeflerText-Italic")) || CFEqua
l(postScriptName.get(), CFSTR("HoeflerText-BlackItalic"))) |
262 fontDescriptor = cascadeToLastResortAndDisableSwashesFontDescriptor(
); | 252 fontDescriptor = cascadeToLastResortAndDisableSwashesFontDescriptor(
); |
263 else | 253 else |
264 fontDescriptor = cascadeToLastResortFontDescriptor(); | 254 fontDescriptor = cascadeToLastResortFontDescriptor(); |
265 m_CTFont.adoptCF(CTFontCreateCopyWithAttributes(m_CTFont.get(), m_size,
0, fontDescriptor)); | 255 m_CTFont.adoptCF(CTFontCreateCopyWithAttributes(m_CTFont.get(), m_size,
0, fontDescriptor)); |
266 } else | 256 } else |
267 m_CTFont.adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), m_size, 0,
canSetCascadeListForCustomFont() ? cascadeToLastResortFontDescriptor() : 0)); | 257 m_CTFont.adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), m_size, 0,
cascadeToLastResortFontDescriptor())); |
268 | 258 |
269 if (m_widthVariant != RegularWidth) { | 259 if (m_widthVariant != RegularWidth) { |
270 int featureTypeValue = kTextSpacingType; | 260 int featureTypeValue = kTextSpacingType; |
271 int featureSelectorValue = mapFontWidthVariantToCTFeatureSelector(m_widt
hVariant); | 261 int featureSelectorValue = mapFontWidthVariantToCTFeatureSelector(m_widt
hVariant); |
272 RetainPtr<CTFontDescriptorRef> sourceDescriptor(AdoptCF, CTFontCopyFontD
escriptor(m_CTFont.get())); | 262 RetainPtr<CTFontDescriptorRef> sourceDescriptor(AdoptCF, CTFontCopyFontD
escriptor(m_CTFont.get())); |
273 RetainPtr<CFNumberRef> featureType(AdoptCF, CFNumberCreate(kCFAllocatorD
efault, kCFNumberIntType, &featureTypeValue)); | 263 RetainPtr<CFNumberRef> featureType(AdoptCF, CFNumberCreate(kCFAllocatorD
efault, kCFNumberIntType, &featureTypeValue)); |
274 RetainPtr<CFNumberRef> featureSelector(AdoptCF, CFNumberCreate(kCFAlloca
torDefault, kCFNumberIntType, &featureSelectorValue)); | 264 RetainPtr<CFNumberRef> featureSelector(AdoptCF, CFNumberCreate(kCFAlloca
torDefault, kCFNumberIntType, &featureSelectorValue)); |
275 RetainPtr<CTFontDescriptorRef> newDescriptor(AdoptCF, CTFontDescriptorCr
eateCopyWithFeature(sourceDescriptor.get(), featureType.get(), featureSelector.g
et())); | 265 RetainPtr<CTFontDescriptorRef> newDescriptor(AdoptCF, CTFontDescriptorCr
eateCopyWithFeature(sourceDescriptor.get(), featureType.get(), featureSelector.g
et())); |
276 RetainPtr<CTFontRef> newFont(AdoptCF, CTFontCreateWithFontDescriptor(new
Descriptor.get(), m_size, 0)); | 266 RetainPtr<CTFontRef> newFont(AdoptCF, CTFontCreateWithFontDescriptor(new
Descriptor.get(), m_size, 0)); |
277 | 267 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 #ifndef NDEBUG | 306 #ifndef NDEBUG |
317 String FontPlatformData::description() const | 307 String FontPlatformData::description() const |
318 { | 308 { |
319 RetainPtr<CFStringRef> cgFontDescription(AdoptCF, CFCopyDescription(cgFont()
)); | 309 RetainPtr<CFStringRef> cgFontDescription(AdoptCF, CFCopyDescription(cgFont()
)); |
320 return String(cgFontDescription.get()) + " " + String::number(m_size) | 310 return String(cgFontDescription.get()) + " " + String::number(m_size) |
321 + (m_syntheticBold ? " synthetic bold" : "") + (m_syntheticOblique ?
" synthetic oblique" : "") + (m_orientation ? " vertical orientation" : ""); | 311 + (m_syntheticBold ? " synthetic bold" : "") + (m_syntheticOblique ?
" synthetic oblique" : "") + (m_orientation ? " vertical orientation" : ""); |
322 } | 312 } |
323 #endif | 313 #endif |
324 | 314 |
325 } // namespace WebCore | 315 } // namespace WebCore |
OLD | NEW |