SDL_FontCache icon indicating copy to clipboard operation
SDL_FontCache copied to clipboard

Fixes gcc wnarrowing spam (issue #38)

Open SnapperTT opened this issue 5 years ago • 6 comments

Adds a number of int casts to take out gcc -wnarrowing spam

SnapperTT avatar Sep 14 '19 00:09 SnapperTT

Sorry I didn't think about this earlier, but this library compiles slightly differently for SDL and SDL_gpu. SDL uses a rect structure that stores integers, while SDL_gpu uses one that stores floats. SDL_FontCache uses a #define to make FC_Rect match the rect used by the appropriate rendering system. The solution here should depend on which system is being used so the floating point precision is preserved for SDL_gpu instead of always truncating to int.

grimfang4 avatar Sep 15 '19 12:09 grimfang4

This could be fixed by having:

#ifdef SDL_gpu (or other)
   #define FC_COORD float
#else
   #define FC_COORD int
#endif

And replacing all (int) casts with (FC_COORD) casts. Sound good for me to do this?

SnapperTT avatar Sep 16 '19 01:09 SnapperTT

Yep, I'm good with that.

grimfang4 avatar Sep 16 '19 13:09 grimfang4

Updated. Also changed #include "SDL.h" to #include <SDL.h>. If you like I can change it back (and the turn around for said change should be faster. Sorry to keep you waiting mate!)

SnapperTT avatar Oct 21 '19 05:10 SnapperTT

Hey, no problem. I've got plenty to occupy me. :)

I'd prefer it as "SDL.h" because it should be checking project-defined search directories before checking standard install locations.

grimfang4 avatar Oct 21 '19 14:10 grimfang4

I've reverted the <> to "", and took a crack at #29 .

I've added a "fallback" member to FC_Font, added "void FC_AddFallback(base_font, fallback_font)" which adds the fallback font to the end of the fallback font linked list, and added the font switching to SDL_FontCache.c:1617.

The font switching does "work" - it does successfully load glyphs from other fonts, however the is-glyph-missing detection does not work, so its commented out, so that when a suitable fix is found it can be easily applied

SnapperTT avatar Oct 22 '19 03:10 SnapperTT