]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - ft2_fontdefs.h
Added R_SkinFrame_PurgeSkinFrame to de-duplicate some repeated code.
[xonotic/darkplaces.git] / ft2_fontdefs.h
1 #ifndef FT2_PRIVATE_H__
2 #define FT2_PRIVATE_H__
3
4 // anything should work, but I recommend multiples of 8
5 // since the texture size should be a power of 2
6 #define FONT_CHARS_PER_LINE 16
7 #define FONT_CHAR_LINES 16
8 #define FONT_CHARS_PER_MAP (FONT_CHARS_PER_LINE * FONT_CHAR_LINES)
9
10 typedef struct glyph_slot_s
11 {
12         qboolean image;
13         // we keep the quad coords here only currently
14         // if you need other info, make Font_LoadMapForIndex fill it into this slot
15         float txmin; // texture coordinate in [0,1]
16         float txmax;
17         float tymin;
18         float tymax;
19         float vxmin;
20         float vxmax;
21         float vymin;
22         float vymax;
23         float advance_x;
24         float advance_y;
25 } glyph_slot_t;
26
27 struct ft2_font_map_s
28 {
29         Uchar                  start;
30         struct ft2_font_map_s *next;
31         float                  size;
32         // the actual size used in the freetype code
33         // by convention, the requested size is the height of the font's bounding box.
34         float                  intSize;
35         int                    glyphSize;
36
37         cachepic_t            *pic;
38         qboolean               static_tex;
39         glyph_slot_t           glyphs[FONT_CHARS_PER_MAP];
40
41         // contains the kerning information for the first 256 characters
42         // for the other characters, we will lookup the kerning information
43         ft2_kerning_t          kerning;
44         // safes us the trouble of calculating these over and over again
45         double                 sfx, sfy;
46
47         // the width_of for the image-font, pixel-snapped for this size
48         float           width_of[256];
49 };
50
51 struct ft2_attachment_s
52 {
53         const unsigned char *data;
54         fs_offset_t    size;
55 };
56
57 //qboolean Font_LoadMapForIndex(ft2_font_t *font, Uchar _ch, ft2_font_map_t **outmap);
58 qboolean Font_LoadMapForIndex(ft2_font_t *font, int map_index, Uchar _ch, ft2_font_map_t **outmap);
59
60 void font_start(void);
61 void font_shutdown(void);
62 void font_newmap(void);
63
64 #endif // FT2_PRIVATE_H__