From 6bf69b9358d13e4e601a05e38e218ee20adc4db8 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sun, 1 Jul 2012 21:08:21 -0300 Subject: [PATCH] tools/libtxt/edit.c (do_edit): move font loading logic to load_font --- tools/libtxt/edit.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/libtxt/edit.c b/tools/libtxt/edit.c index 2f6bdc5..5b9d700 100644 --- a/tools/libtxt/edit.c +++ b/tools/libtxt/edit.c @@ -71,6 +71,17 @@ static struct image *find_font_image(const char *name, const char **error) } +static struct font *load_font(const char *name, const char **error) +{ + struct image *img; + + img = find_font_image(name, error); + if (!img) + return NULL; + return make_font(img, error); +} + + static int do_edit(uint8_t *canvas, int width, int height, const struct edit *e, const char **error) { @@ -95,10 +106,7 @@ static int do_edit(uint8_t *canvas, int width, int height, break; case edit_font: free_font(font); - img = find_font_image(e->u.s, error); - if (!img) - return 0; - font = make_font(img, error); + font = load_font(e->u.s, error); if (!font) goto fail; break;