DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
ft2.h File Reference
#include "utf8lib.h"
+ Include dependency graph for ft2.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ft2_font_t
 
struct  ft2_kerning_t
 

Macros

#define ft2_oldstyle_map   ((ft2_font_map_t*)-1)
 

Typedefs

typedef float ft2_kernvec[2]
 
typedef struct incmap_lookup_cache_s incmap_lookup_cache_t
 

Functions

ft2_font_tFont_Alloc (void)
 
void Font_CloseLibrary (void)
 
qbool Font_GetKerningForMap (ft2_font_t *font, int map_index, float w, float h, Uchar left, Uchar right, float *outx, float *outy)
 
qbool Font_GetKerningForSize (ft2_font_t *font, float w, float h, Uchar left, Uchar right, float *outx, float *outy)
 
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.
 
int Font_IndexForSize (ft2_font_t *font, float size, float *outw, float *outh)
 
void Font_Init (void)
 
qbool Font_LoadFont (const char *name, dp_font_t *dpfnt)
 
ft2_font_map_t * Font_MapForIndex (ft2_font_t *font, int index)
 
qbool Font_OpenLibrary (void)
 
float Font_SnapTo (float val, float snapwidth)
 
void Font_UnloadFont (ft2_font_t *font)
 
float Font_VirtualToRealSize (float sz)
 
ft2_font_map_t * FontMap_FindForChar (ft2_font_map_t *start, Uchar ch)
 

Macro Definition Documentation

◆ ft2_oldstyle_map

#define ft2_oldstyle_map   ((ft2_font_map_t*)-1)

Definition at line 30 of file ft2.h.

Referenced by DrawQ_String_Scale(), and DrawQ_TextWidth_UntilWidth_TrackColors_Scale().

Typedef Documentation

◆ ft2_kernvec

typedef float ft2_kernvec[2]

Definition at line 33 of file ft2.h.

◆ incmap_lookup_cache_t

typedef struct incmap_lookup_cache_s incmap_lookup_cache_t

Definition at line 25 of file ft2.h.

Function Documentation

◆ Font_Alloc()

ft2_font_t * Font_Alloc ( void )

Definition at line 467 of file ft2.c.

468{
469#ifndef DP_FREETYPE_STATIC
470 if (!ft2_dll)
471#else
473#endif
474 return NULL;
475 return (ft2_font_t *)Mem_Alloc(font_mempool, sizeof(ft2_font_t));
476}
cvar_t r_font_disable_freetype
Definition ft2.c:55
static mempool_t * font_mempool
Memory pool for fonts.
Definition ft2.c:241
static dllhandle_t ft2_dll
Handle for FreeType2 DLL.
Definition ft2.c:159
#define NULL
Definition qtypes.h:12
int integer
Definition cvar.h:73
#define Mem_Alloc(pool, size)
Definition zone.h:92

References font_mempool, ft2_dll, cvar_t::integer, Mem_Alloc, NULL, and r_font_disable_freetype.

Referenced by Font_LoadFont().

◆ Font_CloseLibrary()

void Font_CloseLibrary ( void )

Definition at line 339 of file ft2.c.

340{
342 if (font_mempool)
345 {
348 }
349#ifndef DP_FREETYPE_STATIC
351#endif
352 pp.buf = NULL;
353}
(* qFT_Done_FreeType)(FT_Library library)
Definition ft2.c:77
static FT_Library font_ft2lib
FreeType library handle.
Definition ft2.c:244
static void fontfilecache_FreeAll(void)
Definition ft2.c:320
static font_postprocess_t pp
Definition ft2.c:257
unsigned char * buf
Definition ft2.c:249
void Sys_FreeLibrary(dllhandle_t *handle)
Definition sys_shared.c:245
#define Mem_FreePool(pool)
Definition zone.h:105

References font_postprocess_t::buf, font_ft2lib, font_mempool, fontfilecache_FreeAll(), ft2_dll, Mem_FreePool, NULL, pp, qFT_Done_FreeType, and Sys_FreeLibrary().

Referenced by font_shutdown(), and font_start().

◆ Font_GetKerningForMap()

qbool Font_GetKerningForMap ( ft2_font_t * font,
int map_index,
float w,
float h,
Uchar left,
Uchar right,
float * outx,
float * outy )

Definition at line 1085 of file ft2.c.

1086{
1087 ft2_font_map_t *fmap;
1088 if (!font->has_kerning || !r_font_kerning.integer)
1089 return false;
1090 if (map_index < 0 || map_index >= MAX_FONT_SIZES)
1091 return false;
1092 fmap = font->font_maps[map_index];
1093 if (!fmap)
1094 return false;
1095 if (left < 256 && right < 256)
1096 {
1097 //Con_Printf("%g : %f, %f, %f :: %f\n", (w / (float)fmap->size), w, fmap->size, fmap->intSize, Font_VirtualToRealSize(w));
1098 // quick-kerning, be aware of the size: scale it
1099 if (outx) *outx = fmap->kerning->kerning[left][right][0];// * (w / (float)fmap->size);
1100 if (outy) *outy = fmap->kerning->kerning[left][right][1];// * (h / (float)fmap->size);
1101 return true;
1102 }
1103 else
1104 {
1105 FT_Vector kernvec;
1106 FT_ULong ul, ur;
1107
1108 //if (qFT_Set_Pixel_Sizes((FT_Face)font->face, 0, fmap->size))
1109#if 0
1110 if (!Font_SetSize(font, w, h))
1111 {
1112 // this deserves an error message
1113 Con_Printf("Failed to get kerning for %s\n", font->name);
1114 return false;
1115 }
1116 ul = qFT_Get_Char_Index(font->face, left);
1117 ur = qFT_Get_Char_Index(font->face, right);
1118 if (qFT_Get_Kerning(font->face, ul, ur, FT_KERNING_DEFAULT, &kernvec))
1119 {
1120 if (outx) *outx = Font_SnapTo(kernvec.x * fmap->sfx, 1 / fmap->size);
1121 if (outy) *outy = Font_SnapTo(kernvec.y * fmap->sfy, 1 / fmap->size);
1122 return true;
1123 }
1124#endif
1125 if (!Font_SetSize(font, fmap->intSize, fmap->intSize))
1126 {
1127 // this deserves an error message
1128 Con_Printf(CON_ERROR "Failed to get kerning for %s\n", font->name);
1129 return false;
1130 }
1131 ul = qFT_Get_Char_Index((FT_Face)font->face, left);
1132 ur = qFT_Get_Char_Index((FT_Face)font->face, right);
1133 if (qFT_Get_Kerning((FT_Face)font->face, ul, ur, FT_KERNING_DEFAULT, &kernvec))
1134 {
1135 if (outx) *outx = Font_SnapTo(kernvec.x * fmap->sfx, 1 / fmap->size);// * (w / (float)fmap->size);
1136 if (outy) *outy = Font_SnapTo(kernvec.y * fmap->sfy, 1 / fmap->size);// * (h / (float)fmap->size);
1137 return true;
1138 }
1139 return false;
1140 }
1141}
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
#define CON_ERROR
Definition console.h:102
#define MAX_FONT_SIZES
Definition draw.h:94
(* qFT_Get_Char_Index)(FT_Face face, FT_ULong charcode)
Definition ft2.c:118
float Font_SnapTo(float val, float snapwidth)
Definition ft2.c:514
static qbool Font_SetSize(ft2_font_t *font, float w, float h)
Definition ft2.c:1059
cvar_t r_font_kerning
Definition ft2.c:57
(* qFT_Get_Kerning)(FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph, FT_UInt kern_mode, FT_Vector *akerning)
Definition ft2.c:124
unsigned long FT_ULong
Definition ft2_defs.h:28
@ FT_KERNING_DEFAULT
Definition ft2_defs.h:495
struct FT_FaceRec_ * FT_Face
Definition ft2_defs.h:36
GLubyte GLubyte GLubyte GLubyte w
Definition glquake.h:782
FT_Pos x
Definition ft2_defs.h:48
FT_Pos y
Definition ft2_defs.h:49
ft2_font_map_t * font_maps[MAX_FONT_SIZES]
Definition ft2.h:57
void * face
Definition ft2.h:54
char name[64]
Definition ft2.h:41
qbool has_kerning
Definition ft2.h:42
static vec3_t right
Definition sv_user.c:305

References CON_ERROR, Con_Printf(), ft2_font_t::face, ft2_font_t::font_maps, Font_SetSize(), Font_SnapTo(), FT_KERNING_DEFAULT, ft2_font_t::has_kerning, cvar_t::integer, MAX_FONT_SIZES, ft2_font_t::name, qFT_Get_Char_Index, qFT_Get_Kerning, r_font_kerning, right, w, FT_Vector::x, and FT_Vector::y.

Referenced by DrawQ_String_Scale(), DrawQ_TextWidth_UntilWidth_TrackColors_Scale(), and Font_GetKerningForSize().

◆ Font_GetKerningForSize()

qbool Font_GetKerningForSize ( ft2_font_t * font,
float w,
float h,
Uchar left,
Uchar right,
float * outx,
float * outy )

Definition at line 1143 of file ft2.c.

1144{
1145 return Font_GetKerningForMap(font, Font_IndexForSize(font, h, NULL, NULL), w, h, left, right, outx, outy);
1146}
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
int Font_IndexForSize(ft2_font_t *font, float _fsize, float *outw, float *outh)
Definition ft2.c:999

References Font_GetKerningForMap(), Font_IndexForSize(), NULL, right, and w.

◆ Font_GetMapForChar()

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.

Supports the incremental map mechanism; returning if the operation is done successfully

Definition at line 1971 of file ft2.c.

1972{
1973 qbool use_incmap;
1974 ft2_font_map_t *map;
1975
1976 // startmap
1977 map = Font_MapForIndex(font, map_index);
1978
1979 // optimize: the first map must have been loaded already
1980 if (ch < FONT_CHARS_PER_MAP)
1981 {
1982 *outmapch = ch;
1983 *outmap = map;
1984 return true;
1985 }
1986
1987 // search for the character
1988
1989 use_incmap = should_use_incmap(ch);
1990
1991 if (!use_incmap)
1992 {
1993 // normal way
1994 *outmapch = ch % FONT_CHARS_PER_MAP;
1995 while (map && map->start + FONT_CHARS_PER_MAP <= ch)
1996 map = map->next;
1997 if (map && map->start <= ch)
1998 {
1999 *outmap = map;
2000 return true;
2001 }
2002 }
2003 else if (get_char_from_incmap(map, ch, outmap, outmapch))
2004 // got it
2005 return true;
2006
2007 // so no appropriate map was found, load one
2008
2009 if (map_index < 0 || map_index >= MAX_FONT_SIZES)
2010 return false;
2011 return Font_LoadMap(font, font->font_maps[map_index], ch, outmap, outmapch, use_incmap);
2012}
ft2_font_map_t * Font_MapForIndex(ft2_font_t *font, int index)
Definition ft2.c:1052
static qbool Font_LoadMap(ft2_font_t *font, ft2_font_map_t *mapstart, Uchar _ch, ft2_font_map_t **outmap, int *outmapch, qbool incmap_ok)
Definition ft2.c:1385
static qbool get_char_from_incmap(ft2_font_map_t *map, Uchar ch, ft2_font_map_t **outmap, int *outmapch)
Definition ft2.c:1936
static qbool should_use_incmap(Uchar ch)
Definition ft2.c:1922
#define FONT_CHARS_PER_MAP
Definition ft2_fontdefs.h:8
bool qbool
Definition qtypes.h:9

References FONT_CHARS_PER_MAP, Font_LoadMap(), Font_MapForIndex(), ft2_font_t::font_maps, get_char_from_incmap(), MAX_FONT_SIZES, and should_use_incmap().

Referenced by DrawQ_String_Scale(), and DrawQ_TextWidth_UntilWidth_TrackColors_Scale().

◆ Font_IndexForSize()

int Font_IndexForSize ( ft2_font_t * font,
float size,
float * outw,
float * outh )

Definition at line 999 of file ft2.c.

1000{
1001 int match = -1;
1002 float value = 1000000;
1003 float nval;
1004 int matchsize = -10000;
1005 int m;
1006 float fsize_x, fsize_y;
1007 ft2_font_map_t **maps = font->font_maps;
1008
1009 fsize_x = fsize_y = _fsize * vid.mode.height / vid_conheight.value;
1010 if(outw && *outw)
1011 fsize_x = *outw * vid.mode.width / vid_conwidth.value;
1012 if(outh && *outh)
1013 fsize_y = *outh * vid.mode.height / vid_conheight.value;
1014
1015 if (fsize_x < 0)
1016 {
1017 if(fsize_y < 0)
1018 fsize_x = fsize_y = 16;
1019 else
1020 fsize_x = fsize_y;
1021 }
1022 else
1023 {
1024 if(fsize_y < 0)
1025 fsize_y = fsize_x;
1026 }
1027
1028 for (m = 0; m < MAX_FONT_SIZES; ++m)
1029 {
1030 if (!maps[m])
1031 continue;
1032 // "round up" to the bigger size if two equally-valued matches exist
1033 nval = 0.5 * (fabs(maps[m]->size - fsize_x) + fabs(maps[m]->size - fsize_y));
1034 if (match == -1 || nval < value || (nval == value && matchsize < maps[m]->size))
1035 {
1036 value = nval;
1037 match = m;
1038 matchsize = maps[m]->size;
1039 if (value == 0) // there is no better match
1040 break;
1041 }
1042 }
1044 {
1045 // do NOT keep the aspect for perfect rendering
1046 if (outh) *outh = maps[match]->size * vid_conheight.value / vid.mode.height;
1047 if (outw) *outw = maps[match]->size * vid_conwidth.value / vid.mode.width;
1048 }
1049 return match;
1050}
cvar_t vid_conheight
Definition cl_screen.c:57
cvar_t vid_conwidth
Definition cl_screen.c:56
vector size
cvar_t r_font_size_snapping
Definition ft2.c:56
GLsizei const GLfloat * value
Definition glquake.h:740
float fabs(float f)
float value
Definition cvar.h:74
int width
Definition vid.h:60
int height
Definition vid.h:61
viddef_mode_t mode
currently active video mode
Definition vid.h:73
viddef_t vid
global video state
Definition vid_shared.c:64

References fabs(), ft2_font_t::font_maps, viddef_mode_t::height, MAX_FONT_SIZES, viddef_t::mode, r_font_size_snapping, size, cvar_t::value, value, vid, vid_conheight, vid_conwidth, and viddef_mode_t::width.

Referenced by DrawQ_String_Scale(), DrawQ_TextWidth_UntilWidth_TrackColors_Scale(), and Font_GetKerningForSize().

◆ Font_Init()

void Font_Init ( void )

Definition at line 443 of file ft2.c.

444{
452
454
455 // let's open it at startup already
457}
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
cvar_t r_font_disable_incmaps
Definition ft2.c:63
cvar_t r_font_nonpoweroftwo
Definition ft2.c:60
qbool Font_OpenLibrary(void)
Definition ft2.c:362
cvar_t r_font_compress
Definition ft2.c:59
cvar_t r_font_diskcache
Definition ft2.c:58
cvar_t developer_font
Definition ft2.c:61

◆ Font_LoadFont()

qbool Font_LoadFont ( const char * name,
dp_font_t * dpfnt )

Definition at line 521 of file ft2.c.

522{
523 int s, count, i;
524 ft2_font_t *ft2, *fbfont, *fb;
525 char vabuf[1024];
526
527 ft2 = Font_Alloc();
528 if (!ft2)
529 {
530 dpfnt->ft2 = NULL;
531 return false;
532 }
533
534 // check if a fallback font has been specified, if it has been, and the
535 // font fails to load, use the image font as main font
536 for (i = 0; i < MAX_FONT_FALLBACKS; ++i)
537 {
538 if (dpfnt->fallbacks[i][0])
539 break;
540 }
541
542 if (!Font_LoadFile(name, dpfnt->req_face, &dpfnt->settings, ft2))
543 {
544 if (i >= MAX_FONT_FALLBACKS)
545 {
546 dpfnt->ft2 = NULL;
547 Mem_Free(ft2);
548 return false;
549 }
550 dp_strlcpy(ft2->name, name, sizeof(ft2->name));
551 ft2->image_font = true;
552 ft2->has_kerning = false;
553 }
554 else
555 {
556 ft2->image_font = false;
557 }
558
559 // attempt to load fallback fonts:
560 fbfont = ft2;
561 for (i = 0; i < MAX_FONT_FALLBACKS; ++i)
562 {
563 if (!dpfnt->fallbacks[i][0])
564 break;
565 if (! (fb = Font_Alloc()) )
566 {
567 Con_Printf(CON_ERROR "Failed to allocate font for fallback %i of font %s\n", i, name);
568 break;
569 }
570
571 if (!Font_LoadFile(dpfnt->fallbacks[i], dpfnt->fallback_faces[i], &dpfnt->settings, fb))
572 {
573 if(!FS_FileExists(va(vabuf, sizeof(vabuf), "%s.tga", dpfnt->fallbacks[i])))
574 if(!FS_FileExists(va(vabuf, sizeof(vabuf), "%s.png", dpfnt->fallbacks[i])))
575 if(!FS_FileExists(va(vabuf, sizeof(vabuf), "%s.jpg", dpfnt->fallbacks[i])))
576 if(!FS_FileExists(va(vabuf, sizeof(vabuf), "%s.pcx", dpfnt->fallbacks[i])))
577 Con_Printf(CON_ERROR "Failed to load font %s for fallback %i of font %s\n", dpfnt->fallbacks[i], i, name);
578 Mem_Free(fb);
579 continue;
580 }
581 count = 0;
582 for (s = 0; s < MAX_FONT_SIZES && dpfnt->req_sizes[s] >= 0; ++s)
583 {
584 if (Font_LoadSize(fb, Font_VirtualToRealSize(dpfnt->req_sizes[s]), true))
585 ++count;
586 }
587 if (!count)
588 {
589 Con_Printf(CON_ERROR "Failed to allocate font for fallback %i of font %s\n", i, name);
590 Font_UnloadFont(fb);
591 Mem_Free(fb);
592 break;
593 }
594 // at least one size of the fallback font loaded successfully
595 // link it:
596 fbfont->next = fb;
597 fbfont = fb;
598 }
599
600 if (fbfont == ft2 && ft2->image_font)
601 {
602 // no fallbacks were loaded successfully:
603 dpfnt->ft2 = NULL;
604 Mem_Free(ft2);
605 return false;
606 }
607
608 count = 0;
609 for (s = 0; s < MAX_FONT_SIZES && dpfnt->req_sizes[s] >= 0; ++s)
610 {
611 if (Font_LoadSize(ft2, Font_VirtualToRealSize(dpfnt->req_sizes[s]), false))
612 ++count;
613 }
614 if (!count)
615 {
616 // loading failed for every requested size
617 Font_UnloadFont(ft2);
618 Mem_Free(ft2);
619 dpfnt->ft2 = NULL;
620 return false;
621 }
622
623 //Con_Printf("%i sizes loaded\n", count);
624 dpfnt->ft2 = ft2;
625 return true;
626}
char * va(char *buf, size_t buflen, const char *format,...)
Definition common.c:972
#define dp_strlcpy(dst, src, dsize)
Definition common.h:303
#define MAX_FONT_FALLBACKS
Definition draw.h:95
const char * FS_FileExists(const char *filename)
Look for a file in the packages and in the filesystem Returns its canonical name (same case as used i...
Definition fs.c:3693
static qbool Font_LoadFile(const char *name, int _face, ft2_settings_t *settings, ft2_font_t *font)
Definition ft2.c:628
ft2_font_t * Font_Alloc(void)
Definition ft2.c:467
float Font_VirtualToRealSize(float sz)
Definition ft2.c:496
static qbool Font_LoadSize(ft2_font_t *font, float size, qbool check_only)
Definition ft2.c:911
void Font_UnloadFont(ft2_font_t *font)
Definition ft2.c:1184
GLenum GLenum GLsizei count
Definition glquake.h:656
const GLchar * name
Definition glquake.h:601
int i
struct ft2_font_s * ft2
Definition draw.h:110
int req_face
Definition draw.h:106
float req_sizes[MAX_FONT_SIZES]
Definition draw.h:107
int fallback_faces[MAX_FONT_FALLBACKS]
Definition draw.h:109
ft2_settings_t settings
Definition draw.h:112
char fallbacks[MAX_FONT_FALLBACKS][MAX_QPATH]
Definition draw.h:108
qbool image_font
Definition ft2.h:48
struct ft2_font_s * next
Definition ft2.h:67
#define Mem_Free(mem)
Definition zone.h:96

References CON_ERROR, Con_Printf(), count, dp_strlcpy, dp_font_t::fallback_faces, dp_font_t::fallbacks, Font_Alloc(), Font_LoadFile(), Font_LoadSize(), Font_UnloadFont(), Font_VirtualToRealSize(), FS_FileExists(), dp_font_t::ft2, ft2_font_t::has_kerning, i, ft2_font_t::image_font, MAX_FONT_FALLBACKS, MAX_FONT_SIZES, Mem_Free, ft2_font_t::name, name, ft2_font_t::next, NULL, dp_font_t::req_face, dp_font_t::req_sizes, dp_font_t::settings, and va().

Referenced by LoadFont().

◆ Font_MapForIndex()

ft2_font_map_t * Font_MapForIndex ( ft2_font_t * font,
int index )

Definition at line 1052 of file ft2.c.

1053{
1055 return NULL;
1056 return font->font_maps[index];
1057}
GLuint index
Definition glquake.h:629

References ft2_font_t::font_maps, index, MAX_FONT_SIZES, and NULL.

Referenced by DrawQ_String_Scale(), DrawQ_TextWidth_UntilWidth_TrackColors_Scale(), Font_GetMapForChar(), and LoadFont().

◆ Font_OpenLibrary()

qbool Font_OpenLibrary ( void )

Definition at line 362 of file ft2.c.

363{
364#ifndef DP_FREETYPE_STATIC
365 const char* dllnames [] =
366 {
367#if defined(WIN32)
368 "libfreetype-6.dll",
369 "freetype6.dll",
370#elif defined(MACOSX)
371 "libfreetype.6.dylib",
372 "libfreetype.dylib",
373#else
374 "libfreetype.so.6",
375 "libfreetype.so",
376#endif
377 NULL
378 };
379#endif
380
382 return false;
383
384#ifndef DP_FREETYPE_STATIC
385 // Already loaded?
386 if (ft2_dll)
387 return true;
388
389 // Load the DLL
390 if (!Sys_LoadDependency (dllnames, &ft2_dll, ft2funcs))
391 return false;
392#endif
393 return true;
394}
static dllfunction_t ft2funcs[]
Definition ft2.c:138
qbool Sys_LoadDependency(const char **dllnames, dllhandle_t *handle, const dllfunction_t *fcts)
Definition sys_shared.c:131

References ft2_dll, ft2funcs, cvar_t::integer, NULL, r_font_disable_freetype, and Sys_LoadDependency().

Referenced by Font_Init(), Font_LoadFile(), and font_start().

◆ Font_SnapTo()

float Font_SnapTo ( float val,
float snapwidth )

Definition at line 514 of file ft2.c.

515{
516 return floor(val / snapwidth + 0.5f) * snapwidth;
517}
float floor(float f)

References floor().

Referenced by Font_GetKerningForMap(), Font_LoadMap(), Font_LoadSize(), and LoadFont().

◆ Font_UnloadFont()

void Font_UnloadFont ( ft2_font_t * font)

Definition at line 1184 of file ft2.c.

1185{
1186 int i;
1187
1188 // unload fallbacks
1189 if(font->next)
1190 Font_UnloadFont(font->next);
1191
1192 if (font->attachments && font->attachmentcount)
1193 {
1194 for (i = 0; i < (int)font->attachmentcount; ++i) {
1195 if (font->attachments[i].data)
1196 fontfilecache_Free(font->attachments[i].data);
1197 }
1198 Mem_Free(font->attachments);
1199 font->attachmentcount = 0;
1200 font->attachments = NULL;
1201 }
1202 for (i = 0; i < MAX_FONT_SIZES; ++i)
1203 {
1204 if (font->font_maps[i])
1205 {
1206 UnloadMapChain(font->font_maps[i]);
1207 font->font_maps[i] = NULL;
1208 }
1209 }
1210#ifndef DP_FREETYPE_STATIC
1211 if (ft2_dll)
1212#else
1214#endif
1215 {
1216 if (font->face)
1217 {
1218 qFT_Done_Face((FT_Face)font->face);
1219 font->face = NULL;
1220 }
1221 }
1222 if (font->data) {
1223 fontfilecache_Free(font->data);
1224 font->data = NULL;
1225 }
1226}
static int(ZEXPORT *qz_inflate)(z_stream *strm
static void UnloadMapChain(ft2_font_map_t *map)
Definition ft2.c:1150
static void fontfilecache_Free(const unsigned char *buf)
Definition ft2.c:301
(* qFT_Done_Face)(FT_Face face)
Definition ft2.c:92
size_t attachmentcount
Definition ft2.h:61
ft2_attachment_t * attachments
Definition ft2.h:62
const unsigned char * data
Definition ft2.h:52

References ft2_font_t::attachmentcount, ft2_font_t::attachments, ft2_font_t::data, ft2_font_t::face, ft2_font_t::font_maps, Font_UnloadFont(), fontfilecache_Free(), ft2_dll, i, int(), cvar_t::integer, MAX_FONT_SIZES, Mem_Free, ft2_font_t::next, NULL, qFT_Done_Face, r_font_disable_freetype, and UnloadMapChain().

Referenced by Font_LoadFile(), Font_LoadFont(), Font_LoadSize(), font_shutdown(), Font_UnloadFont(), and LoadFont().

◆ Font_VirtualToRealSize()

float Font_VirtualToRealSize ( float sz)

Definition at line 496 of file ft2.c.

497{
498 int vh;
499 //int vw;
500 int si;
501 float sn;
502 if(sz < 0)
503 return sz;
504 //vw = ((vid.width > 0) ? vid.width : vid_width.value);
505 vh = ((vid.mode.height > 0) ? vid.mode.height : vid_height.value);
506 // now try to scale to our actual size:
507 sn = sz * vh / vid_conheight.value;
508 si = (int)sn;
509 if ( sn - (float)si >= 0.5 )
510 ++si;
511 return si;
512}
cvar_t vid_height
Definition vid_shared.c:137

References viddef_mode_t::height, int(), viddef_t::mode, cvar_t::value, vid, vid_conheight, and vid_height.

Referenced by Font_LoadFont().

◆ FontMap_FindForChar()

ft2_font_map_t * FontMap_FindForChar ( ft2_font_map_t * start,
Uchar ch )

Definition at line 1911 of file ft2.c.

1912{
1913 ft2_font_map_t *map = start;
1914 while (map && map->start + FONT_CHARS_PER_MAP <= ch)
1915 map = map->next;
1916 if (map && map->start > ch)
1917 return NULL;
1918 alert_legacy_font_api("FontMap_FindForChar");
1919 return map;
1920}
static void alert_legacy_font_api(const char *name)
Definition ft2.c:1889

References alert_legacy_font_api(), FONT_CHARS_PER_MAP, and NULL.