From 82ef08a01ecfc469a955164e45bfa1e1f5035c10 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Fri, 13 Jul 2018 12:18:52 +0200 Subject: [PATCH] win32: enable antialisaing with TTF fonts --- src/text.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/text.c b/src/text.c index 9603315b..f6b71a5d 100644 --- a/src/text.c +++ b/src/text.c @@ -607,6 +607,7 @@ byte *Render_text_Win32(const char *str, int font_number, int size, int antialia byte * pixels = NULL; byte * new_brush = NULL; int i; + int x, y; HFONT font; const char * font_name; @@ -635,7 +636,7 @@ byte *Render_text_Win32(const char *str, int font_number, int size, int antialia bi->bmiHeader.biWidth = (s.cx + 3) & ~3; bi->bmiHeader.biHeight = -s.cy; bi->bmiHeader.biPlanes = 1; - bi->bmiHeader.biBitCount = 8; + bi->bmiHeader.biBitCount = antialias ? 32 : 8; // the GDI does Antialiasing only on TrueColor DIB bi->bmiHeader.biCompression = BI_RGB; for (i = 0; i < 256; i++) { @@ -664,16 +665,15 @@ byte *Render_text_Win32(const char *str, int font_number, int size, int antialia new_brush = (byte *)malloc(s.cx*s.cy); if (antialias) { - int y; - // TODO complete the antialiasing processing for (y = 0; y < s.cy; y++) { - memcpy(new_brush + y * s.cx, pixels + y * bi->bmiHeader.biWidth, s.cx); + // get the value from the 1st color component. + for (x = 0; x < s.cx; x++) + new_brush[x + y * s.cx] = pixels[(x + y * bi->bmiHeader.biWidth) * 4]; } } else { - int x, y; for (y = 0; y < s.cy; y++) { for (x = 0; x < s.cx; x++)