| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2010, 2011 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov | 3 * Copyright (C) 2006 Alexey Proskuryakov |
| 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 | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if (!m_derivedFontData) | 112 if (!m_derivedFontData) |
| 113 m_derivedFontData = DerivedFontData::create(isCustomFont()); | 113 m_derivedFontData = DerivedFontData::create(isCustomFont()); |
| 114 if (!m_derivedFontData->compositeFontReferences) | 114 if (!m_derivedFontData->compositeFontReferences) |
| 115 m_derivedFontData->compositeFontReferences.adoptCF(CFDictionaryCreat
eMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, NULL)); | 115 m_derivedFontData->compositeFontReferences.adoptCF(CFDictionaryCreat
eMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, NULL)); |
| 116 else { | 116 else { |
| 117 const SimpleFontData* found = static_cast<const SimpleFontData*>(CFD
ictionaryGetValue(m_derivedFontData->compositeFontReferences.get(), static_cast<
const void *>(key))); | 117 const SimpleFontData* found = static_cast<const SimpleFontData*>(CFD
ictionaryGetValue(m_derivedFontData->compositeFontReferences.get(), static_cast<
const void *>(key))); |
| 118 if (found) | 118 if (found) |
| 119 return found; | 119 return found; |
| 120 } | 120 } |
| 121 if (CFMutableDictionaryRef dictionary = m_derivedFontData->compositeFont
References.get()) { | 121 if (CFMutableDictionaryRef dictionary = m_derivedFontData->compositeFont
References.get()) { |
| 122 bool isUsingPrinterFont = platformData().isPrinterFont(); | 122 NSFont *substituteFont = [key printerFont]; |
| 123 NSFont *substituteFont = isUsingPrinterFont ? [key printerFont] : [k
ey screenFont]; | |
| 124 | 123 |
| 125 CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(su
bstituteFont)); | 124 CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(su
bstituteFont)); |
| 126 bool syntheticBold = platformData().syntheticBold() && !(traits & kC
TFontBoldTrait); | 125 bool syntheticBold = platformData().syntheticBold() && !(traits & kC
TFontBoldTrait); |
| 127 bool syntheticOblique = platformData().syntheticOblique() && !(trait
s & kCTFontItalicTrait); | 126 bool syntheticOblique = platformData().syntheticOblique() && !(trait
s & kCTFontItalicTrait); |
| 128 | 127 |
| 129 FontPlatformData substitutePlatform(substituteFont, platformData().s
ize(), isUsingPrinterFont, syntheticBold, syntheticOblique, platformData().orien
tation(), platformData().widthVariant()); | 128 FontPlatformData substitutePlatform(substituteFont, platformData().s
ize(), syntheticBold, syntheticOblique, platformData().orientation(), platformDa
ta().widthVariant()); |
| 130 SimpleFontData* value = new SimpleFontData(substitutePlatform, isCus
tomFont() ? CustomFontData::create() : nullptr); | 129 SimpleFontData* value = new SimpleFontData(substitutePlatform, isCus
tomFont() ? CustomFontData::create() : nullptr); |
| 131 if (value) { | 130 if (value) { |
| 132 CFDictionaryAddValue(dictionary, key, value); | 131 CFDictionaryAddValue(dictionary, key, value); |
| 133 return value; | 132 return value; |
| 134 } | 133 } |
| 135 } | 134 } |
| 136 } | 135 } |
| 137 return 0; | 136 return 0; |
| 138 } | 137 } |
| 139 | 138 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const Fo
ntDescription& fontDescription, float scaleFactor) const | 306 PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const Fo
ntDescription& fontDescription, float scaleFactor) const |
| 308 { | 307 { |
| 309 if (isCustomFont()) { | 308 if (isCustomFont()) { |
| 310 FontPlatformData scaledFontData(m_platformData); | 309 FontPlatformData scaledFontData(m_platformData); |
| 311 scaledFontData.m_size = scaledFontData.m_size * scaleFactor; | 310 scaledFontData.m_size = scaledFontData.m_size * scaleFactor; |
| 312 return SimpleFontData::create(scaledFontData, CustomFontData::create()); | 311 return SimpleFontData::create(scaledFontData, CustomFontData::create()); |
| 313 } | 312 } |
| 314 | 313 |
| 315 BEGIN_BLOCK_OBJC_EXCEPTIONS; | 314 BEGIN_BLOCK_OBJC_EXCEPTIONS; |
| 316 float size = m_platformData.size() * scaleFactor; | 315 float size = m_platformData.size() * scaleFactor; |
| 317 FontPlatformData scaledFontData([[NSFontManager sharedFontManager] convertFo
nt:m_platformData.font() toSize:size], size, m_platformData.isPrinterFont(), fal
se, false, m_platformData.orientation()); | 316 FontPlatformData scaledFontData([[NSFontManager sharedFontManager] convertFo
nt:m_platformData.font() toSize:size], size, false, false, m_platformData.orient
ation()); |
| 318 | 317 |
| 319 // AppKit resets the type information (screen/printer) when you convert a fo
nt to a different size. | 318 // Until we replace AppKit API (NSFontManager etc.), we always want to disab
le hinting, |
| 320 // We have to fix up the font that we're handed back. | 319 // so we use the printerFont here. |
| 321 scaledFontData.setFont(fontDescription.usePrinterFont() ? [scaledFontData.fo
nt() printerFont] : [scaledFontData.font() screenFont]); | 320 scaledFontData.setFont([scaledFontData.font() printerFont]); |
| 322 | 321 |
| 323 if (scaledFontData.font()) { | 322 if (scaledFontData.font()) { |
| 324 NSFontManager *fontManager = [NSFontManager sharedFontManager]; | 323 NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
| 325 NSFontTraitMask fontTraits = [fontManager traitsOfFont:m_platformData.fo
nt()]; | 324 NSFontTraitMask fontTraits = [fontManager traitsOfFont:m_platformData.fo
nt()]; |
| 326 | 325 |
| 327 if (m_platformData.m_syntheticBold) | 326 if (m_platformData.m_syntheticBold) |
| 328 fontTraits |= NSBoldFontMask; | 327 fontTraits |= NSBoldFontMask; |
| 329 if (m_platformData.m_syntheticOblique) | 328 if (m_platformData.m_syntheticOblique) |
| 330 fontTraits |= NSItalicFontMask; | 329 fontTraits |= NSItalicFontMask; |
| 331 | 330 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 RetainPtr<CGFontRef> runCGFont(AdoptCF, CTFontCopyGraphicsFont(runFont,
0)); | 438 RetainPtr<CGFontRef> runCGFont(AdoptCF, CTFontCopyGraphicsFont(runFont,
0)); |
| 440 if (!CFEqual(runCGFont.get(), cgFont.get())) | 439 if (!CFEqual(runCGFont.get(), cgFont.get())) |
| 441 return false; | 440 return false; |
| 442 } | 441 } |
| 443 | 442 |
| 444 addResult.storedValue->value = true; | 443 addResult.storedValue->value = true; |
| 445 return true; | 444 return true; |
| 446 } | 445 } |
| 447 | 446 |
| 448 } // namespace WebCore | 447 } // namespace WebCore |
| OLD | NEW |