X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=demo_prior;a=blobdiff_plain;f=libs%2Fdrawtext%2Fsrc%2Fdrawtext_impl.h;fp=libs%2Fdrawtext%2Fsrc%2Fdrawtext_impl.h;h=31042e3fdc5854aff7d574aaab6907eb31ec7a82;hp=0000000000000000000000000000000000000000;hb=2f14a35e7d557da12f24056267b911f24774aa18;hpb=5eefe7b94c8d6c6caa2c10e3835ab0831a3c42a1 diff --git a/libs/drawtext/src/drawtext_impl.h b/libs/drawtext/src/drawtext_impl.h new file mode 100644 index 0000000..31042e3 --- /dev/null +++ b/libs/drawtext/src/drawtext_impl.h @@ -0,0 +1,94 @@ +/* +libdrawtext - a simple library for fast text rendering in OpenGL +Copyright (C) 2011-2016 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef DRAWTEXT_IMPL_H_ +#define DRAWTEXT_IMPL_H_ + +#include "drawtext.h" + +struct glyph { + int code; + float x, y, width, height; + /* normalized coords [0, 1] */ + float nx, ny, nwidth, nheight; + float orig_x, orig_y; + float advance; + struct glyph *next; +}; + +struct dtx_glyphmap { + int ptsize; + + int xsz, ysz; + unsigned int xsz_shift; + unsigned char *pixels; + unsigned int tex; + int tex_valid; + void *udata; + + int cstart, cend; /* character range */ + int crange; + + float line_advance; + float baseline; + + struct glyph *glyphs; + struct dtx_glyphmap *next; +}; + +struct dtx_font { + /* freetype FT_Face */ + void *face; + + /* list of glyphmaps */ + struct dtx_glyphmap *gmaps; + + /* last returned glyphmap (cache) */ + struct dtx_glyphmap *last_gmap; +}; + +#ifndef COMMON +#define COMMON extern +#endif + +COMMON struct dtx_font *dtx_font; +COMMON int dtx_font_sz; +COMMON int dtx_buf_mode; /* DTX_NBF is 0 */ +COMMON float dtx_cur_color[4]; +COMMON int dtx_cur_color_int[4]; +COMMON float dtx_cur_offset[2]; + +#define fperror(str) \ + fprintf(stderr, "%s: %s: %s\n", __func__, (str), strerror(errno)) + +#ifdef _MSC_VER +#define __func__ __FUNCTION__ +#endif + +/* returns zero if it should NOT be printed and modifies xpos/ypos */ +/* implemented in font.c */ +struct dtx_glyphmap *dtx_proc_char(int code, float *xpos, float *ypos); + +COMMON const char *(*dtx_drawchar)(const char*, float*, float*, int*); +COMMON void (*dtx_drawflush)(void); + +int dtx_gl_setopt(enum dtx_option opt, int val); +int dtx_gl_getopt(enum dtx_option opt, int *ret); +int dtx_rast_setopt(enum dtx_option opt, int val); +int dtx_rast_getopt(enum dtx_option opt, int *ret); + +#endif /* DRAWTEXT_IMPL_H_ */