summaryrefslogtreecommitdiffstats
path: root/lib/fosphor/gl_font.h
blob: 85a9da7efe0b6fb354069ad2ad67e4a005003f4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * gl_font.h
 *
 * Basic OpenGL font rendering
 *
 * Copyright (C) 2013-2014 Sylvain Munaut
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __FOSPHOR_GL_FONT_H__
#define __FOSPHOR_GL_FONT_H__

/*! \defgroup gl/font
 *  @{
 */

/*! \file gl_font.h
 *  \brief Basic OpenGL font rendering
 */

#ifdef _MSC_VER
# define ATTR_FORMAT(a,b,c)
#else
# define ATTR_FORMAT(a,b,c) __attribute__((format(a,b,c)))
#endif


struct gl_font;

#define GLF_FLG_LCD	(1 << 0)

enum glf_align
{
	GLF_LEFT,
	GLF_RIGHT,
	GLF_TOP,
	GLF_BOTTOM,
	GLF_CENTER,
};

struct gl_font *glf_alloc(int height, int flags);
void glf_free(struct gl_font *glf);

int glf_load_face_file(struct gl_font *glf, const char *filename);
int glf_load_face_mem(struct gl_font *glf, const void *data, size_t len);

float glf_width_str(const struct gl_font *glf, const char *str);

void glf_draw_str(const struct gl_font *glf,
                  float x, enum glf_align x_align,
                  float y, enum glf_align y_align,
                  const char *str);

void glf_printf(const struct gl_font *glf,
                float x, enum glf_align x_align,
                float y, enum glf_align y_align,
                const char *fmt, ...) ATTR_FORMAT(printf, 6, 7);

void glf_begin(const struct gl_font *glf, float fg_color[3]);
void glf_end(void);


/*! @} */

#endif /* __FOSPHOR_GL_FONT_H__ */