diff --git a/gfx/drivers_font_renderer/coretext.c b/gfx/drivers_font_renderer/coretext.c index bd94b54a9c..d48b144a36 100644 --- a/gfx/drivers_font_renderer/coretext.c +++ b/gfx/drivers_font_renderer/coretext.c @@ -253,9 +253,12 @@ static bool coretext_font_renderer_create_atlas(CTFontRef face, ct_font_renderer static void *font_renderer_ct_init(const char *font_path, float font_size) { - char err = 0; - CFStringRef cf_font_path = NULL; - CTFontRef face = NULL; + char err = 0; + CFStringRef cf_font_path = NULL; + CTFontRef face = NULL; + CFURLRef url = NULL; + CGDataProviderRef dataProvider = NULL; + CGFontRef theCGFont = NULL; ct_font_renderer_t *handle = (ct_font_renderer_t*) calloc(1, sizeof(*handle)); @@ -273,7 +276,10 @@ static void *font_renderer_ct_init(const char *font_path, float font_size) goto error; } - face = CTFontCreateWithName(cf_font_path, font_size, NULL); + url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cf_font_path, kCFURLPOSIXPathStyle, false); + dataProvider = CGDataProviderCreateWithURL(url); + theCGFont = CGFontCreateWithDataProvider(dataProvider); + face = CTFontCreateWithGraphicsFont(theCGFont, font_size, NULL, NULL); if (!face) { @@ -304,6 +310,21 @@ error: CFRelease(face); face = NULL; } + if (url) + { + CFRelease(url); + url = NULL; + } + if (dataProvider) + { + CFRelease(dataProvider); + dataProvider = NULL; + } + if (theCGFont) + { + CFRelease(theCGFont); + theCGFont = NULL; + } return handle; }