SDL_FontCache icon indicating copy to clipboard operation
SDL_FontCache copied to clipboard

Custom caching

Open im95able opened this issue 9 years ago • 5 comments

Is there any way to cache the UNICODE code points I know I'll be using. For example my app will have support for english and russian, so I would like to cache only the glyph textures belonging to those languages.

im95able avatar May 28 '16 12:05 im95able

There are two ways to tell SDL_FontCache which glyphs to cache. If you have render target support, the glyphs will be cached the first time you use a string with new codepoints in it. Alternatively, you can cache all of your glyphs up front with FC_SetLoadingString(). Pass in a string with all of the UTF-8 codepoints you want to cache when FC_LoadFont* is called.

grimfang4 avatar May 28 '16 13:05 grimfang4

By using a string with new codepoints, you mean calling one of the FC_Draw functions ?

im95able avatar May 28 '16 14:05 im95able

Yes, the drawing functions all autocache new glyphs. I think the others which take strings, like the metrics (e.g. FC_GetWidth), also do it.

grimfang4 avatar May 28 '16 14:05 grimfang4

Ok ok. Thank you very much for the info, and of course for the library.

im95able avatar May 28 '16 14:05 im95able

You're welcome! I haven't been running into any additional needs from the API in a while, so it might be nearly time for a real 1.0 release.

grimfang4 avatar May 28 '16 15:05 grimfang4