rev |
line source |
nuclear@7
|
1 /*
|
nuclear@7
|
2 libdrawtext - a simple library for fast text rendering in OpenGL
|
nuclear@9
|
3 Copyright (C) 2011-2015 John Tsiombikas <nuclear@member.fsf.org>
|
nuclear@7
|
4
|
nuclear@7
|
5 This program is free software: you can redistribute it and/or modify
|
nuclear@7
|
6 it under the terms of the GNU Lesser General Public License as published by
|
nuclear@7
|
7 the Free Software Foundation, either version 3 of the License, or
|
nuclear@7
|
8 (at your option) any later version.
|
nuclear@7
|
9
|
nuclear@7
|
10 This program is distributed in the hope that it will be useful,
|
nuclear@7
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
nuclear@7
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
nuclear@7
|
13 GNU Lesser General Public License for more details.
|
nuclear@7
|
14
|
nuclear@7
|
15 You should have received a copy of the GNU Lesser General Public License
|
nuclear@7
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
nuclear@7
|
17 */
|
nuclear@7
|
18 #ifndef TEXT_IMPL_H_
|
nuclear@7
|
19 #define TEXT_IMPL_H_
|
nuclear@7
|
20
|
nuclear@7
|
21 struct glyph {
|
nuclear@7
|
22 int code;
|
nuclear@7
|
23 float x, y, width, height;
|
nuclear@7
|
24 /* normalized coords [0, 1] */
|
nuclear@7
|
25 float nx, ny, nwidth, nheight;
|
nuclear@7
|
26 float orig_x, orig_y;
|
nuclear@7
|
27 float advance;
|
nuclear@7
|
28 struct glyph *next;
|
nuclear@7
|
29 };
|
nuclear@7
|
30
|
nuclear@7
|
31 struct dtx_glyphmap {
|
nuclear@7
|
32 int ptsize;
|
nuclear@7
|
33
|
nuclear@7
|
34 int xsz, ysz;
|
nuclear@7
|
35 unsigned char *pixels;
|
nuclear@7
|
36 unsigned int tex;
|
nuclear@7
|
37
|
nuclear@7
|
38 int cstart, cend; /* character range */
|
nuclear@7
|
39 int crange;
|
nuclear@7
|
40
|
nuclear@7
|
41 float line_advance;
|
nuclear@7
|
42
|
nuclear@7
|
43 struct glyph *glyphs;
|
nuclear@7
|
44 struct dtx_glyphmap *next;
|
nuclear@7
|
45 };
|
nuclear@7
|
46
|
nuclear@7
|
47 struct dtx_font {
|
nuclear@7
|
48 /* freetype FT_Face */
|
nuclear@7
|
49 void *face;
|
nuclear@7
|
50
|
nuclear@7
|
51 /* list of glyphmaps */
|
nuclear@7
|
52 struct dtx_glyphmap *gmaps;
|
nuclear@7
|
53 int num_gmaps;
|
nuclear@7
|
54
|
nuclear@7
|
55 /* last returned glyphmap (cache) */
|
nuclear@7
|
56 struct dtx_glyphmap *last_gmap;
|
nuclear@7
|
57 };
|
nuclear@7
|
58
|
nuclear@7
|
59
|
nuclear@7
|
60 extern struct dtx_font *dtx_font;
|
nuclear@7
|
61 extern int dtx_font_sz;
|
nuclear@7
|
62
|
nuclear@7
|
63
|
nuclear@7
|
64 #define fperror(str) \
|
nuclear@9
|
65 fprintf(stderr, "%s: %s: %s\n", __func__, (str), strerror(errno))
|
nuclear@7
|
66
|
nuclear@7
|
67 int dtx_gl_init(void);
|
nuclear@7
|
68
|
nuclear@7
|
69 /* returns zero if it should NOT be printed and modifies xpos/ypos */
|
nuclear@7
|
70 /* implemented in font.c */
|
nuclear@7
|
71 struct dtx_glyphmap *dtx_proc_char(int code, float *xpos, float *ypos);
|
nuclear@7
|
72
|
nuclear@7
|
73 #endif /* TEXT_IMPL_H_ */
|