[Change] Seems to make fonts look even better!
This commit is contained in:
parent
8471f53cc2
commit
87ef9e5daa
23
src/font.c
23
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))
|
||||
|
Loading…
Reference in New Issue
Block a user