X-Git-Url: https://harrygodden.com/git/?p=fishladder.git;a=blobdiff_plain;f=fontcomp.c;fp=fontcomp.c;h=0000000000000000000000000000000000000000;hp=c2d26ac68a1e3c65c97d232027b141282fd23d0d;hb=30490c4c08d5c0f811017a901aa9e25a95be7c40;hpb=3363633178b1eea582304742ad1202487af0feb1 diff --git a/fontcomp.c b/fontcomp.c deleted file mode 100644 index c2d26ac..0000000 --- a/fontcomp.c +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved - -#define VG_TOOLS -#include "vg/vg.h" - -#define STB_IMAGE_IMPLEMENTATION -#include "stb/stb_image.h" - -// Super basic model compiler -int main( int argc, char *argv[] ) -{ - if( argc < 3 ) - { - vg_error( "Need input/output files\n" ); - return 0; - } - - FILE *output; - - int x,y,n; - unsigned char *data = stbi_load( argv[1], &x, &y, &n, 4 ); - - if( data ) - { - output = fopen( argv[2], "w" ); - if( !output ) - { - vg_error( "couldn't open output for writing\n" ); - free(data); - return 0; - } - - fprintf( output, "/* Font buffer generated from source file: '%s' */\n", argv[1] ); - - u32 pixel_max = x*y; - u32 pixel = 0, chars = 0; - while(pixel_max) - { - u32 buff = 0; - for( int b = 31; b >= 0; b-- ) - { - buff |= data[pixel*4]>128?0x1<= pixel_max ) - { - pixel_max = 0; - break; - } - } - - fprintf( output, "%#x,", buff ); - if( (++chars) % 8 == 0 ) - fprintf( output, "\n" ); - } - - free(data); - fclose(output); - - vg_success( "Font compiled successfully\n" ); - } - else - { - vg_error( "Couldn't open source file\n" ); - return 0; - } -}