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