mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 502795 - avoid using CTFontCreateCopyWithAttributes to disable ligatures because it fails with privately-activated download fonts, r=roc
This commit is contained in:
parent
544d310f74
commit
6f803b386e
@ -109,7 +109,7 @@ public:
|
||||
// clean up static objects that may have been cached
|
||||
static void Shutdown();
|
||||
|
||||
static CTFontRef CreateCopyWithDisabledLigatures(CTFontRef aFont);
|
||||
static CTFontRef CreateCTFontWithDisabledLigatures(ATSFontRef aFont, CGFloat aSize);
|
||||
|
||||
protected:
|
||||
const gfxFontStyle *mFontStyle;
|
||||
|
@ -77,6 +77,26 @@ static PRLogModuleInfo *gCoreTextTextRunLog = PR_NewLogModule("coreTextTextRun")
|
||||
CTFontDescriptorRef gfxCoreTextFont::sDefaultFeaturesDescriptor = NULL;
|
||||
CTFontDescriptorRef gfxCoreTextFont::sDisableLigaturesDescriptor = NULL;
|
||||
|
||||
#ifdef DEBUG_jonathan
|
||||
static void dumpFontDescCallback(const void *key, const void *value, void *context)
|
||||
{
|
||||
CFStringRef attribute = (CFStringRef)key;
|
||||
CFTypeRef setting = (CFTypeRef)value;
|
||||
fprintf(stderr, "attr: "); CFShow(attribute);
|
||||
fprintf(stderr, " = "); CFShow(setting);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
static void
|
||||
dumpFontDescriptor(CTFontRef font)
|
||||
{
|
||||
CTFontDescriptorRef desc = CTFontCopyFontDescriptor(font);
|
||||
CFDictionaryRef dict = CTFontDescriptorCopyAttributes(desc);
|
||||
CFRelease(desc);
|
||||
CFDictionaryApplyFunction(dict, &dumpFontDescCallback, 0);
|
||||
CFRelease(dict);
|
||||
}
|
||||
#endif
|
||||
|
||||
gfxCoreTextFont::gfxCoreTextFont(MacOSFontEntry *aFontEntry,
|
||||
const gfxFontStyle *aFontStyle,
|
||||
@ -451,9 +471,9 @@ gfxCoreTextFont::CreateDefaultFeaturesDescriptor()
|
||||
CFRelease(attributesDict);
|
||||
}
|
||||
|
||||
// Create a copy of a CTFontRef, with the Common Ligatures feature disabled [static]
|
||||
// Create a CTFontRef for an ATS font ref, with the Common Ligatures feature disabled [static]
|
||||
CTFontRef
|
||||
gfxCoreTextFont::CreateCopyWithDisabledLigatures(CTFontRef aFontRef)
|
||||
gfxCoreTextFont::CreateCTFontWithDisabledLigatures(ATSFontRef aFontRef, CGFloat aSize)
|
||||
{
|
||||
if (sDisableLigaturesDescriptor == NULL) {
|
||||
// initialize cached descriptor to turn off the Common Ligatures feature
|
||||
@ -499,16 +519,11 @@ gfxCoreTextFont::CreateCopyWithDisabledLigatures(CTFontRef aFontRef)
|
||||
CFRelease(featuresArray);
|
||||
|
||||
sDisableLigaturesDescriptor =
|
||||
CTFontDescriptorCreateWithAttributes(attributesDict);
|
||||
CTFontDescriptorCreateCopyWithAttributes(GetDefaultFeaturesDescriptor(), attributesDict);
|
||||
CFRelease(attributesDict);
|
||||
}
|
||||
|
||||
aFontRef =
|
||||
CTFontCreateCopyWithAttributes(aFontRef,
|
||||
0.0,
|
||||
NULL,
|
||||
sDisableLigaturesDescriptor);
|
||||
return aFontRef;
|
||||
|
||||
return CTFontCreateWithPlatformFont(aFontRef, aSize, NULL, sDisableLigaturesDescriptor);
|
||||
}
|
||||
|
||||
void
|
||||
@ -759,19 +774,20 @@ gfxCoreTextFontGroup::InitTextRun(gfxTextRun *aTextRun,
|
||||
if (disableLigatures) {
|
||||
// For letterspacing (or maybe other situations) we need to make a copy of the CTFont
|
||||
// with the ligature feature disabled
|
||||
CTFontRef mainCTFont = mainFont->GetCTFont();
|
||||
mainCTFont = gfxCoreTextFont::CreateCopyWithDisabledLigatures(mainCTFont);
|
||||
CTFontRef ctFont =
|
||||
gfxCoreTextFont::CreateCTFontWithDisabledLigatures(mainFont->GetATSFont(),
|
||||
CTFontGetSize(mainFont->GetCTFont()));
|
||||
|
||||
// Set up the initial font, for the (common) case of a monostyled textRun
|
||||
attrObj =
|
||||
CFDictionaryCreate(kCFAllocatorDefault,
|
||||
(const void**) &kCTFontAttributeName,
|
||||
(const void**) &mainCTFont,
|
||||
(const void**) &ctFont,
|
||||
1, // count of attributes
|
||||
&kCFTypeDictionaryKeyCallBacks,
|
||||
&kCFTypeDictionaryValueCallBacks);
|
||||
// Having created the dict, we're finished with our modified copy of the CTFont
|
||||
CFRelease(mainCTFont);
|
||||
// Having created the dict, we're finished with our ligature-disabled CTFontRef
|
||||
CFRelease(ctFont);
|
||||
} else {
|
||||
attrObj = mainFont->GetAttributesDictionary();
|
||||
CFRetain(attrObj);
|
||||
@ -813,7 +829,8 @@ gfxCoreTextFontGroup::InitTextRun(gfxTextRun *aTextRun,
|
||||
if (matchedFont != mainFont) {
|
||||
CTFontRef matchedCTFont = matchedFont->GetCTFont();
|
||||
if (disableLigatures)
|
||||
matchedCTFont = gfxCoreTextFont::CreateCopyWithDisabledLigatures(matchedCTFont);
|
||||
matchedCTFont = gfxCoreTextFont::CreateCTFontWithDisabledLigatures(matchedFont->GetATSFont(),
|
||||
CTFontGetSize(matchedCTFont));
|
||||
// if necessary, make a mutable copy of the string
|
||||
if (!mutableStringObj) {
|
||||
mutableStringObj =
|
||||
|
Loading…
Reference in New Issue
Block a user