]> git.xonotic.org Git - xonotic/darkplaces.git/blob - ft2_fontdefs.h
physics: fix and refactor unsticking
[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 // map.start value for incremental maps to hold a place
11 #define INCMAP_START 0x110000
12
13 typedef struct glyph_slot_s
14 {
15         qbool image;
16         // we keep the quad coords here only currently
17         // if you need other info, make Font_LoadMapForIndex fill it into this slot
18         float txmin; // texture coordinate in [0,1]
19         float txmax;
20         float tymin;
21         float tymax;
22         float vxmin;
23         float vxmax;
24         float vymin;
25         float vymax;
26         float advance_x;
27         float advance_y;
28 } glyph_slot_t;
29
30 struct ft2_font_map_s
31 {
32         Uchar  start;
33         float  size;
34
35         // the actual size used in the freetype code
36         // by convention, the requested size is the height of the font's bounding box.
37         float  intSize;
38         int    glyphSize;
39
40         ft2_font_map_t *next;
41         cachepic_t     *pic;
42         qbool           static_tex;
43         glyph_slot_t    glyphs[FONT_CHARS_PER_MAP];
44         Uchar           glyphchars[FONT_CHARS_PER_MAP];
45
46         // saves us the trouble of calculating these over and over again
47         double          sfx, sfy;
48
49         // note: float width_of[256] was moved to `struct dp_font_s` as width_of_ft2
50
51         // these may only present in a startmap
52         // contains the kerning information for the first 256 characters
53         // for the other characters, we will lookup the kerning information
54         ft2_kerning_t  *kerning;
55         // for accessing incremental maps for bigblock glyphs
56         font_incmap_t  *incmap;
57 };
58
59 struct font_incmap_s
60 {
61         // associated fontmap; startmap of incmaps
62         struct ft2_font_map_s *fontmap;
63         int charcount;
64         int newmap_start;
65
66         // two rounds of merge will take place, keep those data until then
67         unsigned char *data_tier1[FONT_CHARS_PER_LINE];
68         unsigned char *data_tier2[FONT_CHAR_LINES];
69
70         // count of merged maps
71         int tier1_merged, tier2_merged;
72 };
73
74 struct ft2_attachment_s
75 {
76         const unsigned char *data;
77         fs_offset_t          size;
78 };
79
80 //qbool Font_LoadMapForIndex(ft2_font_t *font, Uchar _ch, ft2_font_map_t **outmap);
81 qbool Font_LoadMapForIndex(ft2_font_t *font, int map_index, Uchar _ch, ft2_font_map_t **outmap);
82
83 void font_start(void);
84 void font_shutdown(void);
85 void font_newmap(void);
86
87 #endif // FT2_PRIVATE_H__