Commit 3c166d67 authored by Felix Paul Kühne's avatar Felix Paul Kühne

freetype/darwin: fix error path when font lookup fails

parent 2506d446
...@@ -72,6 +72,8 @@ void addNewFontToFamily(filter_t *p_filter, CTFontDescriptorRef iter, char *path ...@@ -72,6 +72,8 @@ void addNewFontToFamily(filter_t *p_filter, CTFontDescriptorRef iter, char *path
#ifndef NDEBUG #ifndef NDEBUG
msg_Dbg(p_filter, "New font: bold %i italic %i path '%s'", b_bold, b_italic, path); msg_Dbg(p_filter, "New font: bold %i italic %i path '%s'", b_bold, b_italic, path);
#else
VLC_UNUSED(p_filter);
#endif #endif
NewFont(path, 0, b_bold, b_italic, p_family); NewFont(path, 0, b_bold, b_italic, p_family);
...@@ -98,11 +100,8 @@ const vlc_family_t *CoreText_GetFamily(filter_t *p_filter, const char *psz_famil ...@@ -98,11 +100,8 @@ const vlc_family_t *CoreText_GetFamily(filter_t *p_filter, const char *psz_famil
return p_family; return p_family;
} }
/* create a new family object */ CTFontCollectionRef coreTextFontCollection = NULL;
p_family = NewFamily(p_filter, psz_lc, &p_sys->p_families, &p_sys->family_map, psz_lc); CFArrayRef matchedFontDescriptions = NULL;
if (unlikely(!p_family)) {
return NULL;
}
/* we search for family name, display name and name to find them all */ /* we search for family name, display name and name to find them all */
const size_t numberOfAttributes = 3; const size_t numberOfAttributes = 3;
...@@ -131,14 +130,26 @@ const vlc_family_t *CoreText_GetFamily(filter_t *p_filter, const char *psz_famil ...@@ -131,14 +130,26 @@ const vlc_family_t *CoreText_GetFamily(filter_t *p_filter, const char *psz_famil
(const void **)&coreTextFontDescriptors, (const void **)&coreTextFontDescriptors,
numberOfAttributes, NULL); numberOfAttributes, NULL);
CTFontCollectionRef coreTextFontCollection = CTFontCollectionCreateWithFontDescriptors(coreTextFontDescriptorsArray, 0); coreTextFontCollection = CTFontCollectionCreateWithFontDescriptors(coreTextFontDescriptorsArray, 0);
if (coreTextFontCollection == NULL) {
goto end;
}
CFArrayRef matchedFontDescriptions = CTFontCollectionCreateMatchingFontDescriptors(coreTextFontCollection); matchedFontDescriptions = CTFontCollectionCreateMatchingFontDescriptors(coreTextFontCollection);
if (matchedFontDescriptions == NULL) {
goto end;
}
CFIndex numberOfFoundFontDescriptions = CFArrayGetCount(matchedFontDescriptions); CFIndex numberOfFoundFontDescriptions = CFArrayGetCount(matchedFontDescriptions);
char *path = NULL; char *path = NULL;
/* create a new family object */
p_family = NewFamily(p_filter, psz_lc, &p_sys->p_families, &p_sys->family_map, psz_lc);
if (unlikely(!p_family)) {
goto end;
}
for (CFIndex i = 0; i < numberOfFoundFontDescriptions; i++) { for (CFIndex i = 0; i < numberOfFoundFontDescriptions; i++) {
CTFontDescriptorRef iter = CFArrayGetValueAtIndex(matchedFontDescriptions, i); CTFontDescriptorRef iter = CFArrayGetValueAtIndex(matchedFontDescriptions, i);
path = getPathForFontDescription(iter); path = getPathForFontDescription(iter);
...@@ -154,8 +165,13 @@ const vlc_family_t *CoreText_GetFamily(filter_t *p_filter, const char *psz_famil ...@@ -154,8 +165,13 @@ const vlc_family_t *CoreText_GetFamily(filter_t *p_filter, const char *psz_famil
addNewFontToFamily(p_filter, iter, path, p_family); addNewFontToFamily(p_filter, iter, path, p_family);
} }
CFRelease(matchedFontDescriptions); end:
CFRelease(coreTextFontCollection); if (matchedFontDescriptions != NULL) {
CFRelease(matchedFontDescriptions);
}
if (coreTextFontCollection != NULL) {
CFRelease(coreTextFontCollection);
}
for (size_t x = 0; x < numberOfAttributes; x++) { for (size_t x = 0; x < numberOfAttributes; x++) {
CFRelease(coreTextAttributes[x]); CFRelease(coreTextAttributes[x]);
......
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