Skip to content

Commit

Permalink
Use asset loader for ttf as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabordemooij committed Jun 24, 2024
1 parent 5f56784 commit 05182c6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/media/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -2705,11 +2705,13 @@ ctr_object* ctr_media_anim_speed(ctr_object* myself, ctr_argument* argumentList)
ctr_object* ctr_img_font(ctr_object* myself, ctr_argument* argumentList) {
MediaIMG* image = ctr_internal_get_image_from_object(myself);
if (image == NULL) return myself;
//@todo use asset manager
char* path = ctr_heap_allocate_cstring(ctr_internal_cast2string(argumentList->object));
image->font = TTF_OpenFont(path, (int)ctr_internal_cast2number(argumentList->next->object)->value.nvalue);
SDL_RWops* res = ctr_internal_media_load_asset(path, 1);
ctr_heap_free(path);
if (image->font == NULL) ctr_internal_media_fatalerror("Unable to load font", "TTF Font");
if (res == NULL) {
ctr_internal_media_fatalerror("Unable to load font", "TTF Font");
}
image->font = TTF_OpenFontRW(res, 1, (int)ctr_internal_cast2number(argumentList->next->object)->value.nvalue);
/* Allow to set compile-time FONTSCRIPT for Harfbuzz shaper */
#ifdef FONTSCRIPT
int script_ok = TTF_SetFontScriptName(image->font, FONTSCRIPT);
Expand Down

0 comments on commit 05182c6

Please sign in to comment.