-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfont.h
83 lines (69 loc) · 1.75 KB
/
font.h
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
78
79
80
81
82
83
/*
File: BMFont.h
Project: Platform Development Tools
Date: Sept. 24, 2014
Author: Matt Slevinsky
Based on http://www.angelcode.com/dev/bmfonts/
Description: Bitmap Font Library that is compatible with angelcode's BMF compiler
*/
#ifndef __BMFFONT_H
#define __BMFFONT_H
#include <kos.h>
#include "uthash.h"
#include "utarray.h"
typedef enum EFontTextEncoding {
NONE,
UTF8,
UTF16
} EFontTextEncoding;
typedef enum LineRenderMode {
SINGLE,
MULTILINE
} LineRenderMode;
typedef enum TextAlignmentMode {
LEFT,
CENTER,
RIGHT
} TextAlignmentMode;
typedef struct KerningPair {
uint32 first;
uint32 second;
int16 amount;
} KerningPair;
typedef struct CharDescriptor {
uint32 id;
int16 srcX;
int16 srcY;
int16 srcW;
int16 srcH;
int16 xOff;
int16 yOff;
int16 xAdv;
int16 page;
unsigned int chnl;
UT_array* kerningPairs;
UT_hash_handle hh;
} CharDescriptor;
typedef struct FontPage {
uint16 width;
uint16 height;
pvr_ptr_t texture;
} FontPage;
typedef struct Font {
uint16 fontHeight; // total height of the font
uint16 base; // y of base line
uint16 scaleW;
uint16 scaleH;
CharDescriptor* defChar;
int hasOutline;
float scale;
EFontTextEncoding encoding;
CharDescriptor* characters;
UT_array* pages;
} Font;
Font* load_font(const char* filepath);
void draw_string(Font* font, int currentList, char* string, float xPos, float yPos, float zPos, float width, float height, LineRenderMode lineRenderMode, TextAlignmentMode textAlignmentMode, uint32 color, float scale);
//void measure_line(char* string, uint16* width, uint16* height);
//void measure_string(char* string, uint16* width, uint16* height, LineRenderMode lineRenderMode, TextAlignmentMode textAlignmentMode);
void destroy_font(Font* font);
#endif