From 6439e96f8c8945c6550ca6ca14715dda2dfca2bc Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 6 Jul 2011 10:16:15 +0100 Subject: [PATCH] Add LINK_TO_FREETYPE2 In Debian we want library dependencies to work in the conventional way, since many tools expect that and use it to generate package dependencies. Origin: vendor, Debian --- ft2.c | 42 ++++++++++++++++++++++++++++++++++++++++-- makefile | 5 +++++ makefile.inc | 2 ++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/ft2.c b/ft2.c index f55d0e22..98466735 100644 --- a/ft2.c +++ b/ft2.c @@ -4,7 +4,14 @@ #include "quakedef.h" #include "ft2.h" -#include "ft2_defs.h" + +#ifdef LINK_TO_FREETYPE2 +# include +# include FT_FREETYPE_H +#else +# include "ft2_defs.h" +#endif + #include "ft2_fontdefs.h" #include "image.h" @@ -42,6 +49,26 @@ cvar_t r_font_compress = {CVAR_SAVE, "r_font_compress", "0", "use texture compre cvar_t r_font_nonpoweroftwo = {CVAR_SAVE, "r_font_nonpoweroftwo", "1", "use nonpoweroftwo textures for font (saves memory, potentially slower)"}; cvar_t developer_font = {CVAR_SAVE, "developer_font", "0", "prints debug messages about fonts"}; +#ifdef LINK_TO_FREETYPE2 + +#define qFT_Init_FreeType FT_Init_FreeType +#define qFT_Done_FreeType FT_Done_FreeType +#define qFT_New_Memory_Face FT_New_Memory_Face +#define qFT_Done_Face FT_Done_Face +#define qFT_Select_Size FT_Select_Size +#define qFT_Request_Size FT_Request_Size +#define qFT_Request_Size FT_Request_Size +#define qFT_Set_Char_Size FT_Set_Char_Size +#define qFT_Set_Pixel_Sizes FT_Set_Pixel_Sizes +#define qFT_Load_Glyph FT_Load_Glyph +#define qFT_Load_Char FT_Load_Char +#define qFT_Get_Char_Index FT_Get_Char_Index +#define qFT_Render_Glyph FT_Render_Glyph +#define qFT_Get_Kerning FT_Get_Kerning +#define qFT_Attach_Stream FT_Attach_Stream + +#else + /* ================================================================================ Function definitions. Taken from the freetype2 headers. @@ -136,6 +163,8 @@ static dllfunction_t ft2funcs[] = /// Handle for FreeType2 DLL static dllhandle_t ft2_dll = NULL; +#endif /* PREFER_PRELOAD */ + /// Memory pool for fonts static mempool_t *font_mempool= NULL; @@ -240,12 +269,14 @@ void Font_CloseLibrary (void) fontfilecache_FreeAll(); if (font_mempool) Mem_FreePool(&font_mempool); - if (font_ft2lib && qFT_Done_FreeType) + if (font_ft2lib) { qFT_Done_FreeType(font_ft2lib); font_ft2lib = NULL; } +#ifndef LINK_TO_FREETYPE2 Sys_UnloadLibrary (&ft2_dll); +#endif pp.buf = NULL; } @@ -258,6 +289,7 @@ Try to load the FreeType2 DLL */ qboolean Font_OpenLibrary (void) { +#ifndef LINK_TO_FREETYPE2 const char* dllnames [] = { #if defined(WIN32) @@ -283,6 +315,7 @@ qboolean Font_OpenLibrary (void) // Load the DLL if (!Sys_LoadLibrary (dllnames, &ft2_dll, ft2funcs)) return false; +#endif return true; } @@ -358,8 +391,11 @@ Implementation of a more or less lazy font loading and rendering code. ft2_font_t *Font_Alloc(void) { +#ifndef LINK_TO_FREETYPE2 if (!ft2_dll) return NULL; +#endif + return (ft2_font_t *)Mem_Alloc(font_mempool, sizeof(ft2_font_t)); } @@ -1065,7 +1101,9 @@ void Font_UnloadFont(ft2_font_t *font) font->font_maps[i] = NULL; } } +#ifndef LINK_TO_FREETYPE2 if (ft2_dll) +#endif { if (font->face) { diff --git a/makefile b/makefile index fa64b029..967c4873 100644 --- a/makefile +++ b/makefile @@ -307,6 +307,11 @@ CFLAGS_CURL=-DLINK_TO_CURL `pkg-config --cflags libcurl` LIB_CURL=`pkg-config --libs libcurl` endif +ifdef LINK_TO_FREETYPE2 +CFLAGS_FREETYPE2=-DLINK_TO_FREETYPE2 `pkg-config --cflags freetype2` +LIB_FREETYPE2=`pkg-config --libs freetype2` +endif + ifdef LINK_TO_LIBJPEG CFLAGS_LIBJPEG=-DLINK_TO_LIBJPEG LIB_JPEG=-ljpeg diff --git a/makefile.inc b/makefile.inc index 814eb6a3..7b8023f7 100644 --- a/makefile.inc +++ b/makefile.inc @@ -193,6 +193,7 @@ CFLAGS_COMMON=\ $(CFLAGS_FS) \ $(CFLAGS_WARNINGS) \ $(CFLAGS_CURL) \ + $(CFLAGS_FREETYPE2) \ $(CFLAGS_LIBJPEG) \ $(CFLAGS_LIBVORBIS) \ $(CFLAGS_PNG) \ @@ -234,6 +235,7 @@ OBJ_GLX= builddate.c sys_linux.o vid_glx.o thread_pthread.o keysym2ucs.o $(OBJ_S LDFLAGS_UNIXCOMMON=\ -lm \ $(LIB_CURL) \ + $(LIB_FREETYPE2) \ $(LIB_ODE) \ $(LIB_JPEG) \ $(LIB_PNG) \ -- 2.39.2