libdrawtext

view src/drawtext_impl.h @ 58:11c8b34b0da5

implemented the metrics functions
author John Tsiombikas <nuclear@mutantstargoat.com>
date Sat, 17 Sep 2011 10:09:58 +0300
parents 095ff7ca4e74
children 55c034e70809
line source
1 /*
2 libdrawtext - a simple library for fast text rendering in OpenGL
3 Copyright (C) 2011 John Tsiombikas <nuclear@member.fsf.org>
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.
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.
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 TEXT_IMPL_H_
19 #define TEXT_IMPL_H_
21 struct glyph {
22 int code;
23 float x, y, width, height;
24 /* normalized coords [0, 1] */
25 float nx, ny, nwidth, nheight;
26 float orig_x, orig_y;
27 float advance;
28 struct glyph *next;
29 };
31 struct dtx_glyphmap {
32 int ptsize;
34 int xsz, ysz;
35 unsigned char *pixels;
36 unsigned int tex;
38 int cstart, cend; /* character range */
39 int crange;
41 float line_advance;
43 struct glyph *glyphs;
44 struct dtx_glyphmap *next;
45 };
47 struct dtx_font {
48 /* freetype FT_Face */
49 void *face;
51 /* list of glyphmaps */
52 struct dtx_glyphmap *gmaps;
54 /* last returned glyphmap (cache) */
55 struct dtx_glyphmap *last_gmap;
56 };
59 struct dtx_font *dtx_font;
60 int dtx_font_sz;
63 #define fperror(str) \
64 fprintf(stderr, "%s: %s: %s\n", __func__, (str), strerror(errno))
66 int dtx_gl_init(void);
68 /* returns zero if it should NOT be printed and modifies xpos/ypos */
69 /* implemented in font.c */
70 struct dtx_glyphmap *dtx_proc_char(int code, float *xpos, float *ypos);
72 #endif /* TEXT_IMPL_H_ */