diff --git a/tools/libtxt/font.c b/tools/libtxt/font.c index 69c8fe8..e321e0c 100644 --- a/tools/libtxt/font.c +++ b/tools/libtxt/font.c @@ -99,19 +99,11 @@ static const char *read_xbm_file(FILE *file, struct image *img) } -struct image *load_image(const char *name, const char **error) +struct image *load_image_file(FILE *file, const char **error) { - FILE *file; struct image *img; const char *err; - file = fopen(name, "r"); - if (!file) { - if (error) - *error = alloc_sprintf("%s: %s", name, strerror(errno)); - return NULL; - } - img = alloc_type(struct image); err = read_xbm_file(file, img); if (err) { @@ -124,6 +116,23 @@ struct image *load_image(const char *name, const char **error) } +struct image *load_image(const char *name, const char **error) +{ + FILE *file; + struct image *img; + + file = fopen(name, "r"); + if (!file) { + if (error) + *error = alloc_sprintf("%s: %s", name, strerror(errno)); + return NULL; + } + img = load_image_file(file, error); + fclose(file); + return img; +} + + void free_image(struct image *img) { if (img) { diff --git a/tools/libtxt/libtxt.h b/tools/libtxt/libtxt.h index 7aea2bf..49973df 100644 --- a/tools/libtxt/libtxt.h +++ b/tools/libtxt/libtxt.h @@ -13,6 +13,9 @@ #ifndef LIBTXT_H #define LIBTXT_H +#include + + struct image; struct font; @@ -51,6 +54,7 @@ struct edit { * Newline leaves one blank row between text lines. */ +struct image *load_image_file(FILE *file, const char **error); struct image *load_image(const char *name, const char **error); void free_image(struct image *img);