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