DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
ft2.h
Go to the documentation of this file.
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 * We use:
19 * Range E000 - E0FF
20 * Contains the non-FreeType2 version of characters.
21 */
22
23typedef struct ft2_font_map_s ft2_font_map_t;
24typedef struct font_incmap_s font_incmap_t;
25typedef struct incmap_lookup_cache_s incmap_lookup_cache_t;
26typedef struct ft2_attachment_s ft2_attachment_t;
27#ifdef WIN64
28#define ft2_oldstyle_map ((ft2_font_map_t*)-1LL)
29#else
30#define ft2_oldstyle_map ((ft2_font_map_t*)-1)
31#endif
32
33typedef float ft2_kernvec[2];
34typedef struct ft2_kerning_s
35{
36 ft2_kernvec kerning[256][256]; /* kerning[left char][right char] */
38
39typedef struct ft2_font_s
40{
41 char name[64];
43 // last requested size loaded using Font_SetSize
44 float currentw;
45 float currenth;
46 float ascend;
47 float descend;
48 qbool image_font; // only fallbacks are freetype fonts
49
50 // TODO: clean this up and do not expose everything.
51
52 const unsigned char *data; // FT2 needs it to stay
53 //fs_offset_t datasize;
54 void *face;
55
56 // an unordered array of ordered linked lists of glyph maps for a specific size
57 ft2_font_map_t *font_maps[MAX_FONT_SIZES];
59
60 // attachments
62 ft2_attachment_t *attachments;
63
65
66 // fallback mechanism
67 struct ft2_font_s *next;
69
70void Font_CloseLibrary(void);
71void Font_Init(void);
74void Font_UnloadFont(ft2_font_t *font);
75// IndexForSize suggests to change the width and height if a font size is in a reasonable range
76// for example, you render at a size of 12.4, and a font of size 12 has been loaded
77// in such a case, *outw and *outh are set to 12, which is often a good alternative size
78int Font_IndexForSize(ft2_font_t *font, float size, float *outw, float *outh);
79ft2_font_map_t *Font_MapForIndex(ft2_font_t *font, int index);
80qbool Font_LoadFont(const char *name, dp_font_t *dpfnt);
81qbool Font_GetKerningForSize(ft2_font_t *font, float w, float h, Uchar left, Uchar right, float *outx, float *outy);
82qbool Font_GetKerningForMap(ft2_font_t *font, int map_index, float w, float h, Uchar left, Uchar right, float *outx, float *outy);
83float Font_VirtualToRealSize(float sz);
84float Font_SnapTo(float val, float snapwidth);
85// since this is used on a font_map_t, let's name it FontMap_*
86ft2_font_map_t *FontMap_FindForChar(ft2_font_map_t *start, Uchar ch);
87qbool Font_GetMapForChar(ft2_font_t *font, int map_index, Uchar ch, ft2_font_map_t **outmap, int *outmapch);
88#endif // DP_FREETYPE2_H__
vector size
#define MAX_FONT_SIZES
Definition draw.h:94
int Font_IndexForSize(ft2_font_t *font, float size, float *outw, float *outh)
Definition ft2.c:999
float ft2_kernvec[2]
Definition ft2.h:33
qbool Font_OpenLibrary(void)
Definition ft2.c:362
ft2_font_map_t * Font_MapForIndex(ft2_font_t *font, int index)
Definition ft2.c:1052
float Font_SnapTo(float val, float snapwidth)
Definition ft2.c:514
ft2_font_t * Font_Alloc(void)
Definition ft2.c:467
qbool Font_LoadFont(const char *name, dp_font_t *dpfnt)
Definition ft2.c:521
qbool Font_GetKerningForMap(ft2_font_t *font, int map_index, float w, float h, Uchar left, Uchar right, float *outx, float *outy)
Definition ft2.c:1085
void Font_CloseLibrary(void)
Definition ft2.c:339
float Font_VirtualToRealSize(float sz)
Definition ft2.c:496
ft2_font_map_t * FontMap_FindForChar(ft2_font_map_t *start, Uchar ch)
Definition ft2.c:1911
void Font_Init(void)
Definition ft2.c:443
qbool Font_GetMapForChar(ft2_font_t *font, int map_index, Uchar ch, ft2_font_map_t **outmap, int *outmapch)
Query for or load a font map for a character, with the character's place on it.
Definition ft2.c:1971
struct incmap_lookup_cache_s incmap_lookup_cache_t
Definition ft2.h:25
void Font_UnloadFont(ft2_font_t *font)
Definition ft2.c:1184
qbool Font_GetKerningForSize(ft2_font_t *font, float w, float h, Uchar left, Uchar right, float *outx, float *outy)
Definition ft2.c:1143
GLubyte GLubyte GLubyte GLubyte w
Definition glquake.h:782
const GLchar * name
Definition glquake.h:601
GLuint index
Definition glquake.h:629
bool qbool
Definition qtypes.h:9
int num_sizes
Definition ft2.h:58
float currenth
Definition ft2.h:45
qbool image_font
Definition ft2.h:48
float descend
Definition ft2.h:47
ft2_settings_t * settings
Definition ft2.h:64
void * face
Definition ft2.h:54
float ascend
Definition ft2.h:46
size_t attachmentcount
Definition ft2.h:61
qbool has_kerning
Definition ft2.h:42
ft2_attachment_t * attachments
Definition ft2.h:62
struct ft2_font_s * next
Definition ft2.h:67
float currentw
Definition ft2.h:44
const unsigned char * data
Definition ft2.h:52
static vec3_t right
Definition sv_user.c:305
int32_t Uchar
Definition utf8lib.h:35