Root/tools/libant/libant.h

Source at commit 0f17c404d2bf724b17d8443d6b76701f50be673d created 11 years 6 days ago.
By Werner Almesberger, BOOKSHELF: add data sheets of parts for next Tornado iteration
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
19struct image;
20
21struct font;
22
23struct 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
57struct image *load_image_file(FILE *file, const char **error);
58struct image *load_image(const char *name, const char **error);
59void free_image(struct image *img);
60
61int draw_image(void *canvas, int width, int height,
62    const struct image *img, int x, int y);
63
64struct font *make_font(struct image *img, const char **error);
65void free_font(struct font *font);
66
67int draw_char(void *canvas, int width, int height,
68    const struct font *font, char c, int x, int y);
69int char_height(const struct font *font, char c);
70
71struct edit *text2edit(const char *s, const char **error);
72char *edit2text(const struct edit *e);
73void free_edits(struct edit *e);
74
75void add_font_dir(const char *name);
76
77void *apply_edits(int width, int height, const struct edit *e,
78    const char **error);
79
80int dump_binary(FILE *file, const void *canvas, int width, int height);
81int dump_xbm(FILE *file, const void *canvas, int width, int height);
82int dump_ascii(FILE *file, const void *canvas, int width, int height);
83
84#endif /* !LIBANT_H */
85

Archive Download this file

Branches:
master
tornado-v1



interactive