diff --git a/Makefile.am b/Makefile.am index 5a8eeea..7f45697 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,19 +5,22 @@ DIST_SUBDIRS = $(SUBDIRS) EXTRA_DIST = bootstrap AUTOMAKE_OPTIONS = dist-bzip2 +CACA2TLF = $(top_builddir)/tools/caca2tlf +FONTDIR = $(top_builddir)/fonts + fonts: tools/caca2tlf FORCE - $(top_builddir)/tools/caca2tlf "Monospace 9" | zip \ - > $(top_builddir)/fonts/bigmono9.tlf - $(top_builddir)/tools/caca2tlf "Monospace Bold 12" | zip \ - > $(top_builddir)/fonts/bigmono12.tlf - $(top_builddir)/tools/caca2tlf --half "Monospace 9" | zip \ - > $(top_builddir)/fonts/mono9.tlf - $(top_builddir)/tools/caca2tlf --half "Monospace Bold 12" | zip \ - > $(top_builddir)/fonts/mono12.tlf - $(top_builddir)/tools/caca2tlf --quarter "Monospace 9" | zip \ - > $(top_builddir)/fonts/smmono9.tlf - $(top_builddir)/tools/caca2tlf --quarter "Monospace Bold 12" | zip \ - > $(top_builddir)/fonts/smmono12.tlf + $(CACA2TLF) -u "Monospace 9" | zip > $(FONTDIR)/bigmono9.tlf + $(CACA2TLF) -u "Monospace Bold 12" | zip > $(FONTDIR)/bigmono12.tlf + $(CACA2TLF) -h -u "Monospace 9" | zip > $(FONTDIR)/mono9.tlf + $(CACA2TLF) -h -u "Monospace Bold 12" | zip > $(FONTDIR)/mono12.tlf + $(CACA2TLF) -q -u "Monospace 9" | zip > $(FONTDIR)/smmono9.tlf + $(CACA2TLF) -q -u "Monospace Bold 12" | zip > $(FONTDIR)/smmono12.tlf + $(CACA2TLF) -a "Monospace 9" | zip > $(FONTDIR)/bigascii9.tlf + $(CACA2TLF) -a "Monospace Bold 12" | zip > $(FONTDIR)/bigascii12.tlf + $(CACA2TLF) -h -a "Monospace 9" | zip > $(FONTDIR)/ascii9.tlf + $(CACA2TLF) -h -a "Monospace Bold 12" | zip > $(FONTDIR)/ascii12.tlf + $(CACA2TLF) -q -a "Monospace 9" | zip > $(FONTDIR)/smascii9.tlf + $(CACA2TLF) -q -a "Monospace Bold 12" | zip > $(FONTDIR)/smascii12.tlf webhost = poulet.zoy.org webdir = /srv/libcaca.zoy.org/var/www/ diff --git a/fonts/Makefile.am b/fonts/Makefile.am index e3659d5..21ac816 100644 --- a/fonts/Makefile.am +++ b/fonts/Makefile.am @@ -1,5 +1,7 @@ allfonts = wideterm.tlf circle.tlf emboss.tlf emboss2.tlf future.tlf \ + ascii9.tlf smascii9.tlf bigascii9.tlf \ + ascii12.tlf smascii12.tlf bigascii12.tlf \ mono9.tlf smmono9.tlf bigmono9.tlf \ mono12.tlf smmono12.tlf bigmono12.tlf \ letter.tlf smblock.tlf smbraille.tlf diff --git a/fonts/ascii12.tlf b/fonts/ascii12.tlf new file mode 100644 index 0000000..c5ac330 Binary files /dev/null and b/fonts/ascii12.tlf differ diff --git a/fonts/ascii9.tlf b/fonts/ascii9.tlf new file mode 100644 index 0000000..d972223 Binary files /dev/null and b/fonts/ascii9.tlf differ diff --git a/fonts/bigascii12.tlf b/fonts/bigascii12.tlf new file mode 100644 index 0000000..09f3f45 Binary files /dev/null and b/fonts/bigascii12.tlf differ diff --git a/fonts/bigascii9.tlf b/fonts/bigascii9.tlf new file mode 100644 index 0000000..b023382 Binary files /dev/null and b/fonts/bigascii9.tlf differ diff --git a/fonts/bigmono12.tlf b/fonts/bigmono12.tlf index 275b048..3651305 100644 Binary files a/fonts/bigmono12.tlf and b/fonts/bigmono12.tlf differ diff --git a/fonts/bigmono9.tlf b/fonts/bigmono9.tlf index dceb3c6..1b7534a 100644 Binary files a/fonts/bigmono9.tlf and b/fonts/bigmono9.tlf differ diff --git a/fonts/letter.tlf b/fonts/letter.tlf index 25a4316..69d0a50 100644 --- a/fonts/letter.tlf +++ b/fonts/letter.tlf @@ -1,16 +1,20 @@ -tlf2a 6 5 8 -1 13 0 0 0 +tlf2a 6 5 8 -1 17 0 0 0 =============================================================================== This is letter.tlf, or “Letter”, Copyright (c) 2008 Francesco Poli 2008-09-21 -- Francesco Poli font creation - This font is free software; you can redistribute it and/or modify it under + This font is free software. It comes without any warranty, to the extent +permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more details. Missing characters: many... + + This font is part of TOIlet’s official distribution. More information +on the TOIlet website at http://caca.zoy.org/wiki/toilet =============================================================================== @ @ diff --git a/fonts/mono12.tlf b/fonts/mono12.tlf index cddc76c..965b5ca 100644 Binary files a/fonts/mono12.tlf and b/fonts/mono12.tlf differ diff --git a/fonts/mono9.tlf b/fonts/mono9.tlf index cf0dcf6..2a63b54 100644 Binary files a/fonts/mono9.tlf and b/fonts/mono9.tlf differ diff --git a/fonts/smascii12.tlf b/fonts/smascii12.tlf new file mode 100644 index 0000000..f9abe32 Binary files /dev/null and b/fonts/smascii12.tlf differ diff --git a/fonts/smascii9.tlf b/fonts/smascii9.tlf new file mode 100644 index 0000000..dc9dca5 Binary files /dev/null and b/fonts/smascii9.tlf differ diff --git a/fonts/smmono12.tlf b/fonts/smmono12.tlf index 656a804..f9182a4 100644 Binary files a/fonts/smmono12.tlf and b/fonts/smmono12.tlf differ diff --git a/fonts/smmono9.tlf b/fonts/smmono9.tlf index 34df4d1..f8e6d05 100644 Binary files a/fonts/smmono9.tlf and b/fonts/smmono9.tlf differ diff --git a/src/main.c b/src/main.c index 978fb39..e5c11b9 100644 --- a/src/main.c +++ b/src/main.c @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) int infocode = -1; cx->export = "utf8"; - cx->font = "smblock"; + cx->font = "ascii9"; cx->dir = FONTDIR; cx->term_width = 80; diff --git a/tools/caca2tlf.c b/tools/caca2tlf.c index 976c8da..fd8468b 100644 --- a/tools/caca2tlf.c +++ b/tools/caca2tlf.c @@ -27,6 +27,7 @@ #include enum mode { GRAY, HALFBLOCKS, QUARTERBLOCKS } mode; +enum charset { ASCII, UTF8 } charset; static void list_fonts(void); static void add_char(unsigned long int); @@ -39,37 +40,55 @@ unsigned int w, h, gw, fgw, gh, iw, ih; int main(int argc, char *argv[]) { - char *fontname, *extraflag; + char *flag1, *flag2; unsigned int b, i; if(argc < 2) { - fprintf(stderr, "Usage: %s [--half|--quarter] \n", argv[0]); + fprintf(stderr, + "Usage: %s [--half|--quarter] [--ascii|--utf8] \n", + argv[0]); list_fonts(); return -1; } - if(!strcmp(argv[1], "--half") && argc >= 3) + if((!strcmp(argv[1], "--half") || !strcmp(argv[1], "-h")) && argc > 2) { - extraflag = "--half "; + flag1 = "--half "; mode = HALFBLOCKS; - fontname = argv[2]; + argv++; argc--; } - else if(!strcmp(argv[1], "--quarter") && argc >= 3) + else if((!strcmp(argv[1], "--quarter") || !strcmp(argv[1], "-q")) && argc > 2) { - extraflag = "--quarter "; + flag1 = "--quarter "; mode = QUARTERBLOCKS; - fontname = argv[2]; + argv++; argc--; } else { - extraflag = ""; + flag1 = ""; mode = GRAY; - fontname = argv[1]; } - f = caca_load_font(fontname, 0); + if((!strcmp(argv[1], "--ascii") || !strcmp(argv[1], "-a")) && argc > 2) + { + flag2 = "--ascii "; + charset = ASCII; + argv++; argc--; + } + else if((!strcmp(argv[1], "--utf8") || !strcmp(argv[1], "-u")) && argc > 2) + { + flag2 = "--utf8 "; + charset = UTF8; + argv++; argc--; + } + else + { + flag2 = ""; + charset = ASCII; + } + f = caca_load_font(argv[1], 0); if(!f) { fprintf(stderr, "Font \"%s\" not found.\n", argv[1]); @@ -111,7 +130,7 @@ int main(int argc, char *argv[]) printf("==============================================" "==================================\n"); printf(" This font was automatically generated using:\n"); - printf(" %% caca2tlf %s\"%s\"\n", extraflag, fontname); + printf(" %% caca2tlf %s%s\"%s\"\n", flag1, flag2, argv[1]); printf("==============================================" "==================================\n"); @@ -169,9 +188,23 @@ static void list_fonts(void) static void add_char(unsigned long int ch) { + static char const * chars[][16] = + { + { "#", "$", ":", ".", " " }, + { " ", "\"", "m", "#" }, + { " ", "`", "'", "\"", ",", "[", "/", "P", + ".", "\\", "]", "T", "m", "b", "d", "W" }, + { "█", "▓", "▒", "░", " " }, + { " ", "▀", "▄", "█" }, + { " ", "▘", "▝", "▀", "▖", "▌", "▞", "▛", + "▗", "▚", "▐", "▜", "▄", "▙", "▟", "█" } + }; + + char const **str; void *buf; size_t len; unsigned int x, y, myw, mygw; + int off = 0; int full = caca_utf32_is_fullwidth(ch); caca_set_canvas_size(onechar, full ? 2 : 1, 1); @@ -182,33 +215,44 @@ static void add_char(unsigned long int ch) mygw = full ? fgw : gw; caca_set_canvas_size(out, (full ? fgw : gw) + 2, gh); + caca_clear_canvas(out); + + switch(charset) + { + case ASCII: + off = 0; + break; + case UTF8: + off = 3; + break; + } switch(mode) { case GRAY: + str = chars[off]; for(y = 0; y < h; y++) for(x = 0; x < myw; x++) { uint8_t c = image[4 * (x + y * iw) + 2]; if(c >= 0xa0) - caca_put_str(out, x, y, "█"); + caca_put_str(out, x, y, str[0]); else if(c >= 0x80) - caca_put_str(out, x, y, "▓"); + caca_put_str(out, x, y, str[1]); else if(c >= 0x40) - caca_put_str(out, x, y, "▒"); + caca_put_str(out, x, y, str[2]); else if(c >= 0x20) - caca_put_str(out, x, y, "░"); + caca_put_str(out, x, y, str[3]); else - caca_put_char(out, x, y, ' '); + caca_put_str(out, x, y, str[4]); } break; case HALFBLOCKS: + str = chars[off + 1]; for(y = 0; y < gh; y++) for(x = 0; x < mygw; x++) { - static char const *str[] = { " ", "▀", "▄", "█" }; - uint8_t p1 = image[4 * (x + y * 2 * iw) + 2]; uint8_t p2 = image[4 * (x + (y * 2 + 1) * iw) + 2]; @@ -216,15 +260,10 @@ static void add_char(unsigned long int ch) } break; case QUARTERBLOCKS: + str = chars[off + 2]; for(y = 0; y < gh; y++) for(x = 0; x < mygw; x++) { - static char const *str[] = - { - " ", "▘", "▝", "▀", "▖", "▌", "▞", "▛", - "▗", "▚", "▐", "▜", "▄", "▙", "▟", "█" - }; - uint8_t p1 = image[4 * (x * 2 + y * 2 * iw) + 2]; uint8_t p2 = image[4 * (x * 2 + 1 + y * 2 * iw) + 2]; uint8_t p3 = image[4 * (x * 2 + (y * 2 + 1) * iw) + 2];