Root/
| Source at commit bf2e2c30463d22b5e34fa795eb98b35a855d90ae created 11 years 1 hour ago. By Werner Almesberger, tornado/led/led.cmp: update for new components and changed references | |
|---|---|
| 1 | /* |
| 2 | * tools/libant/libant.h - Text processing functions |
| 3 | * |
| 4 | * Written 2012 by Werner Almesberger |
| 5 | * Copyright 2012 Werner Almesberger |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | #ifndef LIBANT_H |
| 14 | #define LIBANT_H |
| 15 | |
| 16 | #include <stdio.h> |
| 17 | |
| 18 | |
| 19 | struct image; |
| 20 | |
| 21 | struct font; |
| 22 | |
| 23 | struct edit { |
| 24 | enum edit_type { |
| 25 | edit_string, |
| 26 | edit_font, |
| 27 | edit_img, |
| 28 | edit_spc, |
| 29 | edit_xoff, |
| 30 | edit_xpos, |
| 31 | edit_yoff, |
| 32 | edit_ypos, |
| 33 | edit_nl, |
| 34 | } type; |
| 35 | union { |
| 36 | char *s; |
| 37 | int n; |
| 38 | } u; |
| 39 | struct edit *next; |
| 40 | }; |
| 41 | |
| 42 | /* |
| 43 | * Markup: |
| 44 | * |
| 45 | * <FONT fontname> |
| 46 | * <IMG imagefile> |
| 47 | * <SPC offset> |
| 48 | * <X+offset> <X-offset> <X=pos> |
| 49 | * <Y+offset> ... |
| 50 | * |
| 51 | * Empty lines are ignored. The newline of a line containing only markup is |
| 52 | * also ignored. |
| 53 | * |
| 54 | * Newline leaves one blank row between text lines. |
| 55 | */ |
| 56 | |
| 57 | struct image *load_image_file(FILE *file, const char **error); |
| 58 | struct image *load_image(const char *name, const char **error); |
| 59 | void free_image(struct image *img); |
| 60 | |
| 61 | int draw_image(void *canvas, int width, int height, |
| 62 | const struct image *img, int x, int y); |
| 63 | |
| 64 | struct font *make_font(struct image *img, const char **error); |
| 65 | void free_font(struct font *font); |
| 66 | |
| 67 | int draw_char(void *canvas, int width, int height, |
| 68 | const struct font *font, char c, int x, int y); |
| 69 | int char_height(const struct font *font, char c); |
| 70 | |
| 71 | struct edit *text2edit(const char *s, const char **error); |
| 72 | char *edit2text(const struct edit *e); |
| 73 | void free_edits(struct edit *e); |
| 74 | |
| 75 | void add_font_dir(const char *name); |
| 76 | |
| 77 | void *apply_edits(int width, int height, const struct edit *e, |
| 78 | const char **error); |
| 79 | |
| 80 | int dump_binary(FILE *file, const void *canvas, int width, int height); |
| 81 | int dump_xbm(FILE *file, const void *canvas, int width, int height); |
| 82 | int dump_ascii(FILE *file, const void *canvas, int width, int height); |
| 83 | |
| 84 | #endif /* !LIBANT_H */ |
| 85 | |
Branches:
master
tornado-v1
