|
|
|
|
@@ -511,7 +511,7 @@ CGFontRef CTFontEntry::CreateOrCopyFontRef() {
|
|
|
|
|
CrashReporter::Annotation::FontName, mName);
|
|
|
|
|
|
|
|
|
|
// Create a new CGFont; caller will own the only reference to it.
|
|
|
|
|
AutoCFRelease<CFStringRef> psname = CreateCFStringForString(mName);
|
|
|
|
|
AutoCFTypeRef<CFStringRef> psname(CreateCFStringForString(mName));
|
|
|
|
|
if (!psname) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
@@ -549,7 +549,7 @@ class FontTableRec {
|
|
|
|
|
|
|
|
|
|
hb_blob_t* CTFontEntry::GetFontTable(uint32_t aTag) {
|
|
|
|
|
mLock.ReadLock();
|
|
|
|
|
AutoCFRelease<CGFontRef> fontRef = CreateOrCopyFontRef();
|
|
|
|
|
AutoCFTypeRef<CGFontRef> fontRef(CreateOrCopyFontRef());
|
|
|
|
|
mLock.ReadUnlock();
|
|
|
|
|
if (!fontRef) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
@@ -582,11 +582,11 @@ bool CTFontEntry::HasFontTable(uint32_t aTableTag) {
|
|
|
|
|
|
|
|
|
|
AutoWriteLock lock(mLock);
|
|
|
|
|
if (mAvailableTables.Count() == 0) {
|
|
|
|
|
AutoCFRelease<CGFontRef> fontRef = CreateOrCopyFontRef();
|
|
|
|
|
AutoCFTypeRef<CGFontRef> fontRef(CreateOrCopyFontRef());
|
|
|
|
|
if (!fontRef) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
AutoCFRelease<CFArrayRef> tags = ::CGFontCopyTableTags(fontRef);
|
|
|
|
|
AutoCFTypeRef<CFArrayRef> tags(::CGFontCopyTableTags(fontRef));
|
|
|
|
|
if (!tags) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@@ -679,10 +679,10 @@ bool CTFontEntry::SupportsOpenTypeFeature(Script aScript,
|
|
|
|
|
CrashReporter::AutoRecordAnnotation autoFontName(
|
|
|
|
|
CrashReporter::Annotation::FontName, FamilyName());
|
|
|
|
|
|
|
|
|
|
AutoCFRelease<CTFontRef> ctFont =
|
|
|
|
|
CTFontCreateWithGraphicsFont(cgFont, 0.0, nullptr, nullptr);
|
|
|
|
|
AutoCFTypeRef<CTFontRef> ctFont(
|
|
|
|
|
CTFontCreateWithGraphicsFont(cgFont, 0.0, nullptr, nullptr));
|
|
|
|
|
if (ctFont) {
|
|
|
|
|
AutoCFRelease<CFArrayRef> features = CTFontCopyFeatures(ctFont);
|
|
|
|
|
AutoCFTypeRef<CFArrayRef> features(CTFontCopyFeatures(ctFont));
|
|
|
|
|
if (features) {
|
|
|
|
|
mHasAATSmallCaps = CheckForAATSmallCaps(features);
|
|
|
|
|
}
|
|
|
|
|
@@ -700,14 +700,14 @@ void CTFontEntry::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
|
|
|
|
|
|
|
|
|
static CTFontDescriptorRef CreateDescriptorForFamily(
|
|
|
|
|
const nsACString& aFamilyName, bool aNormalized) {
|
|
|
|
|
AutoCFRelease<CFStringRef> family = CreateCFStringForString(aFamilyName);
|
|
|
|
|
AutoCFTypeRef<CFStringRef> family(CreateCFStringForString(aFamilyName));
|
|
|
|
|
const void* values[] = {family};
|
|
|
|
|
const void* keys[] = {kCTFontFamilyNameAttribute};
|
|
|
|
|
AutoCFRelease<CFDictionaryRef> attributes = CFDictionaryCreate(
|
|
|
|
|
AutoCFTypeRef<CFDictionaryRef> attributes(CFDictionaryCreate(
|
|
|
|
|
kCFAllocatorDefault, keys, values, 1, &kCFTypeDictionaryKeyCallBacks,
|
|
|
|
|
&kCFTypeDictionaryValueCallBacks);
|
|
|
|
|
&kCFTypeDictionaryValueCallBacks));
|
|
|
|
|
|
|
|
|
|
// Not AutoCFRelease, because we might return it.
|
|
|
|
|
// Not AutoCFTypeRef, because we might return it.
|
|
|
|
|
CTFontDescriptorRef descriptor =
|
|
|
|
|
CTFontDescriptorCreateWithAttributes(attributes);
|
|
|
|
|
|
|
|
|
|
@@ -724,12 +724,12 @@ static CTFontDescriptorRef CreateDescriptorForFamily(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CTFontFamily::LocalizedName(nsACString& aLocalizedName) {
|
|
|
|
|
AutoCFRelease<CTFontDescriptorRef> descriptor =
|
|
|
|
|
CreateDescriptorForFamily(mName, true);
|
|
|
|
|
AutoCFTypeRef<CTFontDescriptorRef> descriptor(
|
|
|
|
|
CreateDescriptorForFamily(mName, true));
|
|
|
|
|
if (descriptor) {
|
|
|
|
|
AutoCFRelease<CFStringRef> name =
|
|
|
|
|
AutoCFTypeRef<CFStringRef> name(
|
|
|
|
|
static_cast<CFStringRef>(CTFontDescriptorCopyLocalizedAttribute(
|
|
|
|
|
descriptor, kCTFontFamilyNameAttribute, nullptr));
|
|
|
|
|
descriptor, kCTFontFamilyNameAttribute, nullptr)));
|
|
|
|
|
if (name) {
|
|
|
|
|
nsAutoString localized;
|
|
|
|
|
GetStringForCFString(name, localized);
|
|
|
|
|
@@ -824,15 +824,15 @@ static inline FontStretch CoreTextWidthToCSSStretch(CGFloat aCTWidth) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CTFontFamily::AddFace(CTFontDescriptorRef aFace) {
|
|
|
|
|
AutoCFRelease<CFStringRef> psname =
|
|
|
|
|
(CFStringRef)CTFontDescriptorCopyAttribute(aFace, kCTFontNameAttribute);
|
|
|
|
|
AutoCFRelease<CFStringRef> facename =
|
|
|
|
|
AutoCFTypeRef<CFStringRef> psname(
|
|
|
|
|
(CFStringRef)CTFontDescriptorCopyAttribute(aFace, kCTFontNameAttribute));
|
|
|
|
|
AutoCFTypeRef<CFStringRef> facename(
|
|
|
|
|
(CFStringRef)CTFontDescriptorCopyAttribute(aFace,
|
|
|
|
|
kCTFontStyleNameAttribute);
|
|
|
|
|
kCTFontStyleNameAttribute));
|
|
|
|
|
|
|
|
|
|
AutoCFRelease<CFDictionaryRef> traitsDict =
|
|
|
|
|
AutoCFTypeRef<CFDictionaryRef> traitsDict(
|
|
|
|
|
(CFDictionaryRef)CTFontDescriptorCopyAttribute(aFace,
|
|
|
|
|
kCTFontTraitsAttribute);
|
|
|
|
|
kCTFontTraitsAttribute));
|
|
|
|
|
CFNumberRef weight =
|
|
|
|
|
(CFNumberRef)CFDictionaryGetValue(traitsDict, kCTFontWeightTrait);
|
|
|
|
|
CFNumberRef width =
|
|
|
|
|
@@ -921,7 +921,7 @@ void CTFontFamily::FindStyleVariationsLocked(FontInfoData* aFontInfoData) {
|
|
|
|
|
MOZ_ASSERT(gfxPlatform::HasVariationFontSupport());
|
|
|
|
|
|
|
|
|
|
auto addToFamily = [&](CTFontRef aFont) MOZ_REQUIRES(mLock) {
|
|
|
|
|
AutoCFRelease<CFStringRef> psName = CTFontCopyPostScriptName(aFont);
|
|
|
|
|
AutoCFTypeRef<CFStringRef> psName(CTFontCopyPostScriptName(aFont));
|
|
|
|
|
nsAutoString nameUTF16;
|
|
|
|
|
nsAutoCString nameUTF8;
|
|
|
|
|
GetStringForCFString(psName, nameUTF16);
|
|
|
|
|
@@ -944,8 +944,8 @@ void CTFontFamily::FindStyleVariationsLocked(FontInfoData* aFontInfoData) {
|
|
|
|
|
addToFamily(mForSystemFont);
|
|
|
|
|
|
|
|
|
|
// See if there is a corresponding italic face, and add it to the family.
|
|
|
|
|
AutoCFRelease<CTFontRef> italicFont = CTFontCreateCopyWithSymbolicTraits(
|
|
|
|
|
mForSystemFont, 0.0, nullptr, kCTFontTraitItalic, kCTFontTraitItalic);
|
|
|
|
|
AutoCFTypeRef<CTFontRef> italicFont(CTFontCreateCopyWithSymbolicTraits(
|
|
|
|
|
mForSystemFont, 0.0, nullptr, kCTFontTraitItalic, kCTFontTraitItalic));
|
|
|
|
|
if (italicFont != mForSystemFont) {
|
|
|
|
|
addToFamily(italicFont);
|
|
|
|
|
}
|
|
|
|
|
@@ -979,10 +979,10 @@ void CTFontFamily::FindStyleVariationsLocked(FontInfoData* aFontInfoData) {
|
|
|
|
|
MOZ_POP_THREAD_SAFETY;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AutoCFRelease<CTFontDescriptorRef> descriptor =
|
|
|
|
|
CreateDescriptorForFamily(mName, false);
|
|
|
|
|
AutoCFRelease<CFArrayRef> faces =
|
|
|
|
|
CTFontDescriptorCreateMatchingFontDescriptors(descriptor, nullptr);
|
|
|
|
|
AutoCFTypeRef<CTFontDescriptorRef> descriptor(
|
|
|
|
|
CreateDescriptorForFamily(mName, false));
|
|
|
|
|
AutoCFTypeRef<CFArrayRef> faces(
|
|
|
|
|
CTFontDescriptorCreateMatchingFontDescriptors(descriptor, nullptr));
|
|
|
|
|
|
|
|
|
|
if (faces) {
|
|
|
|
|
Context context{this};
|
|
|
|
|
@@ -1070,21 +1070,21 @@ void CoreTextFontList::AddFamily(CFStringRef aFamily) {
|
|
|
|
|
/* static */
|
|
|
|
|
void CoreTextFontList::ActivateFontsFromDir(
|
|
|
|
|
const nsACString& aDir, nsTHashSet<nsCStringHashKey>* aLoadedFamilies) {
|
|
|
|
|
AutoCFRelease<CFURLRef> directory = CFURLCreateFromFileSystemRepresentation(
|
|
|
|
|
AutoCFTypeRef<CFURLRef> directory(CFURLCreateFromFileSystemRepresentation(
|
|
|
|
|
kCFAllocatorDefault, (const UInt8*)nsPromiseFlatCString(aDir).get(),
|
|
|
|
|
aDir.Length(), true);
|
|
|
|
|
aDir.Length(), true));
|
|
|
|
|
if (!directory) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
AutoCFRelease<CFURLEnumeratorRef> enumerator =
|
|
|
|
|
AutoCFTypeRef<CFURLEnumeratorRef> enumerator(
|
|
|
|
|
CFURLEnumeratorCreateForDirectoryURL(kCFAllocatorDefault, directory,
|
|
|
|
|
kCFURLEnumeratorDefaultBehavior,
|
|
|
|
|
nullptr);
|
|
|
|
|
nullptr));
|
|
|
|
|
if (!enumerator) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
AutoCFRelease<CFMutableArrayRef> urls =
|
|
|
|
|
CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
|
|
|
|
|
AutoCFTypeRef<CFMutableArrayRef> urls(
|
|
|
|
|
CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks));
|
|
|
|
|
if (!urls) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -1101,16 +1101,15 @@ void CoreTextFontList::ActivateFontsFromDir(
|
|
|
|
|
if (!aLoadedFamilies) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
AutoCFRelease<CFArrayRef> descriptors =
|
|
|
|
|
CTFontManagerCreateFontDescriptorsFromURL(url);
|
|
|
|
|
AutoCFTypeRef<CFArrayRef> descriptors(
|
|
|
|
|
CTFontManagerCreateFontDescriptorsFromURL(url));
|
|
|
|
|
if (!descriptors || !CFArrayGetCount(descriptors)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
CTFontDescriptorRef desc =
|
|
|
|
|
(CTFontDescriptorRef)CFArrayGetValueAtIndex(descriptors, 0);
|
|
|
|
|
AutoCFRelease<CFStringRef> name =
|
|
|
|
|
(CFStringRef)CTFontDescriptorCopyAttribute(desc,
|
|
|
|
|
kCTFontFamilyNameAttribute);
|
|
|
|
|
AutoCFTypeRef<CFStringRef> name((CFStringRef)CTFontDescriptorCopyAttribute(
|
|
|
|
|
desc, kCTFontFamilyNameAttribute));
|
|
|
|
|
nsAutoCString key;
|
|
|
|
|
key.SetLength((CFStringGetLength(name) + 1) * 3);
|
|
|
|
|
if (CFStringGetCString(name, key.BeginWriting(), key.Length(),
|
|
|
|
|
@@ -1177,8 +1176,8 @@ nsresult CoreTextFontList::InitFontListForPlatform() {
|
|
|
|
|
|
|
|
|
|
// We're not a content process, so get the available fonts directly
|
|
|
|
|
// from Core Text.
|
|
|
|
|
AutoCFRelease<CFArrayRef> familyNames =
|
|
|
|
|
CTFontManagerCopyAvailableFontFamilyNames();
|
|
|
|
|
AutoCFTypeRef<CFArrayRef> familyNames(
|
|
|
|
|
CTFontManagerCopyAvailableFontFamilyNames());
|
|
|
|
|
for (CFIndex i = 0; i < CFArrayGetCount(familyNames); i++) {
|
|
|
|
|
CFStringRef familyName =
|
|
|
|
|
(CFStringRef)CFArrayGetValueAtIndex(familyNames, i);
|
|
|
|
|
@@ -1245,8 +1244,8 @@ void CoreTextFontList::InitSharedFontListForPlatform() {
|
|
|
|
|
firstTime = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AutoCFRelease<CFArrayRef> familyNames =
|
|
|
|
|
CTFontManagerCopyAvailableFontFamilyNames();
|
|
|
|
|
AutoCFTypeRef<CFArrayRef> familyNames(
|
|
|
|
|
CTFontManagerCopyAvailableFontFamilyNames());
|
|
|
|
|
nsTArray<fontlist::Family::InitData> families;
|
|
|
|
|
families.SetCapacity(CFArrayGetCount(familyNames)
|
|
|
|
|
#if USE_DEPRECATED_FONT_FAMILY_NAMES
|
|
|
|
|
@@ -1347,11 +1346,11 @@ gfxFontEntry* CoreTextFontList::PlatformGlobalFontFallback(
|
|
|
|
|
mDefaultFont = CTFontCreateWithName(CFSTR("LucidaGrande"), 12.f, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AutoCFRelease<CTFontRef> fallback =
|
|
|
|
|
CTFontCreateForString(mDefaultFont, str, CFRangeMake(0, length));
|
|
|
|
|
AutoCFTypeRef<CTFontRef> fallback(
|
|
|
|
|
CTFontCreateForString(mDefaultFont, str, CFRangeMake(0, length)));
|
|
|
|
|
|
|
|
|
|
if (fallback) {
|
|
|
|
|
AutoCFRelease<CFStringRef> familyNameRef = CTFontCopyFamilyName(fallback);
|
|
|
|
|
AutoCFTypeRef<CFStringRef> familyNameRef(CTFontCopyFamilyName(fallback));
|
|
|
|
|
|
|
|
|
|
if (familyNameRef &&
|
|
|
|
|
CFStringCompare(familyNameRef, CFSTR("LastResort"),
|
|
|
|
|
@@ -1432,13 +1431,13 @@ gfxFontEntry* CoreTextFontList::LookupLocalFont(
|
|
|
|
|
CrashReporter::AutoRecordAnnotation autoFontName(
|
|
|
|
|
CrashReporter::Annotation::FontName, aFontName);
|
|
|
|
|
|
|
|
|
|
AutoCFRelease<CFStringRef> faceName = CreateCFStringForString(aFontName);
|
|
|
|
|
AutoCFTypeRef<CFStringRef> faceName(CreateCFStringForString(aFontName));
|
|
|
|
|
if (!faceName) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// lookup face based on postscript or full name
|
|
|
|
|
AutoCFRelease<CGFontRef> fontRef = CGFontCreateWithFontName(faceName);
|
|
|
|
|
AutoCFTypeRef<CGFontRef> fontRef(CGFontCreateWithFontName(faceName));
|
|
|
|
|
if (!fontRef) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
@@ -1449,12 +1448,12 @@ gfxFontEntry* CoreTextFontList::LookupLocalFont(
|
|
|
|
|
// is allowed to be used.
|
|
|
|
|
|
|
|
|
|
// CGFontRef doesn't offer a family-name API, so we go via a CTFontRef.
|
|
|
|
|
AutoCFRelease<CTFontRef> ctFont =
|
|
|
|
|
CTFontCreateWithGraphicsFont(fontRef, 0.0, nullptr, nullptr);
|
|
|
|
|
AutoCFTypeRef<CTFontRef> ctFont(
|
|
|
|
|
CTFontCreateWithGraphicsFont(fontRef, 0.0, nullptr, nullptr));
|
|
|
|
|
if (!ctFont) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
AutoCFRelease<CFStringRef> name = CTFontCopyFamilyName(ctFont);
|
|
|
|
|
AutoCFTypeRef<CFStringRef> name(CTFontCopyFamilyName(ctFont));
|
|
|
|
|
// Convert the family name to a key suitable for font-list lookup (8-bit,
|
|
|
|
|
// lowercased).
|
|
|
|
|
nsAutoCString key;
|
|
|
|
|
@@ -1510,9 +1509,9 @@ gfxFontEntry* CoreTextFontList::MakePlatformFont(const nsACString& aFontName,
|
|
|
|
|
CrashReporter::AutoRecordAnnotation autoFontName(
|
|
|
|
|
CrashReporter::Annotation::FontName, aFontName);
|
|
|
|
|
|
|
|
|
|
AutoCFRelease<CGDataProviderRef> provider =
|
|
|
|
|
::CGDataProviderCreateWithData(nullptr, aFontData, aLength, &ReleaseData);
|
|
|
|
|
AutoCFRelease<CGFontRef> fontRef = ::CGFontCreateWithDataProvider(provider);
|
|
|
|
|
AutoCFTypeRef<CGDataProviderRef> provider(::CGDataProviderCreateWithData(
|
|
|
|
|
nullptr, aFontData, aLength, &ReleaseData));
|
|
|
|
|
AutoCFTypeRef<CGFontRef> fontRef(::CGFontCreateWithDataProvider(provider));
|
|
|
|
|
if (!fontRef) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
@@ -1576,16 +1575,16 @@ void CTFontInfo::LoadFontFamilyData(const nsACString& aFamilyName) {
|
|
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
|
|
|
|
|
|
|
|
|
// family name ==> CTFontDescriptor
|
|
|
|
|
AutoCFRelease<CFStringRef> family = CreateCFStringForString(aFamilyName);
|
|
|
|
|
AutoCFTypeRef<CFStringRef> family(CreateCFStringForString(aFamilyName));
|
|
|
|
|
|
|
|
|
|
AutoCFRelease<CFMutableDictionaryRef> attr =
|
|
|
|
|
AutoCFTypeRef<CFMutableDictionaryRef> attr(
|
|
|
|
|
CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks,
|
|
|
|
|
&kCFTypeDictionaryValueCallBacks);
|
|
|
|
|
&kCFTypeDictionaryValueCallBacks));
|
|
|
|
|
CFDictionaryAddValue(attr, kCTFontFamilyNameAttribute, family);
|
|
|
|
|
AutoCFRelease<CTFontDescriptorRef> fd =
|
|
|
|
|
CTFontDescriptorCreateWithAttributes(attr);
|
|
|
|
|
AutoCFRelease<CFArrayRef> matchingFonts =
|
|
|
|
|
CTFontDescriptorCreateMatchingFontDescriptors(fd, NULL);
|
|
|
|
|
AutoCFTypeRef<CTFontDescriptorRef> fd(
|
|
|
|
|
CTFontDescriptorCreateWithAttributes(attr));
|
|
|
|
|
AutoCFTypeRef<CFArrayRef> matchingFonts(
|
|
|
|
|
CTFontDescriptorCreateMatchingFontDescriptors(fd, NULL));
|
|
|
|
|
if (!matchingFonts) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -1610,8 +1609,8 @@ void CTFontInfo::LoadFontFamilyData(const nsACString& aFamilyName) {
|
|
|
|
|
}
|
|
|
|
|
prevFace = faceDesc;
|
|
|
|
|
|
|
|
|
|
AutoCFRelease<CTFontRef> fontRef =
|
|
|
|
|
CTFontCreateWithFontDescriptor(faceDesc, 0.0, nullptr);
|
|
|
|
|
AutoCFTypeRef<CTFontRef> fontRef(
|
|
|
|
|
CTFontCreateWithFontDescriptor(faceDesc, 0.0, nullptr));
|
|
|
|
|
if (!fontRef) {
|
|
|
|
|
NS_WARNING("failed to create a CTFontRef");
|
|
|
|
|
continue;
|
|
|
|
|
@@ -1619,9 +1618,9 @@ void CTFontInfo::LoadFontFamilyData(const nsACString& aFamilyName) {
|
|
|
|
|
|
|
|
|
|
if (mLoadCmaps) {
|
|
|
|
|
// face name
|
|
|
|
|
AutoCFRelease<CFStringRef> faceName =
|
|
|
|
|
AutoCFTypeRef<CFStringRef> faceName(
|
|
|
|
|
(CFStringRef)CTFontDescriptorCopyAttribute(faceDesc,
|
|
|
|
|
kCTFontNameAttribute);
|
|
|
|
|
kCTFontNameAttribute));
|
|
|
|
|
|
|
|
|
|
AutoTArray<UniChar, 1024> buffer;
|
|
|
|
|
CFIndex len = CFStringGetLength(faceName);
|
|
|
|
|
@@ -1633,8 +1632,8 @@ void CTFontInfo::LoadFontFamilyData(const nsACString& aFamilyName) {
|
|
|
|
|
|
|
|
|
|
// load the cmap data
|
|
|
|
|
FontFaceData fontData;
|
|
|
|
|
AutoCFRelease<CFDataRef> cmapTable = CTFontCopyTable(
|
|
|
|
|
fontRef, kCTFontTableCmap, kCTFontTableOptionNoOptions);
|
|
|
|
|
AutoCFTypeRef<CFDataRef> cmapTable(CTFontCopyTable(
|
|
|
|
|
fontRef, kCTFontTableCmap, kCTFontTableOptionNoOptions));
|
|
|
|
|
|
|
|
|
|
if (cmapTable) {
|
|
|
|
|
const uint8_t* cmapData = (const uint8_t*)CFDataGetBytePtr(cmapTable);
|
|
|
|
|
@@ -1655,8 +1654,8 @@ void CTFontInfo::LoadFontFamilyData(const nsACString& aFamilyName) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mLoadOtherNames && hasOtherFamilyNames) {
|
|
|
|
|
AutoCFRelease<CFDataRef> nameTable = CTFontCopyTable(
|
|
|
|
|
fontRef, kCTFontTableName, kCTFontTableOptionNoOptions);
|
|
|
|
|
AutoCFTypeRef<CFDataRef> nameTable(CTFontCopyTable(
|
|
|
|
|
fontRef, kCTFontTableName, kCTFontTableOptionNoOptions));
|
|
|
|
|
|
|
|
|
|
if (nameTable) {
|
|
|
|
|
const char* nameData = (const char*)CFDataGetBytePtr(nameTable);
|
|
|
|
|
@@ -1702,15 +1701,14 @@ gfxFontEntry* CoreTextFontList::CreateFontEntry(
|
|
|
|
|
void CoreTextFontList::AddFaceInitData(
|
|
|
|
|
CTFontDescriptorRef aFontDesc, nsTArray<fontlist::Face::InitData>& aFaces,
|
|
|
|
|
bool aLoadCmaps) {
|
|
|
|
|
AutoCFRelease<CFStringRef> psname =
|
|
|
|
|
AutoCFTypeRef<CFStringRef> psname((CFStringRef)CTFontDescriptorCopyAttribute(
|
|
|
|
|
aFontDesc, kCTFontNameAttribute));
|
|
|
|
|
AutoCFTypeRef<CFStringRef> facename(
|
|
|
|
|
(CFStringRef)CTFontDescriptorCopyAttribute(aFontDesc,
|
|
|
|
|
kCTFontNameAttribute);
|
|
|
|
|
AutoCFRelease<CFStringRef> facename =
|
|
|
|
|
(CFStringRef)CTFontDescriptorCopyAttribute(aFontDesc,
|
|
|
|
|
kCTFontStyleNameAttribute);
|
|
|
|
|
AutoCFRelease<CFDictionaryRef> traitsDict =
|
|
|
|
|
kCTFontStyleNameAttribute));
|
|
|
|
|
AutoCFTypeRef<CFDictionaryRef> traitsDict(
|
|
|
|
|
(CFDictionaryRef)CTFontDescriptorCopyAttribute(aFontDesc,
|
|
|
|
|
kCTFontTraitsAttribute);
|
|
|
|
|
kCTFontTraitsAttribute));
|
|
|
|
|
|
|
|
|
|
CFNumberRef weight =
|
|
|
|
|
(CFNumberRef)CFDictionaryGetValue(traitsDict, kCTFontWeightTrait);
|
|
|
|
|
@@ -1752,11 +1750,11 @@ void CoreTextFontList::AddFaceInitData(
|
|
|
|
|
|
|
|
|
|
RefPtr<gfxCharacterMap> charmap;
|
|
|
|
|
if (aLoadCmaps) {
|
|
|
|
|
AutoCFRelease<CGFontRef> font =
|
|
|
|
|
CGFontCreateWithFontName(CFStringRef(psname));
|
|
|
|
|
AutoCFTypeRef<CGFontRef> font(
|
|
|
|
|
CGFontCreateWithFontName(CFStringRef(psname)));
|
|
|
|
|
if (font) {
|
|
|
|
|
uint32_t kCMAP = TRUETYPE_TAG('c', 'm', 'a', 'p');
|
|
|
|
|
AutoCFRelease<CFDataRef> data = CGFontCopyTableForTag(font, kCMAP);
|
|
|
|
|
AutoCFTypeRef<CFDataRef> data(CGFontCopyTableForTag(font, kCMAP));
|
|
|
|
|
if (data) {
|
|
|
|
|
uint32_t offset;
|
|
|
|
|
charmap = new gfxCharacterMap();
|
|
|
|
|
@@ -1808,10 +1806,10 @@ void CoreTextFontList::GetFacesInitDataForFamily(
|
|
|
|
|
context->mLoadCmaps);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AutoCFRelease<CTFontDescriptorRef> descriptor =
|
|
|
|
|
CreateDescriptorForFamily(name, false);
|
|
|
|
|
AutoCFRelease<CFArrayRef> faces =
|
|
|
|
|
CTFontDescriptorCreateMatchingFontDescriptors(descriptor, nullptr);
|
|
|
|
|
AutoCFTypeRef<CTFontDescriptorRef> descriptor(
|
|
|
|
|
CreateDescriptorForFamily(name, false));
|
|
|
|
|
AutoCFTypeRef<CFArrayRef> faces(
|
|
|
|
|
CTFontDescriptorCreateMatchingFontDescriptors(descriptor, nullptr));
|
|
|
|
|
|
|
|
|
|
if (faces) {
|
|
|
|
|
Context context{aFaces, aLoadCmaps};
|
|
|
|
|
@@ -1869,14 +1867,14 @@ void CoreTextFontList::ReadFaceNamesForFamily(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static CFStringRef CopyRealFamilyName(CTFontRef aFont) {
|
|
|
|
|
AutoCFRelease<CFStringRef> psName = CTFontCopyPostScriptName(aFont);
|
|
|
|
|
AutoCFRelease<CGFontRef> cgFont =
|
|
|
|
|
CGFontCreateWithFontName(CFStringRef(psName));
|
|
|
|
|
AutoCFTypeRef<CFStringRef> psName(CTFontCopyPostScriptName(aFont));
|
|
|
|
|
AutoCFTypeRef<CGFontRef> cgFont(
|
|
|
|
|
CGFontCreateWithFontName(CFStringRef(psName)));
|
|
|
|
|
if (!cgFont) {
|
|
|
|
|
return CTFontCopyFamilyName(aFont);
|
|
|
|
|
}
|
|
|
|
|
AutoCFRelease<CTFontRef> ctFont =
|
|
|
|
|
CTFontCreateWithGraphicsFont(cgFont, 0.0, nullptr, nullptr);
|
|
|
|
|
AutoCFTypeRef<CTFontRef> ctFont(
|
|
|
|
|
CTFontCreateWithGraphicsFont(cgFont, 0.0, nullptr, nullptr));
|
|
|
|
|
if (!ctFont) {
|
|
|
|
|
return CTFontCopyFamilyName(aFont);
|
|
|
|
|
}
|
|
|
|
|
@@ -1885,9 +1883,9 @@ static CFStringRef CopyRealFamilyName(CTFontRef aFont) {
|
|
|
|
|
|
|
|
|
|
void CoreTextFontList::InitSystemFontNames() {
|
|
|
|
|
// text font family
|
|
|
|
|
AutoCFRelease<CTFontRef> font = CTFontCreateUIFontForLanguage(
|
|
|
|
|
kCTFontUIFontSystem, 0.0, nullptr); // TODO: language
|
|
|
|
|
AutoCFRelease<CFStringRef> name = CopyRealFamilyName(font);
|
|
|
|
|
AutoCFTypeRef<CTFontRef> font(CTFontCreateUIFontForLanguage(
|
|
|
|
|
kCTFontUIFontSystem, 0.0, nullptr)); // TODO: language
|
|
|
|
|
AutoCFTypeRef<CFStringRef> name(CopyRealFamilyName(font));
|
|
|
|
|
|
|
|
|
|
nsAutoString familyName;
|
|
|
|
|
GetStringForCFString(name, familyName);
|
|
|
|
|
@@ -1908,9 +1906,9 @@ void CoreTextFontList::InitSystemFontNames() {
|
|
|
|
|
FontFamily CoreTextFontList::GetDefaultFontForPlatform(
|
|
|
|
|
nsPresContext* aPresContext, const gfxFontStyle* aStyle,
|
|
|
|
|
nsAtom* aLanguage) {
|
|
|
|
|
AutoCFRelease<CTFontRef> font = CTFontCreateUIFontForLanguage(
|
|
|
|
|
kCTFontUIFontUser, 0.0, nullptr); // TODO: language
|
|
|
|
|
AutoCFRelease<CFStringRef> name = CTFontCopyFamilyName(font);
|
|
|
|
|
AutoCFTypeRef<CTFontRef> font(CTFontCreateUIFontForLanguage(
|
|
|
|
|
kCTFontUIFontUser, 0.0, nullptr)); // TODO: language
|
|
|
|
|
AutoCFTypeRef<CFStringRef> name(CTFontCopyFamilyName(font));
|
|
|
|
|
|
|
|
|
|
nsAutoString familyName;
|
|
|
|
|
GetStringForCFString(name, familyName);
|
|
|
|
|
|