Changeset 53039 in webkit
- Timestamp:
- Jan 9, 2010, 10:45:06 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r53035 r53039 1 2010-01-09 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Nikolas Zimmermann. 4 5 <rdar://problem/7525778> Font fallback kills SVG kerning 6 https://bugs.webkit.org/show_bug.cgi?id=33400 7 8 * platform/mac/fast/text/sticky-typesetting-features-expected.checksum: Added. 9 * platform/mac/fast/text/sticky-typesetting-features-expected.png: Added. 10 * platform/mac/fast/text/sticky-typesetting-features-expected.txt: Added. 11 * platform/mac/fast/text/sticky-typesetting-features.html: Added. 12 1 13 2010-01-08 Simon Fraser <simon.fraser@apple.com> 2 14 -
trunk/WebCore/ChangeLog
r53038 r53039 1 2010-01-09 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Nikolas Zimmermann. 4 5 <rdar://problem/7525778> Font fallback kills SVG kerning 6 https://bugs.webkit.org/show_bug.cgi?id=33400 7 8 Test: platform/mac/fast/text/sticky-typesetting-features.html 9 10 Cache font attributes separately for different typesetting features. 11 12 * platform/graphics/SimpleFontData.h: Replaced single-element caches 13 with maps. 14 * platform/graphics/mac/ComplexTextControllerATSUI.cpp: 15 (WebCore::disableLigatures): Added an ATSUStyle parameter. 16 (WebCore::initializeATSUStyle): Look up the ATSUStyle in the map and 17 initialize if necessary. Return the ATSUStyle. 18 (WebCore::ComplexTextController::collectComplexTextRunsForCharactersATSUI): 19 Use the ATSUStyle returned from initializeATSUStyle(). 20 * platform/graphics/mac/SimpleFontDataMac.mm: 21 (WebCore::SimpleFontData::platformInit): 22 (WebCore::SimpleFontData::platformDestroy): Destroy the ATSUStyles in the 23 map. 24 (WebCore::SimpleFontData::getCFStringAttributes): Look up the attributes 25 dictionary in the map and initialize if necessary. 26 1 27 2010-01-08 Adam Barth <abarth@webkit.org> 2 28 -
trunk/WebCore/platform/graphics/SimpleFontData.h
r53036 r53039 212 212 #if USE(ATSUI) 213 213 public: 214 mutable ATSUStyle m_ATSUStyle; 215 mutable bool m_ATSUStyleInitialized; 214 mutable HashMap<unsigned, ATSUStyle> m_ATSUStyleMap; 216 215 mutable bool m_ATSUMirrors; 217 216 mutable bool m_checkedShapesArabic; … … 223 222 #if USE(CORE_TEXT) 224 223 mutable RetainPtr<CTFontRef> m_CTFont; 225 mutable RetainPtr<CFDictionaryRef> m_CFStringAttributes;224 mutable HashMap<unsigned, RetainPtr<CFDictionaryRef> > m_CFStringAttributes; 226 225 #endif 227 226 -
trunk/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp
r52931 r53039 258 258 } 259 259 260 static void disableLigatures(const SimpleFontData* fontData, TypesettingFeatures typesettingFeatures)260 static void disableLigatures(const SimpleFontData* fontData, ATSUStyle atsuStyle, TypesettingFeatures typesettingFeatures) 261 261 { 262 262 // Don't be too aggressive: if the font doesn't contain 'a', then assume that any ligatures it contains are … … 268 268 ATSUFontFeatureType featureTypes[] = { kLigaturesType }; 269 269 ATSUFontFeatureSelector featureSelectors[] = { kCommonLigaturesOffSelector }; 270 OSStatus status = ATSUSetFontFeatures( fontData->m_ATSUStyle, 1, featureTypes, featureSelectors);270 OSStatus status = ATSUSetFontFeatures(atsuStyle, 1, featureTypes, featureSelectors); 271 271 if (status != noErr) 272 272 LOG_ERROR("ATSUSetFontFeatures failed (%d) -- ligatures remain enabled", static_cast<int>(status)); 273 273 } 274 274 275 static void initializeATSUStyle(const SimpleFontData* fontData, TypesettingFeatures typesettingFeatures) 276 { 277 if (fontData->m_ATSUStyleInitialized) 278 return; 275 static ATSUStyle initializeATSUStyle(const SimpleFontData* fontData, TypesettingFeatures typesettingFeatures) 276 { 277 unsigned key = typesettingFeatures + 1; 278 pair<HashMap<unsigned, ATSUStyle>::iterator, bool> addResult = fontData->m_ATSUStyleMap.add(key, 0); 279 ATSUStyle& atsuStyle = addResult.first->second; 280 if (!addResult.second) 281 return atsuStyle; 279 282 280 283 ATSUFontID fontID = fontData->platformData().m_atsuFontID; 281 284 if (!fontID) { 282 285 LOG_ERROR("unable to get ATSUFontID for %p", fontData->platformData().font()); 283 return; 284 } 285 286 OSStatus status = ATSUCreateStyle(&fontData->m_ATSUStyle); 286 fontData->m_ATSUStyleMap.remove(addResult.first); 287 return 0; 288 } 289 290 OSStatus status = ATSUCreateStyle(&atsuStyle); 287 291 if (status != noErr) 288 292 LOG_ERROR("ATSUCreateStyle failed (%d)", static_cast<int>(status)); … … 297 301 298 302 bool allowKerning = typesettingFeatures & Kerning; 299 status = ATSUSetAttributes( fontData->m_ATSUStyle, allowKerning ? 3 : 4, styleTags, styleSizes, styleValues);303 status = ATSUSetAttributes(atsuStyle, allowKerning ? 3 : 4, styleTags, styleSizes, styleValues); 300 304 if (status != noErr) 301 305 LOG_ERROR("ATSUSetAttributes failed (%d)", static_cast<int>(status)); … … 303 307 fontData->m_ATSUMirrors = fontHasMirroringInfo(fontID); 304 308 305 disableLigatures(fontData, typesettingFeatures); 306 307 fontData->m_ATSUStyleInitialized = true; 309 disableLigatures(fontData, atsuStyle, typesettingFeatures); 310 return atsuStyle; 308 311 } 309 312 … … 319 322 m_fallbackFonts->add(fontData); 320 323 321 initializeATSUStyle(fontData, m_font.typesettingFeatures());324 ATSUStyle atsuStyle = initializeATSUStyle(fontData, m_font.typesettingFeatures()); 322 325 323 326 OSStatus status; … … 325 328 UniCharCount runLength = length; 326 329 327 status = ATSUCreateTextLayoutWithTextPtr(cp, 0, length, length, 1, &runLength, & fontData->m_ATSUStyle, &atsuTextLayout);330 status = ATSUCreateTextLayoutWithTextPtr(cp, 0, length, length, 1, &runLength, &atsuStyle, &atsuTextLayout); 328 331 if (status != noErr) { 329 332 LOG_ERROR("ATSUCreateTextLayoutWithTextPtr failed with error %d", static_cast<int>(status)); -
trunk/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
r52931 r53039 149 149 #endif 150 150 #if USE(ATSUI) 151 m_ATSUStyleInitialized = false;152 151 m_ATSUMirrors = false; 153 152 m_checkedShapesArabic = false; … … 318 317 #endif 319 318 #if USE(ATSUI) 320 if (m_ATSUStyleInitialized) 321 ATSUDisposeStyle(m_ATSUStyle); 319 HashMap<unsigned, ATSUStyle>::iterator end = m_ATSUStyleMap.end(); 320 for (HashMap<unsigned, ATSUStyle>::iterator it = m_ATSUStyleMap.begin(); it != end; ++it) 321 ATSUDisposeStyle(it->second); 322 322 #endif 323 323 } … … 447 447 CFDictionaryRef SimpleFontData::getCFStringAttributes(TypesettingFeatures typesettingFeatures) const 448 448 { 449 if (m_CFStringAttributes) 450 return m_CFStringAttributes.get(); 449 unsigned key = typesettingFeatures + 1; 450 pair<HashMap<unsigned, RetainPtr<CFDictionaryRef> >::iterator, bool> addResult = m_CFStringAttributes.add(key, RetainPtr<CFDictionaryRef>()); 451 RetainPtr<CFDictionaryRef>& attributesDictionary = addResult.first->second; 452 if (!addResult.second) 453 return attributesDictionary.get(); 451 454 452 455 bool allowLigatures = platformData().allowsLigatures() || (typesettingFeatures & Ligatures); … … 464 467 const void* valuesWithKerningDisabled[] = { getCTFont(), kerningAdjustment, allowLigatures 465 468 ? ligaturesAllowed : ligaturesNotAllowed }; 466 m_CFStringAttributes.adoptCF(CFDictionaryCreate(NULL, keysWithKerningDisabled, valuesWithKerningDisabled,469 attributesDictionary.adoptCF(CFDictionaryCreate(NULL, keysWithKerningDisabled, valuesWithKerningDisabled, 467 470 sizeof(keysWithKerningDisabled) / sizeof(*keysWithKerningDisabled), 468 471 &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); … … 471 474 static const void* keysWithKerningEnabled[] = { kCTFontAttributeName, kCTLigatureAttributeName }; 472 475 const void* valuesWithKerningEnabled[] = { getCTFont(), allowLigatures ? ligaturesAllowed : ligaturesNotAllowed }; 473 m_CFStringAttributes.adoptCF(CFDictionaryCreate(NULL, keysWithKerningEnabled, valuesWithKerningEnabled,476 attributesDictionary.adoptCF(CFDictionaryCreate(NULL, keysWithKerningEnabled, valuesWithKerningEnabled, 474 477 sizeof(keysWithKerningEnabled) / sizeof(*keysWithKerningEnabled), 475 478 &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 476 479 } 477 480 478 return m_CFStringAttributes.get();481 return attributesDictionary.get(); 479 482 } 480 483
Note:
See TracChangeset
for help on using the changeset viewer.