Commit d684831f authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

gdi32: Get the font URL directly from the descriptor on macOS 10.6 and later.

It's significantly faster than the roundabout way that's necessary for 10.5, which is especially important for users with many fonts installed. Issue identified by Andrew Eikum. Signed-off-by: 's avatarKen Thomases <ken@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 8e8c991c
......@@ -2933,33 +2933,40 @@ static void load_mac_fonts(void)
for (i = 0; i < CFArrayGetCount(descs); i++)
{
CTFontDescriptorRef desc;
CTFontRef font;
ATSFontRef atsFont;
OSStatus status;
FSRef fsref;
CFURLRef url;
CFStringRef ext;
CFStringRef path;
desc = CFArrayGetValueAtIndex(descs, i);
/* CTFontDescriptor doesn't support kCTFontURLAttribute until 10.6, so
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
url = CTFontDescriptorCopyAttribute(desc, kCTFontURLAttribute);
#else
/* CTFontDescriptor doesn't support kCTFontURLAttribute prior to 10.6, so
we have to go CFFontDescriptor -> CTFont -> ATSFont -> FSRef -> CFURL. */
font = CTFontCreateWithFontDescriptor(desc, 0, NULL);
if (!font) continue;
atsFont = CTFontGetPlatformFont(font, NULL);
if (!atsFont)
{
CFRelease(font);
continue;
}
CTFontRef font;
ATSFontRef atsFont;
OSStatus status;
FSRef fsref;
status = ATSFontGetFileReference(atsFont, &fsref);
CFRelease(font);
if (status != noErr) continue;
font = CTFontCreateWithFontDescriptor(desc, 0, NULL);
if (!font) continue;
url = CFURLCreateFromFSRef(NULL, &fsref);
atsFont = CTFontGetPlatformFont(font, NULL);
if (!atsFont)
{
CFRelease(font);
continue;
}
status = ATSFontGetFileReference(atsFont, &fsref);
CFRelease(font);
if (status != noErr) continue;
url = CFURLCreateFromFSRef(NULL, &fsref);
}
#endif
if (!url) continue;
ext = CFURLCopyPathExtension(url);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment