Closed ghost closed 3 months ago
I haven't done a full review, but here are some thoughts:
I just noticed how hard to read this is when looking at the diff. I'll have the next PR be based on the main tree.
I found some time to look at kernings. It appears FreeType will scan the file every time you look up a pair and there's no way to get a table. However stb_truetype.h appears to create a table which I think is an excellent choice
It offers two license, mit and public domain https://github.com/nothings/stb?tab=License-1-ov-file#readme https://github.com/nothings/stb/blob/master/stb_truetype.h#L804
I'm interested in implementing kerning with some stb code. I just want to make sure that you'll accept my code before I go out to do this. I can write a text document of the API (funcs and structs) if you want. A quick summary is
https://github.com/LevoDeLellis/SDL_ttf/blob/main/include/SDL3_ttf/SDL_ttf.h#L2251
Thoughts? I'm not in a rush to implement this. Here's the drawing code from the example (which will be changed to use a hashtable), I like having the Y be top instead of baseline but if it makes more sense for Y to be baseline that's completely fine and a minor edit https://github.com/LevoDeLellis/SDL_ttf/blob/main/examples/AtlasLoadAll.c#L142
did we just loose this code?
did we just loose this code?
No, run
git fetch https://github.com/libsdl-org/SDL_ttf pull/359/head
git checkout FETCH_HEAD
I don't think there's anything else I want to add to the library. I'll want to improve documentation and examples.
I like the C++ version because of the hash table but both are pretty close. The C++ example uses multiple atlas functions while the C version uses the function that loads everything at once. Here's a picture of the C++ version which loads 2 fonts and intentionally didn't load the 'Y' in the larger font
IIRC GL supports a texture with 8bit alpha channel (GL_Alpha8 and GL_R8 for pixel shaders). Is it possible to use an 8bit format for this? At the moment only SDL_PIXELFORMAT_ARGB8888 is supported. I simply use white and set the alpha bits
(0x00FFFFFF | ((Uint32)*src << 24);
)Let me know what you think. If it's all good I'll write better documentation and may add more to the example(s)