]> icculus.org git repositories - divverent/darkplaces.git/blob - ft2.h
better size-seeking and float sizes in DrawQ_TextWidth
[divverent/darkplaces.git] / ft2.h
1 /* Header for FreeType 2 and UTF-8 encoding support for
2  * DarkPlaces
3  */
4
5 #ifndef DP_FREETYPE2_H__
6 #define DP_FREETYPE2_H__
7
8 //#include <sys/types.h>
9
10 #include "utf8lib.h"
11
12 /* 
13  * From http://www.unicode.org/Public/UNIDATA/Blocks.txt
14  *
15  *   E000..F8FF; Private Use Area
16  *   F0000..FFFFF; Supplementary Private Use Area-A
17  *
18  * TODO:
19  *   Range E000 - E0FF
20  *     Contains the non-FreeType2 version of characters.
21  */
22
23 typedef struct ft2_font_map_s ft2_font_map_t;
24 typedef struct ft2_attachment_s ft2_attachment_t;
25 #define ft2_oldstyle_map ((ft2_font_map_t*)-1)
26
27 typedef float ft2_kernvec[2];
28 typedef struct ft2_kerning_s
29 {
30         ft2_kernvec kerning[256][256]; /* kerning[left char][right char] */
31 } ft2_kerning_t;
32
33 typedef struct ft2_font_s
34 {
35         char            name[64];
36
37         qboolean        has_kerning;
38
39         // TODO: clean this up and do not expose everything.
40         
41         //unsigned char  *data;
42         //fs_offset_t     datasize;
43         void           *face;
44
45         // an unordered array of ordered linked lists of glyph maps for a specific size
46         ft2_font_map_t *font_maps[MAX_FONT_SIZES];
47         int             num_sizes;
48
49         // attachments
50         size_t            attachmentcount;
51         ft2_attachment_t *attachments;
52 } ft2_font_t;
53
54 void            Font_CloseLibrary(void);
55 void            Font_Init(void);
56 qboolean        Font_OpenLibrary(void);
57 ft2_font_t*     Font_Alloc(void);
58 void            Font_UnloadFont(ft2_font_t *font);
59 //qboolean        Font_LoadFont(const char *name, int size, int face, ft2_font_t *font);
60 int             Font_IndexForSize(ft2_font_t *font, float size);
61 ft2_font_map_t *Font_MapForIndex(ft2_font_t *font, int index);
62 qboolean        Font_LoadFont(const char *name, dp_font_t *dpfnt);
63 qboolean        Font_GetKerningForSize(ft2_font_t *font, int size, Uchar left, Uchar right, float *outx, float *outy);
64 qboolean        Font_GetKerningForMap(ft2_font_t *font, int map_index, Uchar left, Uchar right, float *outx, float *outy);
65
66 #endif // DP_FREETYPE2_H__