vrshoot

annotate libs/drawtext/drawtext_impl.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
rev   line source
nuclear@0 1 /*
nuclear@0 2 libdrawtext - a simple library for fast text rendering in OpenGL
nuclear@0 3 Copyright (C) 2011-2012 John Tsiombikas <nuclear@member.fsf.org>
nuclear@0 4
nuclear@0 5 This program is free software: you can redistribute it and/or modify
nuclear@0 6 it under the terms of the GNU Lesser General Public License as published by
nuclear@0 7 the Free Software Foundation, either version 3 of the License, or
nuclear@0 8 (at your option) any later version.
nuclear@0 9
nuclear@0 10 This program is distributed in the hope that it will be useful,
nuclear@0 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
nuclear@0 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
nuclear@0 13 GNU Lesser General Public License for more details.
nuclear@0 14
nuclear@0 15 You should have received a copy of the GNU Lesser General Public License
nuclear@0 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
nuclear@0 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 float baseline;
nuclear@0 43
nuclear@0 44 struct glyph *glyphs;
nuclear@0 45 struct dtx_glyphmap *next;
nuclear@0 46 };
nuclear@0 47
nuclear@0 48 struct dtx_font {
nuclear@0 49 /* freetype FT_Face */
nuclear@0 50 void *face;
nuclear@0 51
nuclear@0 52 /* list of glyphmaps */
nuclear@0 53 struct dtx_glyphmap *gmaps;
nuclear@0 54
nuclear@0 55 /* last returned glyphmap (cache) */
nuclear@0 56 struct dtx_glyphmap *last_gmap;
nuclear@0 57 };
nuclear@0 58
nuclear@0 59
nuclear@0 60 struct dtx_font *dtx_font;
nuclear@0 61 int dtx_font_sz;
nuclear@0 62
nuclear@0 63
nuclear@0 64 #define fperror(str) \
nuclear@0 65 fprintf(stderr, "%s: %s: %s\n", __FUNCTION__, (str), strerror(errno))
nuclear@0 66
nuclear@0 67 int dtx_gl_init(void);
nuclear@0 68
nuclear@0 69 /* returns zero if it should NOT be printed and modifies xpos/ypos */
nuclear@0 70 /* implemented in font.c */
nuclear@0 71 struct dtx_glyphmap *dtx_proc_char(int code, float *xpos, float *ypos);
nuclear@0 72
nuclear@0 73 #endif /* TEXT_IMPL_H_ */