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