diff --git a/src/openrct2/drawing/ScrollingText.cpp b/src/openrct2/drawing/ScrollingText.cpp index 1efbe06247..03a3bcd484 100644 --- a/src/openrct2/drawing/ScrollingText.cpp +++ b/src/openrct2/drawing/ScrollingText.cpp @@ -1575,6 +1575,8 @@ static void scrolling_text_set_bitmap_for_ttf(utf8 *text, sint32 scroll, uint8 * sint32 min_vpos = -fontDesc->offset_y; sint32 max_vpos = std::min(surface->h - 2, min_vpos + 7); + bool use_hinting = gConfigFonts.enable_hinting && fontDesc->hinting_threshold > 0; + for (sint32 x = 0; ; x++) { if (x >= width) @@ -1593,7 +1595,7 @@ static void scrolling_text_set_bitmap_for_ttf(utf8 *text, sint32 scroll, uint8 * for (sint32 y = min_vpos; y < max_vpos; y++) { - if (src[y * pitch + x] > 92 || (src[y * pitch + x] != 0 && !gConfigFonts.enable_hinting)) + if (src[y * pitch + x] > 92 || (src[y * pitch + x] != 0 && !use_hinting)) *dst = colour; // Jump to next row diff --git a/src/openrct2/drawing/String.cpp b/src/openrct2/drawing/String.cpp index 04c68729bf..42465a23a9 100644 --- a/src/openrct2/drawing/String.cpp +++ b/src/openrct2/drawing/String.cpp @@ -541,6 +541,7 @@ static void ttf_draw_string_raw_ttf(rct_drawpixelinfo *dpi, const utf8 *text, te { dst = dst_orig; src = src_orig; + bool use_hinting = gConfigFonts.enable_hinting && fontDesc->hinting_threshold > 0; for (sint32 yy = 0; yy < height; yy++) { for (sint32 xx = 0; xx < width; xx++) { if (*src != 0) { @@ -548,12 +549,12 @@ static void ttf_draw_string_raw_ttf(rct_drawpixelinfo *dpi, const utf8 *text, te *(dst + width + dstScanSkip + 1) = info->palette[3]; } - if (*src > 180 || !gConfigFonts.enable_hinting) + if (*src > 180 || !use_hinting) { // Centre of the glyph: use full colour. *dst = colour; } - else if (*src > fontDesc->hinting_threshold) + else if (use_hinting && *src > fontDesc->hinting_threshold) { // Simulate font hinting by shading the background colour instead. if (info->flags & TEXT_DRAW_FLAG_OUTLINE) diff --git a/src/openrct2/drawing/TTF.cpp b/src/openrct2/drawing/TTF.cpp index 8ec974e1b3..b4521eff6c 100644 --- a/src/openrct2/drawing/TTF.cpp +++ b/src/openrct2/drawing/TTF.cpp @@ -165,7 +165,8 @@ void ttf_toggle_hinting() for (sint32 i = 0; i < FONT_SIZE_COUNT; i++) { TTFFontDescriptor *fontDesc = &(gCurrentTTFFontSet->size[i]); - TTF_SetFontHinting(fontDesc->font, gConfigFonts.enable_hinting ? 1 : 0); + bool use_hinting = gConfigFonts.enable_hinting && fontDesc->hinting_threshold; + TTF_SetFontHinting(fontDesc->font, use_hinting ? 1 : 0); } if (_ttfSurfaceCacheCount) @@ -299,7 +300,7 @@ static bool ttf_get_size(TTF_Font * font, const utf8 * text, sint32 * outWidth, static TTFSurface * ttf_render(TTF_Font * font, const utf8 * text) { - if (gConfigFonts.enable_hinting) + if (TTF_GetFontHinting(font) != 0) { return TTF_RenderUTF8_Shaded(font, text, 0x000000FF, 0x000000FF); } diff --git a/src/openrct2/drawing/TTF.h b/src/openrct2/drawing/TTF.h index 3010a65de1..68e1597e33 100644 --- a/src/openrct2/drawing/TTF.h +++ b/src/openrct2/drawing/TTF.h @@ -46,6 +46,7 @@ TTFSurface * TTF_RenderUTF8_Solid(TTF_Font *font, const char *text, uint32 colou TTFSurface * TTF_RenderUTF8_Shaded(TTF_Font *font, const char *text, uint32 fg, uint32 bg); void TTF_CloseFont(TTF_Font *font); void TTF_SetFontHinting(TTF_Font* font, int hinting); +int TTF_GetFontHinting(const TTF_Font* font); void TTF_Quit(void); #endif // NO_TTF diff --git a/src/openrct2/drawing/TTFSDLPort.cpp b/src/openrct2/drawing/TTFSDLPort.cpp index 60ddf0dfde..58f285de4a 100644 --- a/src/openrct2/drawing/TTFSDLPort.cpp +++ b/src/openrct2/drawing/TTFSDLPort.cpp @@ -1401,6 +1401,17 @@ void TTF_SetFontHinting(TTF_Font* font, int hinting) Flush_Cache(font); } +int TTF_GetFontHinting(const TTF_Font* font) +{ + if (font->hinting == FT_LOAD_TARGET_LIGHT) + return TTF_HINTING_LIGHT; + else if (font->hinting == FT_LOAD_TARGET_MONO) + return TTF_HINTING_MONO; + else if (font->hinting == FT_LOAD_NO_HINTING) + return TTF_HINTING_NONE; + return 0; +} + void TTF_Quit(void) { if (TTF_initialized) { diff --git a/src/openrct2/interface/Fonts.cpp b/src/openrct2/interface/Fonts.cpp index fc7f8e601b..a2b8056bd3 100644 --- a/src/openrct2/interface/Fonts.cpp +++ b/src/openrct2/interface/Fonts.cpp @@ -26,6 +26,7 @@ #include "../localisation/Language.h" #ifndef NO_TTF +uint8 const HINTING_DISABLED = 0; uint8 const HINTING_THRESHOLD_LOW = 40; uint8 const HINTING_THRESHOLD_MEDIUM = 60; @@ -73,14 +74,14 @@ TTFFontSetDescriptor TTFFontLiHeiPro = { { } }; TTFFontSetDescriptor TTFFontGulim = { { - { "gulim.ttc", "Gulim", 10, 1, 0, 10, HINTING_THRESHOLD_MEDIUM, nullptr }, + { "gulim.ttc", "Gulim", 10, 1, 0, 10, HINTING_DISABLED, nullptr }, { "gulim.ttc", "Gulim", 12, 1, 0, 15, HINTING_THRESHOLD_MEDIUM, nullptr }, { "gulim.ttc", "Gulim", 12, 1, 0, 15, HINTING_THRESHOLD_MEDIUM, nullptr }, { "gulim.ttc", "Gulim", 13, 1, 0, 16, HINTING_THRESHOLD_MEDIUM, nullptr }, } }; TTFFontSetDescriptor TTFFontNanum = { { - { "NanumGothic.ttc", "Nanum Gothic", 10, 1, 0, 10, HINTING_THRESHOLD_LOW, nullptr }, + { "NanumGothic.ttc", "Nanum Gothic", 10, 1, 0, 10, HINTING_DISABLED, nullptr }, { "NanumGothic.ttc", "Nanum Gothic", 12, 1, 0, 15, HINTING_THRESHOLD_LOW, nullptr }, { "NanumGothic.ttc", "Nanum Gothic", 12, 1, 0, 15, HINTING_THRESHOLD_LOW, nullptr }, { "NanumGothic.ttc", "Nanum Gothic", 13, 1, 0, 16, HINTING_THRESHOLD_LOW, nullptr },