]> git.tdb.fi Git - ttf2png.git/commitdiff
Add an option to invert colors
authorMikko Rasa <tdb@tdb.fi>
Fri, 23 Nov 2012 08:43:08 +0000 (10:43 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 23 Nov 2012 08:43:08 +0000 (10:43 +0200)
ttf2png.c

index b61d51d6ac31702de6259438516b6ea33c3868cc..c77cd5889509248390bd80dbeee0606586719c96 100644 (file)
--- a/ttf2png.c
+++ b/ttf2png.c
@@ -73,6 +73,7 @@ int main(int argc, char **argv)
        char autohinter = 0;
        char seq = 0;
        char alpha = 0;
+       char invert = 0;
        char pack = 0;
 
        FT_Library freetype;
@@ -92,7 +93,7 @@ int main(int argc, char **argv)
                return 1;
        }
 
-       while((i = getopt(argc, argv, "r:s:l:c:o:atvh?ed:p")) != -1)
+       while((i = getopt(argc, argv, "r:s:l:c:o:atvh?ed:pi")) != -1)
        {
                char *ptr;
                int  temp;
@@ -175,6 +176,9 @@ int main(int argc, char **argv)
                case 'p':
                        pack = 1;
                        break;
+               case 'i':
+                       invert = 1;
+                       break;
                }
        }
        if(!strcmp(out_fn, "-"))
@@ -224,6 +228,11 @@ int main(int argc, char **argv)
                render_packed(&font);
        else
                render_grid(&font, cellw, cellh, cpl, seq);
+       if(invert)
+       {
+               for(i=0; i<font.image.w*font.image.h; ++i)
+                       font.image.data[i] = 255-font.image.data[i];
+       }
        save_png(out_fn, &font.image, alpha);
        if(def_fn)
                save_defs(def_fn, &font);
@@ -265,6 +274,7 @@ void usage()
                "  -o  Output file name (or - for stdout) [font.png]\n"
                "  -a  Force autohinter\n"
                "  -t  Render font to alpha channel\n"
+               "  -i  Invert colors of the glyphs\n"
                "  -v  Increase the level of verbosity\n"
                "  -e  Use cells in sequence, rather than by code\n"
                "  -p  Pack the glyphs tightly instead of in a grid\n"