1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-03 07:41:21 +00:00

Reimplemented the _FREEFONT command

A new function has been added to parts/video/fonts/ttf/src.c, FontFree().
This takes an index into the fonts array, and calls FT_Done_Face() on the
handle, free() on the ttf_data then sets in_use to 0.

The sub__freefont() function calls FontFree(), and sets the appropriate font[]
element to NULL (after checking the passed font handle is valid, of course.
This commit is contained in:
Luke Ceddia 2014-10-06 19:05:05 +11:00
parent 5158950119
commit 160624a2b5
2 changed files with 10 additions and 3 deletions

View file

@ -20890,8 +20890,8 @@ int32 func__printwidth(qbs* text, int32 screenhandle, int32 passed){
}
}
//remove font
//NO_S_D_L//TTF_CloseFont(font[f]);
//NO_S_D_L//font[f]=NULL;
FontFree(font[f]);
font[f]=NULL;
}
void sub__printmode(int32 mode,int32 i,int32 passed){

View file

@ -13,6 +13,7 @@ int32 FontLoad (uint8 *content_original,int32 content_bytes,int32 default_pixel_
int32 FontRenderTextASCII(int32 i,uint8*codepoint,int32 codepoints,int32 options,
uint8**out_data,int32*out_x,int32 *out_y,int32*out_x_pre_increment,int32*out_x_post_increment){return NULL;}
int32 FontWidth(int32 i){return NULL;}
void FontFree(int32 i){return;}
#else
#ifdef QB64_BACKSLASH_FILESYSTEM
@ -297,6 +298,12 @@ return i;
}
void FontFree(int32 i) {
FT_Done_Face(fonts[i].handle);
free(fonts[i].ttf_data);
fonts[i].in_use = 0;
}
int32 FontRenderTextASCII(int32 i,uint8*codepoint,int32 codepoints,int32 options,
uint8**out_data,int32*out_x,int32 *out_y,int32*out_x_pre_increment,int32*out_x_post_increment){
static uint32 *utf32_codepoint;
@ -318,4 +325,4 @@ if (fonts[i].monospace) return fonts[i].monospace_width;
return 0;
}
#endif
#endif