grimfang4 / SDL_FontCache

A generic font caching C library with loading and rendering support for SDL.
MIT License
305 stars 66 forks source link

Outlining Text #17

Open gnwong opened 6 years ago

gnwong commented 6 years ago

First of all: this is a great library.

I've been trying to get reasonable outlining for text but had little success. If I use the FreeSans font in your test/fonts folder, call FC_SetSpacing(outlinefont, -2), and render the outline at -1,-1 offset to the colored "fill" font, then things work as expected. (Changing the SetFontOutline thickness to 2 requires multiplying everything by 2 and so on.)

Playing around with the vanilla SDL TTF library seems to suggest that rendering the outline at the offset is required either way, so I'm fine with that, but I'm wondering about (1) the SetSpacing requirement and (2) why the outline just doesn't line up (for some characters) in other fonts I've tried (e.g., Roboto and OpenSans)?

Is there some theoretical knowledge about outlines in general that I'm missing, or is it just that some fonts don't like to be outlined?

grimfang4 commented 6 years ago

Those observations match my expectations, but I'm not sure about why other fonts might be misbehaving. I haven't messed around with outlines and matching them up with the normal font yet, but it would be good to add something like this to the test program.