87 } |
87 } |
88 } |
88 } |
89 |
89 |
90 struct asc_font_cache_entry entry; |
90 struct asc_font_cache_entry entry; |
91 entry.font = font; |
91 entry.font = font; |
92 cxmutstr fpath = asc_filesystem_combine_paths(cx_strcast(asc_context.font_path), cx_str(asc_font_filename(font.style))); |
92 const char *font_name = asc_font_filename(font.style); |
|
93 cxmutstr fpath = asc_filesystem_combine_paths(cx_strcast(asc_context.font_path), cx_str(font_name)); |
93 asc_dprintf("Load font from %" CX_PRIstr, CX_SFMT(fpath)); |
94 asc_dprintf("Load font from %" CX_PRIstr, CX_SFMT(fpath)); |
94 entry.ttf = TTF_OpenFont(fpath.ptr, font.size); |
95 entry.ttf = TTF_OpenFont(fpath.ptr, font.size); |
95 cx_strfree(&fpath); |
96 cx_strfree(&fpath); |
96 if (entry.ttf == NULL) { |
97 if (entry.ttf == NULL) { |
97 asc_error(TTF_GetError()); |
98 asc_error("Failed to load font %s: %s", font_name, TTF_GetError()); |
98 return NULL; |
99 return NULL; |
99 } else { |
100 } else { |
100 cxListAdd(asc_font_cache, &entry); |
101 cxListAdd(asc_font_cache, &entry); |
101 asc_dprintf("Loaded font size %d, style %d from disk", font.size, font.style); |
102 asc_dprintf("Loaded font size %d, style %d from %s", font.size, font.style, font_name); |
102 return entry.ttf; |
103 return entry.ttf; |
103 } |
104 } |
104 } |
105 } |