From 75b56c94c33cb443ed3eb544b8ab38bd04ed9b9c Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Tue, 21 Jun 2016 17:01:53 -0400 Subject: [PATCH] fixing up font stuff --- 4ed_rendering.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/4ed_rendering.cpp b/4ed_rendering.cpp index 98de5bbf..965a4e42 100644 --- a/4ed_rendering.cpp +++ b/4ed_rendering.cpp @@ -585,7 +585,9 @@ font_load_freetype(Partition *part, memset(pixels, 0, tex_width * tex_height * sizeof(u32)); // XXX: test if AUTOHINT looks better or not - const u32 ft_extra_flags = use_lcd_filter ? FT_LOAD_TARGET_LCD : 0; // FT_LOAD_FORCE_AUTOHINT; + // NOTE(allen): As of now FT_LOAD_FORCE_AUTOHINT looks much better for + // Liberation Mono which is one of the included 4coder fonts. + const u32 ft_extra_flags = use_lcd_filter ? FT_LOAD_TARGET_LCD : FT_LOAD_FORCE_AUTOHINT; for(int i = 0; i < NUM_GLYPHS; ++i){ if(FT_Load_Char(face, i, FT_LOAD_RENDER | ft_extra_flags) != 0) continue; @@ -632,11 +634,22 @@ font_load_freetype(Partition *part, int y = pen_y + j; if(use_lcd_filter){ +#if 1 u8 a = face->glyph->bitmap.buffer[j * pitch + i * 3 + 1]; u8 r = face->glyph->bitmap.buffer[j * pitch + i * 3 + 0]; u8 b = face->glyph->bitmap.buffer[j * pitch + i * 3 + 2]; pixels[y * tex_width + x] = (a << 24) | (b << 16) | (a << 8) | r; + +#else + + u8 r = face->glyph->bitmap.buffer[j * pitch + i * 3]; + u8 g = face->glyph->bitmap.buffer[j * pitch + i * 3 + 1]; + u8 b = face->glyph->bitmap.buffer[j * pitch + i * 3 + 2]; + u8 a = (u8)ROUND32((r + g + b) / 3.0f); + + pixels[y * tex_width + x] = (a << 24) | (r << 16) | (g << 8) | b; +#endif } else { pixels[y * tex_width + x] = face->glyph->bitmap.buffer[j * pitch + i] * 0x1010101; }