Root/
| 1 | /* |
| 2 | * gfx/text.h - FIG text object |
| 3 | * |
| 4 | * Written 2016 by Werner Almesberger |
| 5 | * Copyright 2016 by 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 | |
| 14 | #ifndef GFX_TEXT_H |
| 15 | #define GFX_TEXT_H |
| 16 | |
| 17 | |
| 18 | /* use constants of FIG text sub_type */ |
| 19 | |
| 20 | enum text_align { |
| 21 | text_min = 0, // left or bottom |
| 22 | text_mid = 1, // center |
| 23 | text_max = 2, // right or top |
| 24 | }; |
| 25 | |
| 26 | enum text_style { |
| 27 | text_normal, |
| 28 | text_italic, |
| 29 | }; |
| 30 | |
| 31 | struct text { |
| 32 | const char *s; |
| 33 | int size; |
| 34 | int x, y; |
| 35 | int rot; |
| 36 | enum text_align hor; |
| 37 | enum text_align vert; |
| 38 | }; |
| 39 | |
| 40 | void text_init(struct text *txt); |
| 41 | void text_free(struct text *txt); |
| 42 | |
| 43 | void text_set(struct text *txt, const char *s); |
| 44 | void text_rot(struct text *txt, int deg); |
| 45 | void text_flip_x(struct text *txt); |
| 46 | enum text_align text_flip(enum text_align align); |
| 47 | |
| 48 | void text_fig(const struct text *txt, int color, unsigned layer); |
| 49 | |
| 50 | void text_rel(const struct text *txt, enum text_align xr, enum text_align yr, |
| 51 | int dx, int dy, int *res_x, int *res_y); |
| 52 | void text_shift(struct text *txt, enum text_align xr, enum text_align yr, |
| 53 | int dx, int dy); |
| 54 | int text_rel_x(const struct text *txt, enum text_align xr, enum text_align yr, |
| 55 | int dx, int dy); |
| 56 | int text_rel_y(const struct text *txt, enum text_align xr, enum text_align yr, |
| 57 | int dx, int dy); |
| 58 | |
| 59 | #endif /* !GFX_TEXT_H */ |
| 60 |
Branches:
master
