nuclear@10: /* nuclear@10: libdrawtext - a simple library for fast text rendering in OpenGL nuclear@10: Copyright (C) 2011-2012 John Tsiombikas nuclear@10: nuclear@10: This program is free software: you can redistribute it and/or modify nuclear@10: it under the terms of the GNU Lesser General Public License as published by nuclear@10: the Free Software Foundation, either version 3 of the License, or nuclear@10: (at your option) any later version. nuclear@10: nuclear@10: This program is distributed in the hope that it will be useful, nuclear@10: but WITHOUT ANY WARRANTY; without even the implied warranty of nuclear@10: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nuclear@10: GNU Lesser General Public License for more details. nuclear@10: nuclear@10: You should have received a copy of the GNU Lesser General Public License nuclear@10: along with this program. If not, see . nuclear@10: */ nuclear@10: #ifndef TEXT_IMPL_H_ nuclear@10: #define TEXT_IMPL_H_ nuclear@10: nuclear@10: struct glyph { nuclear@10: int code; nuclear@10: float x, y, width, height; nuclear@10: /* normalized coords [0, 1] */ nuclear@10: float nx, ny, nwidth, nheight; nuclear@10: float orig_x, orig_y; nuclear@10: float advance; nuclear@10: struct glyph *next; nuclear@10: }; nuclear@10: nuclear@10: struct dtx_glyphmap { nuclear@10: int ptsize; nuclear@10: nuclear@10: int xsz, ysz; nuclear@10: unsigned char *pixels; nuclear@10: unsigned int tex; nuclear@10: nuclear@10: int cstart, cend; /* character range */ nuclear@10: int crange; nuclear@10: nuclear@10: float line_advance; nuclear@10: nuclear@10: struct glyph *glyphs; nuclear@10: struct dtx_glyphmap *next; nuclear@10: }; nuclear@10: nuclear@10: struct dtx_font { nuclear@10: /* freetype FT_Face */ nuclear@10: void *face; nuclear@10: nuclear@10: /* list of glyphmaps */ nuclear@10: struct dtx_glyphmap *gmaps; nuclear@10: nuclear@10: /* last returned glyphmap (cache) */ nuclear@10: struct dtx_glyphmap *last_gmap; nuclear@10: }; nuclear@10: nuclear@10: nuclear@10: struct dtx_font *dtx_font; nuclear@10: int dtx_font_sz; nuclear@10: nuclear@10: nuclear@10: #define fperror(str) \ nuclear@10: fprintf(stderr, "%s: %s: %s\n", __FUNCTION__, (str), strerror(errno)) nuclear@10: nuclear@10: int dtx_gl_init(void); nuclear@10: nuclear@10: /* returns zero if it should NOT be printed and modifies xpos/ypos */ nuclear@10: /* implemented in font.c */ nuclear@10: struct dtx_glyphmap *dtx_proc_char(int code, float *xpos, float *ypos); nuclear@10: nuclear@10: #endif /* TEXT_IMPL_H_ */