Module: wine Branch: master Commit: d684831f4a6c420e76f4ba9dc5a2e6d033e555c8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d684831f4a6c420e76f4ba9dc5...
Author: Ken Thomases ken@codeweavers.com Date: Tue Nov 29 11:22:32 2016 -0600
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: Ken Thomases ken@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/gdi32/freetype.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 0e82e5e..a5147b5 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -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);