(CoreText) Check first if path is valid
This commit is contained in:
parent
8d9812985b
commit
b9d7be372f
|
@ -262,13 +262,14 @@ static void *font_renderer_ct_init(const char *font_path, float font_size)
|
||||||
ct_font_renderer_t *handle = (ct_font_renderer_t*)
|
ct_font_renderer_t *handle = (ct_font_renderer_t*)
|
||||||
calloc(1, sizeof(*handle));
|
calloc(1, sizeof(*handle));
|
||||||
|
|
||||||
if (!handle)
|
if (!handle || !string_is_valid(font_path))
|
||||||
{
|
{
|
||||||
err = 1;
|
err = 1;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
cf_font_path = CFStringCreateWithCString(NULL, font_path, kCFStringEncodingASCII);
|
cf_font_path = CFStringCreateWithCString(
|
||||||
|
NULL, font_path, kCFStringEncodingASCII);
|
||||||
|
|
||||||
if (!cf_font_path)
|
if (!cf_font_path)
|
||||||
{
|
{
|
||||||
|
@ -276,7 +277,8 @@ static void *font_renderer_ct_init(const char *font_path, float font_size)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cf_font_path, kCFURLPOSIXPathStyle, false);
|
url = CFURLCreateWithFileSystemPath(
|
||||||
|
kCFAllocatorDefault, cf_font_path, kCFURLPOSIXPathStyle, false);
|
||||||
dataProvider = CGDataProviderCreateWithURL(url);
|
dataProvider = CGDataProviderCreateWithURL(url);
|
||||||
theCGFont = CGFontCreateWithDataProvider(dataProvider);
|
theCGFont = CGFontCreateWithDataProvider(dataProvider);
|
||||||
face = CTFontCreateWithGraphicsFont(theCGFont, font_size, NULL, NULL);
|
face = CTFontCreateWithGraphicsFont(theCGFont, font_size, NULL, NULL);
|
||||||
|
|
Loading…
Reference in New Issue