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
|
#pragma once
#include <ft2build.h>
#include FT_FREETYPE_H
#include "gl.h"
#include "../util/thread.h"
extern THREAD_MUTEX font_mutex;
typedef struct {
F32 offset_x;
F32 offset_y;
U32 width;
U32 height;
F32 advance_x;
F32 advance_y;
U32 bearing;
} FONT_GLYPH;
const I32 GL_FONT_MAX_GLYPHS = 256;
typedef struct GL_FONT {
FT_Face face;
I32 size;
U32* bitmap;
U32 bitmap_width;
U32 bitmap_height;
U32 char_width;
U32 char_height;
GL_TEX2D* atlas;
const char* name;
FONT_GLYPH glyphs[GL_FONT_MAX_GLYPHS];
} *PGL_FONT;
GL_FONT* gl_font_create( GL_DATA* gl, const char* path, I32 size );
void gl_font_destroy( GL_DATA* gl, GL_FONT* font );
void gl_font_draw( GL_FONT* font, GL_SHADER_PROGRAM* shader, VEC2 pos, const char* text, CLR color, F32 scale = 1.0f );
void gl_font_textured(
GL_FONT* font,
GL_SHADER_PROGRAM* shader,
VEC2 pos,
const char* text,
GL_TEX2D* tex,
CLR color = (CLR){1.f, 1.f, 1.f, 1.f},
F32 scale = 1.0f
);
VEC2 gl_font_dim( GL_FONT* font, const char* text, F32 scale = 1.0f );
void gl_font_fit_into_box( GL_FONT* font, const char* source, char* out, F32 box_width, F32 box_height, F32 scale );
|