From 0e0b37af19a9a6a90b16e3530d498ac1461f9cda Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 14 Jul 2010 00:14:31 +0000 Subject: [PATCH] Simple tool to create a font file. --- .gitignore | 2 ++ Makefile | 6 +++++- gfx/Makefile | 7 +++++++ gfx/font/Makefile | 9 +++++++++ tools/Makefile | 12 ++++++++++++ tools/make-font.cpp | 25 +++++++++++++++++++++++++ 6 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 gfx/Makefile create mode 100644 gfx/font/Makefile create mode 100644 tools/Makefile create mode 100644 tools/make-font.cpp diff --git a/.gitignore b/.gitignore index ac3e9c6e..6fd83048 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ *.o src/test-map +tools/make-font art/*.png art/test/*.png +gfx/font/*.png diff --git a/Makefile b/Makefile index f6cc743c..6a45520e 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,13 @@ all: - cd art && $(MAKE) all cd src && $(MAKE) all + cd tools && $(MAKE) all + cd art && $(MAKE) all + cd gfx && $(MAKE) all clean: + cd gfx && $(MAKE) clean cd art && $(MAKE) clean + cd tools && $(MAKE) clean cd src && $(MAKE) clean diff --git a/gfx/Makefile b/gfx/Makefile new file mode 100644 index 00000000..34d05722 --- /dev/null +++ b/gfx/Makefile @@ -0,0 +1,7 @@ + +all: + cd font && $(MAKE) all + +clean: + cd font && $(MAKE) clean + diff --git a/gfx/font/Makefile b/gfx/font/Makefile new file mode 100644 index 00000000..4268c3f2 --- /dev/null +++ b/gfx/font/Makefile @@ -0,0 +1,9 @@ + +all: ascii.png + +ascii.png: + ../../tools/make-font | convert tga:- $@ + +clean: + rm -f ascii.png + diff --git a/tools/Makefile b/tools/Makefile new file mode 100644 index 00000000..b6371ee3 --- /dev/null +++ b/tools/Makefile @@ -0,0 +1,12 @@ + +all: make-font + +make-font: make-font.o + g++ -g -Wall -O3 $^ -o $@ `pkg-config --libs caca` + +%.o: %.cpp + g++ -g -Wall -O3 -c $^ -o $@ `pkg-config --cflags caca` + +clean: + rm -f *.o make-font + diff --git a/tools/make-font.cpp b/tools/make-font.cpp new file mode 100644 index 00000000..331dff49 --- /dev/null +++ b/tools/make-font.cpp @@ -0,0 +1,25 @@ + +#include + +#include +#include + +int main(void) +{ + caca_canvas_t *cv = caca_create_canvas(16, 16); + caca_set_color_ansi(cv, CACA_WHITE, CACA_TRANSPARENT); + + for (unsigned int n = 0; n < 256; n++) + caca_put_char(cv, n % 16, n / 16, n); + + size_t len; + void *buffer = caca_export_canvas_to_memory(cv, "tga", &len); + fwrite(buffer, len, 1, stdout); + free(buffer); + + /* Free everything */ + caca_free_canvas(cv); + + return 0; +} +