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