[Change] Load fonts from project directory, throw it in data pack.
This commit is contained in:
parent
376eedc616
commit
f90a2a273c
@ -29,7 +29,7 @@ LDGL = -lGL
|
||||
LDFLAGS = -lm $(LDLUA) $(LDSDL) $(LDXML) $(LDTTF) $(LDGL)
|
||||
|
||||
DATA = data
|
||||
DATAFILES = $(shell find ../scripts/ai/ ../gfx/ ../dat/ -name '*.lua' -o -name '*.png' -o -name '*.xml')
|
||||
DATAFILES = $(shell find ../scripts/ ../gfx/ ../dat/ -name '*.lua' -o -name '*.png' -o -name '*.xml' -o -name '*.ttf')
|
||||
|
||||
%.o: %.c %.h
|
||||
@gcc -c $(CFLAGS) -o $@ $<
|
||||
|
@ -1,5 +1,6 @@
|
||||
function follow()
|
||||
face(1,1)
|
||||
accel(1)
|
||||
end
|
||||
|
||||
function goto()
|
||||
|
@ -192,7 +192,7 @@ int main(int argc, char** argv) {
|
||||
if(ai_init())
|
||||
WARN("Error initializing AI");
|
||||
|
||||
gl_fontInit(NULL, "../gfx/fonts/FreeSans.ttf", 16);
|
||||
gl_fontInit(NULL, NULL, 16);
|
||||
|
||||
// Data loading.
|
||||
ships_load();
|
||||
|
10
src/opengl.c
10
src/opengl.c
@ -15,6 +15,8 @@
|
||||
#define SCREEN_W gl_screen.w
|
||||
#define SCREEN_H gl_screen.h
|
||||
|
||||
#define FONT_DEF "../gfx/fonts/FreeSans.ttf"
|
||||
|
||||
// The screen info, gives data of current opengl settings.
|
||||
gl_info gl_screen;
|
||||
|
||||
@ -423,6 +425,9 @@ static void gl_fontMakeDList(FT_Face face, char ch, GLuint list_base, GLuint* te
|
||||
void gl_fontInit(gl_font* font, const char* fname, unsigned int h) {
|
||||
if(font == NULL) font = &gl_defFont;
|
||||
|
||||
uint32_t bufsize;
|
||||
FT_Byte* buf = pack_readfile(DATA, (fname) ? fname : FONT_DEF, &bufsize);
|
||||
|
||||
font->textures = malloc(sizeof(GLuint)*128);
|
||||
font->h = h;
|
||||
|
||||
@ -434,8 +439,8 @@ void gl_fontInit(gl_font* font, const char* fname, unsigned int h) {
|
||||
|
||||
// Objects that freetype uses to store font info.
|
||||
FT_Face face;
|
||||
if(FT_New_Face(library, fname, 0, &face))
|
||||
WARN("FT_New_Face failed loading library from %s", fname);
|
||||
if(FT_New_Memory_Face(library, buf, bufsize, 0, &face))
|
||||
WARN("FT_New_Memory_Face failed loading library from %s", fname);
|
||||
|
||||
// FreeType is pretty nice and measures using 1/64 of a pixel, therfore expand.
|
||||
FT_Set_Char_Size(face, h << 6, h << 6, 96, 96);
|
||||
@ -452,6 +457,7 @@ void gl_fontInit(gl_font* font, const char* fname, unsigned int h) {
|
||||
// We can now free the face and library.
|
||||
FT_Done_Face(face);
|
||||
FT_Done_FreeType(library);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void gl_freeFont(gl_font* font) {
|
||||
|
Loading…
Reference in New Issue
Block a user