From 350283375c7724c107e2845541612121c56c906f Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 30 Jun 2012 12:52:01 -0300 Subject: [PATCH] tools/libtxt/: create library instead of executable --- tools/libtxt/Makefile | 10 +++++----- tools/libtxt/font.c | 45 ------------------------------------------- 2 files changed, 5 insertions(+), 50 deletions(-) diff --git a/tools/libtxt/Makefile b/tools/libtxt/Makefile index 750a09a..39f80b6 100644 --- a/tools/libtxt/Makefile +++ b/tools/libtxt/Makefile @@ -11,7 +11,7 @@ # -MAIN = libtxt.a +LIB = libtxt.a CFLAGS = -g -Wall @@ -19,13 +19,13 @@ OBJS = edit.o font.o .PHONY: all clean spotless -all: $(MAIN) +all: $(LIB) -$(MAIN): $(OBJS) - $(CC) $(CFLAGS) -o $@ $(OBJS) +$(LIB): $(OBJS) + $(AR) cr $@ $^ clean: rm -f $(OBJS) spotless: clean - rm -f $(MAIN) + rm -f $(LIB) diff --git a/tools/libtxt/font.c b/tools/libtxt/font.c index 6ba37c5..8406f88 100644 --- a/tools/libtxt/font.c +++ b/tools/libtxt/font.c @@ -305,48 +305,3 @@ int char_height(const struct font *font, char c) sym = font->sym+(cp-charset); return sym->h; } - - -/* ----- Testing ----------------------------------------------------------- */ - - -#define W 64 -#define H 20 - - -int main(int argc, char **argv) -{ - struct font *font; - struct image *img; - const char *error; - uint8_t canvas[W*H/8] = { 0 }; - char *s; - int x, xo, y; - - img = load_image(argv[1], &error); - if (!img) { - fprintf(stderr, "%s\n", error); - return 1; - } - font = make_font(img, &error); - if (!font) { - fprintf(stderr, "%s\n", error); - return 1; - } - - x = 0; - for (s = argv[2]; *s; s++) { - xo = draw_char(canvas, W, H, font, *s, x, 0); - if (xo) - x += xo+1; - } - for (y = 0; y != H; y++) { - for (x = 0; x != W; x++) - if (canvas[(y*W+x) >> 3] & (1 << (x & 7))) - putchar('#'); - else - putchar('.'); - putchar('\n'); - } - return 0; -}