stb icon indicating copy to clipboard operation
stb copied to clipboard

Update stb_truetype.h to make it usable for IoT/embedded devices as well

Open codewitch-honey-crisis opened this issue 1 year ago • 5 comments

Makes the library configurable to be suitable on IoT devices or otherwise devices without very much RAM (<256kB)

Changes only take place if configured as such. Otherwise the library behaves as normal wherever possible: Edit: I changed functions that returned pointers to return integer offsets instead that way they can be used with pointers or streams.

Any contributions i make are under "honey the codewitch" as that is my business and brand. I have a credit card and everything. So if you see that, well, I'm not just being silly for effect - I actually am silly.

I did note at the top that I forked 1.26

I added my name at the top but not even under contributors because I didn't know if you were even interested in this. It's being used in LVGL going forward, whether or not you're interested, but I think it would be cool to have worked together to make this more accessible in more places and platforms! =)

codewitch-honey-crisis avatar Sep 13 '22 01:09 codewitch-honey-crisis

Welp, I'm stumped. Where is main being referenced?

$ make all gcc -I.. -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -DSTB_DIVIDE_TEST ../stb_vorbis.c test_c_compilation.c test_c_lexer.c test_dxt.c test_easyfont.c test_image.c test_image_write.c test_perlin.c test_sprintf.c test_truetype.c test_voxel.c -lm gcc -I.. -Wno-write-strings -DSTB_DIVIDE_TEST -std=c++0x test_cpp_compilation.cpp -lm -lstdc++ /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function _start': (.text+0x20): undefined reference to main' collect2: error: ld returned 1 exit status Makefile:9: recipe for target 'all' failed make: *** [all] Error 1 The command "make all" exited with 2.

codewitch-honey-crisis avatar Sep 13 '22 03:09 codewitch-honey-crisis

Don't worry about it, the tests are mostly for my purpose, not for your testing. (The details is they are standalone and require a -D on the commandline to determine which one to have a main. And in some cases the data required to run them isn't in the report.)

nothings avatar Sep 13 '22 03:09 nothings

Thanks! I thought it was something I did. My initial comment said I did not change the API. I fibbed. The truth is I forget I had to change, like the FindSVGDoc function and one or two others that returned pointers to return integer offsets that could be used with either a pointer or stream.

codewitch-honey-crisis avatar Sep 13 '22 03:09 codewitch-honey-crisis

As to the submission:

This is the kind of robust complexity that I generally try to avoid in the stb libraries. For example, libjpg supports streaming images, whereas stb_image requires the whole image to be loaded at once. I generally leave it to the more robust, official libraries to support these sorts of things, and the stb libraries are meant to be simpler to use, to not worry too much about memory management, etc.

nothings avatar Sep 13 '22 03:09 nothings

Fair enough. This library is almost perfect for IoT and embedded gadgets. This bridges the "almost" gap. So maybe it's worth considering in this case? check out https://lvgl.io Your code will be running on that going forward. It already is being used in https://honeythecodewitch.com/gfx using a previous version I ported.

Most of your libraries are clearly for gaming engines. This is too. But trust me, in this case, it's much more, and fills a sorely needed gap in support across a variety of devices.

Do what you want, but I'd be remiss if I didn't try to twist your arm on this issue a little. =)

codewitch-honey-crisis avatar Sep 13 '22 03:09 codewitch-honey-crisis