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