From 87ef9e5daaf69c8740706c31b6f251efa2825ebe Mon Sep 17 00:00:00 2001 From: Allanis Date: Sat, 8 Mar 2014 01:44:03 +0000 Subject: [PATCH] [Change] Seems to make fonts look even better! --- src/font.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/font.c b/src/font.c index de4fc0b..b1eb38f 100644 --- a/src/font.c +++ b/src/font.c @@ -451,9 +451,10 @@ static void glFontMakeDList(FT_Face face, char ch, GLuint list_base, expanded_data = (GLubyte*)malloc(sizeof(GLubyte)*2*w*h + 1); for(j = 0; j < h; j++) { for(i = 0; i < w; i++) { - expanded_data[2*(i+j*w)] = expanded_data[2*(i+j*w)+1] = - (i >= bitmap.width || j >= bitmap.rows) ? - 0 : bitmap.buffer[i + bitmap.width*j]; + expanded_data[2*(i+j*w)] = 0xcf; /* Set LUMINANCE to constant. */ + expanded_data[2*(i+j*w)+1] = /* Alpha varies with bitmap. */ + ((i >= bitmap.width) || (j >= bitmap.rows)) ? + 0 : bitmap.buffer[i + bitmap.width*j]; } } /* Create the GL texture. */ @@ -509,6 +510,8 @@ static void glFontMakeDList(FT_Face face, char ch, GLuint list_base, * @param h Height of the font to generate. */ void gl_fontInit(glFont* font, const char* fname, const unsigned int h) { + FT_Library library; + FT_Face face; uint32_t bufsize; int i; @@ -526,22 +529,22 @@ void gl_fontInit(glFont* font, const char* fname, const unsigned int h) { } /* Create a FreeType font library. */ - FT_Library library; if(FT_Init_FreeType(&library)) { WARN("FT_Init_FreeType failed"); } /* Objects that freetype uses to store font info. */ - FT_Face face; 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, - 0, /* Same as width. */ - h << 6, /* In 1/64th of a pixel. */ - 96, - 96); + if(FT_IS_SCALABLE(face)) + if(FT_Set_Char_Size(face, + 0, /* Same as width. */ + h << 6, /* In 1/64th of a pixel. */ + 96, + 96)) + WARN("FT_Set_Char_Size failed."); /* Selected the character map. */ if(FT_Select_Charmap(face, FT_ENCODING_UNICODE))