[Change] Seems to make fonts look even better!

This commit is contained in:
Allanis 2014-03-08 01:44:03 +00:00
parent 8471f53cc2
commit 87ef9e5daa

View File

@ -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); expanded_data = (GLubyte*)malloc(sizeof(GLubyte)*2*w*h + 1);
for(j = 0; j < h; j++) { for(j = 0; j < h; j++) {
for(i = 0; i < w; i++) { for(i = 0; i < w; i++) {
expanded_data[2*(i+j*w)] = expanded_data[2*(i+j*w)+1] = expanded_data[2*(i+j*w)] = 0xcf; /* Set LUMINANCE to constant. */
(i >= bitmap.width || j >= bitmap.rows) ? expanded_data[2*(i+j*w)+1] = /* Alpha varies with bitmap. */
0 : bitmap.buffer[i + bitmap.width*j]; ((i >= bitmap.width) || (j >= bitmap.rows)) ?
0 : bitmap.buffer[i + bitmap.width*j];
} }
} }
/* Create the GL texture. */ /* 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. * @param h Height of the font to generate.
*/ */
void gl_fontInit(glFont* font, const char* fname, const unsigned int h) { void gl_fontInit(glFont* font, const char* fname, const unsigned int h) {
FT_Library library;
FT_Face face;
uint32_t bufsize; uint32_t bufsize;
int i; int i;
@ -526,22 +529,22 @@ void gl_fontInit(glFont* font, const char* fname, const unsigned int h) {
} }
/* Create a FreeType font library. */ /* Create a FreeType font library. */
FT_Library library;
if(FT_Init_FreeType(&library)) { if(FT_Init_FreeType(&library)) {
WARN("FT_Init_FreeType failed"); WARN("FT_Init_FreeType failed");
} }
/* Objects that freetype uses to store font info. */ /* Objects that freetype uses to store font info. */
FT_Face face;
if(FT_New_Memory_Face(library, buf, bufsize, 0, &face)) if(FT_New_Memory_Face(library, buf, bufsize, 0, &face))
WARN("FT_New_Memory_Face failed loading library from %s", fname); 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. */ /* FreeType is pretty nice and measures using 1/64 of a pixel, therfore expand. */
FT_Set_Char_Size(face, if(FT_IS_SCALABLE(face))
0, /* Same as width. */ if(FT_Set_Char_Size(face,
h << 6, /* In 1/64th of a pixel. */ 0, /* Same as width. */
96, h << 6, /* In 1/64th of a pixel. */
96); 96,
96))
WARN("FT_Set_Char_Size failed.");
/* Selected the character map. */ /* Selected the character map. */
if(FT_Select_Charmap(face, FT_ENCODING_UNICODE)) if(FT_Select_Charmap(face, FT_ENCODING_UNICODE))