| 1 | /* |
| 2 | libdrawtext - a simple library for fast text rendering in OpenGL |
| 3 | Copyright (C) 2011-2012 John Tsiombikas <nuclear@member.fsf.org> |
| 4 | |
| 5 | This program is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU Lesser General Public License as published by |
| 7 | the Free Software Foundation, either version 3 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public License |
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | #pragma once |
| 19 | |
| 20 | struct glyph { |
| 21 | int code; |
| 22 | float x, y, width, height; |
| 23 | /* normalized coords [0, 1] */ |
| 24 | float nx, ny, nwidth, nheight; |
| 25 | float orig_x, orig_y; |
| 26 | float advance; |
| 27 | struct glyph *next; |
| 28 | }; |
| 29 | |
| 30 | struct dtx_glyphmap { |
| 31 | int ptsize; |
| 32 | |
| 33 | int xsz, ysz; |
| 34 | unsigned char *pixels; |
| 35 | unsigned int tex; |
| 36 | |
| 37 | int cstart, cend; /* character range */ |
| 38 | int crange; |
| 39 | |
| 40 | float line_advance; |
| 41 | |
| 42 | struct glyph *glyphs; |
| 43 | struct dtx_glyphmap *next; |
| 44 | }; |
| 45 | |
| 46 | // refers to a particular type of font |
| 47 | struct dtx_font { |
| 48 | // freetype FT_Face |
| 49 | void *face; |
| 50 | |
| 51 | // active glyphmap |
| 52 | struct dtx_glyphmap *gmaps; |
| 53 | |
| 54 | // cache of the last active glyphmap |
| 55 | struct dtx_glyphmap *last_gmap; |
| 56 | }; |
| 57 | |
| 58 | int dtx_interpolation; |
| 59 | struct dtx_font *dtx_font; |
| 60 | int dtx_font_sz; |
| 61 | |
| 62 | |
| 63 | #define fperror(str) \ |
| 64 | fprintf(stderr, "%s: %s: %s\n", __FUNCTION__, (str), strerror(errno)) |
| 65 | |