From ea034e85fa1edf4d37aab556e3c89ccf5957794b Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Fri, 22 Sep 2017 12:42:22 +0200 Subject: [PATCH] Simulate font hinting when using TrueType fonts for better legibility. --- src/openrct2/drawing/string.c | 14 +++++++++++++- src/openrct2/drawing/ttf.c | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/openrct2/drawing/string.c b/src/openrct2/drawing/string.c index 9328036338..e4741d0e8c 100644 --- a/src/openrct2/drawing/string.c +++ b/src/openrct2/drawing/string.c @@ -798,7 +798,19 @@ static void ttf_draw_string_raw_ttf(rct_drawpixelinfo *dpi, const utf8 *text, te if (info->flags & TEXT_DRAW_FLAG_INSET) { *(dst + width + dstScanSkip + 1) = info->palette[3]; } - *dst = colour; + + if (*src > 180) + { + // Centre of the glyph: use full colour. + *dst = colour; + } + else if (*src > 70) + { + // Simulate font hinting by shading the background colour instead. + // uint8 hinting = floor(*src / 12); + // *dst = *dst - (*dst % 12) + hinting; + *dst = *dst + 2; + } } src++; dst++; diff --git a/src/openrct2/drawing/ttf.c b/src/openrct2/drawing/ttf.c index a31bb3b6a7..8d3b0b983a 100644 --- a/src/openrct2/drawing/ttf.c +++ b/src/openrct2/drawing/ttf.c @@ -276,7 +276,7 @@ static bool ttf_get_size(TTF_Font * font, const utf8 * text, sint32 * outWidth, static TTFSurface * ttf_render(TTF_Font * font, const utf8 * text) { - return TTF_RenderUTF8_Solid(font, text, 0x000000FF); + return TTF_RenderUTF8_Shaded(font, text, 0x000000FF, 0x000000FF); } void ttf_free_surface(TTFSurface * surface)