1 /* Header for FreeType 2 and UTF-8 encoding support for
5 #ifndef DP_FREETYPE2_H__
6 #define DP_FREETYPE2_H__
8 //#include <sys/types.h>
13 * From http://www.unicode.org/Public/UNIDATA/Blocks.txt
15 * E000..F8FF; Private Use Area
16 * F0000..FFFFF; Supplementary Private Use Area-A
20 * Contains the non-FreeType2 version of characters.
23 typedef struct ft2_font_map_s ft2_font_map_t;
24 typedef struct ft2_attachment_s ft2_attachment_t;
26 #define ft2_oldstyle_map ((ft2_font_map_t*)-1LL)
28 #define ft2_oldstyle_map ((ft2_font_map_t*)-1)
31 typedef float ft2_kernvec[2];
32 typedef struct ft2_kerning_s
34 ft2_kernvec kerning[256][256]; /* kerning[left char][right char] */
37 typedef struct ft2_font_s
41 // last requested size loaded using Font_SetSize
46 qboolean image_font; // only fallbacks are freetype fonts
48 // TODO: clean this up and do not expose everything.
50 const unsigned char *data; // FT2 needs it to stay
51 //fs_offset_t datasize;
54 // an unordered array of ordered linked lists of glyph maps for a specific size
55 ft2_font_map_t *font_maps[MAX_FONT_SIZES];
59 size_t attachmentcount;
60 ft2_attachment_t *attachments;
62 ft2_settings_t *settings;
65 struct ft2_font_s *next;
68 void Font_CloseLibrary(void);
70 qboolean Font_OpenLibrary(void);
71 ft2_font_t* Font_Alloc(void);
72 void Font_UnloadFont(ft2_font_t *font);
73 // IndexForSize suggests to change the width and height if a font size is in a reasonable range
74 // for example, you render at a size of 12.4, and a font of size 12 has been loaded
75 // in such a case, *outw and *outh are set to 12, which is often a good alternative size
76 int Font_IndexForSize(ft2_font_t *font, float size, float *outw, float *outh);
77 ft2_font_map_t *Font_MapForIndex(ft2_font_t *font, int index);
78 qboolean Font_LoadFont(const char *name, dp_font_t *dpfnt);
79 qboolean Font_GetKerningForSize(ft2_font_t *font, float w, float h, Uchar left, Uchar right, float *outx, float *outy);
80 qboolean Font_GetKerningForMap(ft2_font_t *font, int map_index, float w, float h, Uchar left, Uchar right, float *outx, float *outy);
81 float Font_VirtualToRealSize(float sz);
82 float Font_SnapTo(float val, float snapwidth);
83 // since this is used on a font_map_t, let's name it FontMap_*
84 ft2_font_map_t *FontMap_FindForChar(ft2_font_map_t *start, Uchar ch);
85 #endif // DP_FREETYPE2_H__