static void *font_renderer_ft_init(const char *font_path, float font_size) { FT_Error err; ft_font_renderer_t *handle = (ft_font_renderer_t*) calloc(1, sizeof(*handle)); if (!handle) goto error; err = FT_Init_FreeType(&handle->lib); if (err) goto error; err = FT_New_Face(handle->lib, font_path, 0, &handle->face); if (err) goto error; err = FT_Set_Pixel_Sizes(handle->face, 0, font_size); if (err) goto error; if (!font_renderer_create_atlas(handle)) goto error; return handle; error: font_renderer_ft_free(handle); return NULL; }
static void *font_renderer_ft_init(const char *font_path, float font_size) { FT_Error err; ft_font_renderer_t *handle = (ft_font_renderer_t*) calloc(1, sizeof(*handle)); if (!handle) goto error; if (font_size < 1.0) goto error; err = FT_Init_FreeType(&handle->lib); if (err) goto error; #ifdef WIIU if(!*font_path) { void* font_data = NULL; uint32_t font_size = 0; if(!OSGetSharedData(SHARED_FONT_DEFAULT, 0, &font_data, &font_size)) goto error; err = FT_New_Memory_Face(handle->lib, font_data, font_size, 0, &handle->face); if (err) goto error; } else #endif { err = FT_New_Face(handle->lib, font_path, 0, &handle->face); if (err) goto error; } err = FT_Select_Charmap(handle->face, FT_ENCODING_UNICODE); if (err) goto error; err = FT_Set_Pixel_Sizes(handle->face, 0, font_size); if (err) goto error; if (!font_renderer_create_atlas(handle, font_size)) goto error; return handle; error: font_renderer_ft_free(handle); return NULL; }
static void *font_renderer_ct_init(const char *font_path, float font_size) { char err = 0; CFStringRef cf_font_path = NULL; CTFontRef face = NULL; ct_font_renderer_t *handle = (ct_font_renderer_t*) calloc(1, sizeof(*handle)); if (!handle) { err = 1; goto error; } cf_font_path = CFStringCreateWithCString(NULL, font_path, kCFStringEncodingASCII); if (!cf_font_path) { err = 1; goto error; } face = CTFontCreateWithName(cf_font_path, font_size, NULL); if (!face) { err = 1; goto error; } if (!font_renderer_create_atlas(face, handle)) { err = 1; goto error; } error: if (err) { font_renderer_ct_free(handle); handle = NULL; } if (cf_font_path) { CFRelease(cf_font_path); cf_font_path = NULL; } if (face) { CFRelease(face); face = NULL; } return handle; }