gdi32: On Mac OS X, find fonts using Core Text rather than FontConfig, by default.

This commit is contained in:
Ken Thomases 2012-04-04 17:41:10 -05:00 committed by Alexandre Julliard
parent 272cf2a973
commit 9cb7a97981
3 changed files with 130 additions and 5 deletions

5
configure vendored
View File

@ -2561,7 +2561,7 @@ fi
# Check whether --with-fontconfig was given. # Check whether --with-fontconfig was given.
if test "${with_fontconfig+set}" = set; then : if test "${with_fontconfig+set}" = set; then :
withval=$with_fontconfig; if test "x$withval" = "xno"; then ac_cv_header_fontconfig_fontconfig_h=no; fi withval=$with_fontconfig;
fi fi
@ -4058,6 +4058,7 @@ case $host in
enable_win16=${enable_win16:-yes} enable_win16=${enable_win16:-yes}
fi fi
with_fontconfig=${with_fontconfig:-no}
;; ;;
x86_64*) x86_64*)
if test "x$enable_win64" != "xyes" -a "$cross_compiling" != "yes" if test "x$enable_win64" != "xyes" -a "$cross_compiling" != "yes"
@ -5278,6 +5279,8 @@ OPENGL_LIBS=""
test "x$with_fontconfig" != "xno" || ac_cv_header_fontconfig_fontconfig_h=no
# Check whether --enable-largefile was given. # Check whether --enable-largefile was given.
if test "${enable_largefile+set}" = set; then : if test "${enable_largefile+set}" = set; then :
enableval=$enable_largefile; enableval=$enable_largefile;

View File

@ -43,8 +43,7 @@ AC_ARG_WITH(cups, AS_HELP_STRING([--without-cups],[do not use CUPS]))
AC_ARG_WITH(curses, AS_HELP_STRING([--without-curses],[do not use (n)curses]), AC_ARG_WITH(curses, AS_HELP_STRING([--without-curses],[do not use (n)curses]),
[if test "x$withval" = "xno"; then ac_cv_header_ncurses_h=no; ac_cv_header_curses_h=no; fi]) [if test "x$withval" = "xno"; then ac_cv_header_ncurses_h=no; ac_cv_header_curses_h=no; fi])
AC_ARG_WITH(dbus, AS_HELP_STRING([--without-dbus],[do not use DBus (dynamic device support)])) AC_ARG_WITH(dbus, AS_HELP_STRING([--without-dbus],[do not use DBus (dynamic device support)]))
AC_ARG_WITH(fontconfig,AS_HELP_STRING([--without-fontconfig],[do not use fontconfig]), AC_ARG_WITH(fontconfig,AS_HELP_STRING([--without-fontconfig],[do not use fontconfig]))
[if test "x$withval" = "xno"; then ac_cv_header_fontconfig_fontconfig_h=no; fi])
AC_ARG_WITH(freetype, AS_HELP_STRING([--without-freetype],[do not use the FreeType library])) AC_ARG_WITH(freetype, AS_HELP_STRING([--without-freetype],[do not use the FreeType library]))
AC_ARG_WITH(gettext, AS_HELP_STRING([--without-gettext],[do not use gettext])) AC_ARG_WITH(gettext, AS_HELP_STRING([--without-gettext],[do not use gettext]))
AC_ARG_WITH(gettextpo, AS_HELP_STRING([--with-gettextpo],[use the GetTextPO library to rebuild po files]), AC_ARG_WITH(gettextpo, AS_HELP_STRING([--with-gettextpo],[use the GetTextPO library to rebuild po files]),
@ -142,6 +141,7 @@ case $host in
AC_SUBST(TARGETFLAGS,"-m32") AC_SUBST(TARGETFLAGS,"-m32")
enable_win16=${enable_win16:-yes} enable_win16=${enable_win16:-yes}
fi fi
with_fontconfig=${with_fontconfig:-no}
;; ;;
x86_64*) x86_64*)
if test "x$enable_win64" != "xyes" -a "$cross_compiling" != "yes" if test "x$enable_win64" != "xyes" -a "$cross_compiling" != "yes"
@ -381,6 +381,8 @@ AC_SUBST(OPENGL_LIBS,"")
dnl **** Check for header files **** dnl **** Check for header files ****
test "x$with_fontconfig" != "xno" || ac_cv_header_fontconfig_fontconfig_h=no
AC_SYS_LARGEFILE() AC_SYS_LARGEFILE()
AC_CHECK_HEADERS(\ AC_CHECK_HEADERS(\

View File

@ -2340,9 +2340,9 @@ static BOOL ReadFontDir(const char *dirname, BOOL external_fonts)
return TRUE; return TRUE;
} }
#ifdef SONAME_LIBFONTCONFIG
static void load_fontconfig_fonts(void) static void load_fontconfig_fonts(void)
{ {
#ifdef SONAME_LIBFONTCONFIG
void *fc_handle = NULL; void *fc_handle = NULL;
FcConfig *config; FcConfig *config;
FcPattern *pat; FcPattern *pat;
@ -2408,10 +2408,126 @@ LOAD_FUNCPTR(FcPatternGetString);
pFcObjectSetDestroy(os); pFcObjectSetDestroy(os);
pFcPatternDestroy(pat); pFcPatternDestroy(pat);
sym_not_found: sym_not_found:
#endif
return; return;
} }
#elif defined(HAVE_CARBON_CARBON_H)
static void load_mac_font_callback(const void *value, void *context)
{
CFStringRef pathStr = value;
CFIndex len;
char* path;
len = CFStringGetMaximumSizeOfFileSystemRepresentation(pathStr);
path = HeapAlloc(GetProcessHeap(), 0, len);
if (path && CFStringGetFileSystemRepresentation(pathStr, path, len))
{
TRACE("font file %s\n", path);
AddFontToList(path, NULL, 0, ADDFONT_EXTERNAL_FONT | ADDFONT_ADD_TO_CACHE);
}
HeapFree(GetProcessHeap(), 0, path);
}
static void load_mac_fonts(void)
{
CFStringRef removeDupesKey;
CFBooleanRef removeDupesValue;
CFDictionaryRef options;
CTFontCollectionRef col;
CFArrayRef descs;
CFMutableSetRef paths;
CFIndex i;
removeDupesKey = kCTFontCollectionRemoveDuplicatesOption;
removeDupesValue = kCFBooleanTrue;
options = CFDictionaryCreate(NULL, (const void**)&removeDupesKey, (const void**)&removeDupesValue, 1,
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
col = CTFontCollectionCreateFromAvailableFonts(options);
if (options) CFRelease(options);
if (!col)
{
WARN("CTFontCollectionCreateFromAvailableFonts failed\n");
return;
}
descs = CTFontCollectionCreateMatchingFontDescriptors(col);
CFRelease(col);
if (!descs)
{
WARN("CTFontCollectionCreateMatchingFontDescriptors failed\n");
return;
}
paths = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks);
if (!paths)
{
WARN("CFSetCreateMutable failed\n");
CFRelease(descs);
return;
}
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
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;
}
status = ATSFontGetFileReference(atsFont, &fsref);
CFRelease(font);
if (status != noErr) continue;
url = CFURLCreateFromFSRef(NULL, &fsref);
if (!url) continue;
ext = CFURLCopyPathExtension(url);
if (ext)
{
BOOL skip = (CFStringCompare(ext, CFSTR("pfa"), kCFCompareCaseInsensitive) == kCFCompareEqualTo ||
CFStringCompare(ext, CFSTR("pfb"), kCFCompareCaseInsensitive) == kCFCompareEqualTo);
CFRelease(ext);
if (skip)
{
CFRelease(url);
continue;
}
}
path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
CFRelease(url);
if (!path) continue;
CFSetAddValue(paths, path);
CFRelease(path);
}
CFRelease(descs);
CFSetApplyFunction(paths, load_mac_font_callback, NULL);
CFRelease(paths);
}
#endif
static BOOL load_font_from_data_dir(LPCWSTR file) static BOOL load_font_from_data_dir(LPCWSTR file)
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
@ -3485,7 +3601,11 @@ static void init_font_list(void)
RegCloseKey(hkey); RegCloseKey(hkey);
} }
#ifdef SONAME_LIBFONTCONFIG
load_fontconfig_fonts(); load_fontconfig_fonts();
#elif defined(HAVE_CARBON_CARBON_H)
load_mac_fonts();
#endif
/* then look in any directories that we've specified in the config file */ /* then look in any directories that we've specified in the config file */
/* @@ Wine registry key: HKCU\Software\Wine\Fonts */ /* @@ Wine registry key: HKCU\Software\Wine\Fonts */