win32: enable antialisaing with TTF fonts

This commit is contained in:
Thomas Bernard 2018-07-13 12:18:52 +02:00
parent 05d6a4b3dd
commit 82ef08a01e

View File

@ -607,6 +607,7 @@ byte *Render_text_Win32(const char *str, int font_number, int size, int antialia
byte * pixels = NULL; byte * pixels = NULL;
byte * new_brush = NULL; byte * new_brush = NULL;
int i; int i;
int x, y;
HFONT font; HFONT font;
const char * font_name; 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.biWidth = (s.cx + 3) & ~3;
bi->bmiHeader.biHeight = -s.cy; bi->bmiHeader.biHeight = -s.cy;
bi->bmiHeader.biPlanes = 1; 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; bi->bmiHeader.biCompression = BI_RGB;
for (i = 0; i < 256; i++) { 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); new_brush = (byte *)malloc(s.cx*s.cy);
if (antialias) if (antialias)
{ {
int y;
// TODO complete the antialiasing processing
for (y = 0; y < s.cy; y++) 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 else
{ {
int x, y;
for (y = 0; y < s.cy; y++) for (y = 0; y < s.cy; y++)
{ {
for (x = 0; x < s.cx; x++) for (x = 0; x < s.cx; x++)