SimpleFontDataCoreText.cpp [plain text]
#include "config.h"
#include "SimpleFontData.h"
#if !PLATFORM(IOS)
#include <ApplicationServices/ApplicationServices.h>
#else
#include <CoreText/CoreText.h>
#endif
namespace WebCore {
CFDictionaryRef SimpleFontData::getCFStringAttributes(TypesettingFeatures typesettingFeatures, FontOrientation orientation) const
{
unsigned key = typesettingFeatures + 1;
HashMap<unsigned, RetainPtr<CFDictionaryRef>>::AddResult addResult = m_CFStringAttributes.add(key, RetainPtr<CFDictionaryRef>());
RetainPtr<CFDictionaryRef>& attributesDictionary = addResult.iterator->value;
if (!addResult.isNewEntry)
return attributesDictionary.get();
attributesDictionary = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 4, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
CFMutableDictionaryRef mutableAttributes = (CFMutableDictionaryRef)attributesDictionary.get();
CFDictionarySetValue(mutableAttributes, kCTFontAttributeName, platformData().ctFont());
if (!(typesettingFeatures & Kerning)) {
const float zero = 0;
static CFNumberRef zeroKerningValue = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &zero);
CFDictionarySetValue(mutableAttributes, kCTKernAttributeName, zeroKerningValue);
}
bool allowLigatures = (orientation == Horizontal && platformData().allowsLigatures()) || (typesettingFeatures & Ligatures);
if (!allowLigatures) {
const int zero = 0;
static CFNumberRef essentialLigaturesValue = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &zero);
CFDictionarySetValue(mutableAttributes, kCTLigatureAttributeName, essentialLigaturesValue);
}
if (orientation == Vertical)
CFDictionarySetValue(mutableAttributes, kCTVerticalFormsAttributeName, kCFBooleanTrue);
return attributesDictionary.get();
}
}