SDL_FontCache icon indicating copy to clipboard operation
SDL_FontCache copied to clipboard

fallback fonts

Open foen opened this issue 6 years ago • 4 comments

easy way to set multiple fonts as fallback for missing characters. or is this already possible but missing something ?

foen avatar Jan 19 '19 15:01 foen

I'm also interested in this. It appears that it isn't possible.

However, I think it could be made possible. FC_Font could have a pointer added to another FC_Font* to be used in the case that a codepoint cannot be found in the font. If it is found in that font then use that glyph, else keep going down the linked list until you hit NULL.

@grimfang4 do you think this is possible/wise, and are you happy for me to take a crack at this?

SnapperTT avatar Oct 21 '19 13:10 SnapperTT

I think it's certainly possible and wouldn't harm the interface at all, while providing some functionality that would need a significant workaround otherwise. I'd say go for it and we'll work it in.

grimfang4 avatar Oct 21 '19 14:10 grimfang4

I've gotten something working. A major problem is that TTF_GlyphIsProvided takes a Uint16 as an arg, slicing up the top 16 bits of a code point. A workaround to that is to use FT_Get_Char_Index() - which SDL_TTF calls internally and accepts a 32 bit codepoint. However this is causing linking issues on my end

If we can find a "is_codepoint_in_this_font(uint32 codepoint)" then this will be good to go

SnapperTT avatar Oct 22 '19 01:10 SnapperTT

Another update: I posted on the SDL forums, in the next SDL_TTF patch it'll have 32 bit codepoint support: Thread: https://discourse.libsdl.org/t/sdl-tff-utf8-codepoint-checking/26751/2 Relevent Code: https://hg.libsdl.org/SDL_ttf/rev/ae83a705f5ab

SnapperTT avatar Oct 22 '19 06:10 SnapperTT