diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index aed9510d67..d5e2d29d22 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -494,6 +494,7 @@ namespace Config model->height_medium = reader->GetSint32("height_medium", false); model->height_big = reader->GetSint32("height_big", false); model->enable_hinting = reader->GetBoolean("enable_hinting", true); + model->hinting_threshold = reader->GetSint32("hinting_threshold", false); } } @@ -514,6 +515,7 @@ namespace Config writer->WriteSint32("height_medium", model->height_medium); writer->WriteSint32("height_big", model->height_big); writer->WriteBoolean("enable_hinting", model->enable_hinting); + writer->WriteSint32("hinting_threshold", model->hinting_threshold); } static bool SetDefaults() diff --git a/src/openrct2/config/Config.h b/src/openrct2/config/Config.h index 1817316338..e253646680 100644 --- a/src/openrct2/config/Config.h +++ b/src/openrct2/config/Config.h @@ -192,6 +192,7 @@ typedef struct FontConfiguration sint32 height_medium; sint32 height_big; bool enable_hinting; + sint32 hinting_threshold; } FontConfiguration; enum SORT diff --git a/src/openrct2/drawing/font.h b/src/openrct2/drawing/font.h index 62f1b4b104..90d773e805 100644 --- a/src/openrct2/drawing/font.h +++ b/src/openrct2/drawing/font.h @@ -48,6 +48,7 @@ typedef struct TTFFontDescriptor { sint32 offset_x; sint32 offset_y; sint32 line_height; + sint32 hinting_threshold; TTF_Font * font; } TTFFontDescriptor; diff --git a/src/openrct2/drawing/string.c b/src/openrct2/drawing/string.c index dcd71f8f2f..17fc832d3f 100644 --- a/src/openrct2/drawing/string.c +++ b/src/openrct2/drawing/string.c @@ -805,7 +805,7 @@ static void ttf_draw_string_raw_ttf(rct_drawpixelinfo *dpi, const utf8 *text, te // Centre of the glyph: use full colour. *dst = colour; } - else if (*src > 60) + else if (*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/interface/Fonts.cpp b/src/openrct2/interface/Fonts.cpp index d83f1de5c4..5fc2d47475 100644 --- a/src/openrct2/interface/Fonts.cpp +++ b/src/openrct2/interface/Fonts.cpp @@ -25,39 +25,42 @@ #include "../localisation/language.h" #ifndef NO_TTF +uint8 const HINTING_THRESHOLD_LOW = 40; +uint8 const HINTING_THRESHOLD_MEDIUM = 60; + TTFFontSetDescriptor TTFFontMSGothic = { { - { "msgothic.ttc", "MS PGothic", 9, 1, 0, 15, nullptr }, - { "msgothic.ttc", "MS PGothic", 12, 1, 0, 17, nullptr }, - { "msgothic.ttc", "MS PGothic", 12, 1, 0, 17, nullptr }, - { "msgothic.ttc", "MS PGothic", 13, 1, 0, 20, nullptr }, + { "msgothic.ttc", "MS PGothic", 9, 1, 0, 15, HINTING_THRESHOLD_MEDIUM, nullptr }, + { "msgothic.ttc", "MS PGothic", 12, 1, 0, 17, HINTING_THRESHOLD_MEDIUM, nullptr }, + { "msgothic.ttc", "MS PGothic", 12, 1, 0, 17, HINTING_THRESHOLD_MEDIUM, nullptr }, + { "msgothic.ttc", "MS PGothic", 13, 1, 0, 20, HINTING_THRESHOLD_MEDIUM, nullptr }, } }; TTFFontSetDescriptor TTFFontMingLiu = { { - { "msjh.ttc", "JhengHei", 9, -1, -3, 6, nullptr }, - { "mingliu.ttc", "MingLiU", 11, 1, 1, 12, nullptr }, - { "mingliu.ttc", "MingLiU", 12, 1, 0, 12, nullptr }, - { "mingliu.ttc", "MingLiU", 13, 1, 0, 20, nullptr }, + { "msjh.ttc", "JhengHei", 9, -1, -3, 6, HINTING_THRESHOLD_MEDIUM, nullptr }, + { "mingliu.ttc", "MingLiU", 11, 1, 1, 12, HINTING_THRESHOLD_MEDIUM, nullptr }, + { "mingliu.ttc", "MingLiU", 12, 1, 0, 12, HINTING_THRESHOLD_MEDIUM, nullptr }, + { "mingliu.ttc", "MingLiU", 13, 1, 0, 20, HINTING_THRESHOLD_MEDIUM, nullptr }, } }; TTFFontSetDescriptor TTFFontSimSun = { { - { "msyh.ttc", "YaHei", 9, -1, -3, 6, nullptr }, - { "simsun.ttc", "SimSun", 11, 1, -1, 14, nullptr }, - { "simsun.ttc", "SimSun", 12, 1, -2, 14, nullptr }, - { "simsun.ttc", "SimSun", 13, 1, 0, 20, nullptr }, + { "msyh.ttc", "YaHei", 9, -1, -3, 6, HINTING_THRESHOLD_MEDIUM, nullptr }, + { "simsun.ttc", "SimSun", 11, 1, -1, 14, HINTING_THRESHOLD_MEDIUM, nullptr }, + { "simsun.ttc", "SimSun", 12, 1, -2, 14, HINTING_THRESHOLD_MEDIUM, nullptr }, + { "simsun.ttc", "SimSun", 13, 1, 0, 20, HINTING_THRESHOLD_MEDIUM, nullptr }, } }; TTFFontSetDescriptor TTFFontGulim = { { - { "gulim.ttc", "Gulim", 11, 1, 0, 15, nullptr }, - { "gulim.ttc", "Gulim", 12, 1, 0, 17, nullptr }, - { "gulim.ttc", "Gulim", 12, 1, 0, 17, nullptr }, - { "gulim.ttc", "Gulim", 13, 1, 0, 20, nullptr }, + { "gulim.ttc", "Gulim", 11, 1, 0, 15, HINTING_THRESHOLD_MEDIUM, nullptr }, + { "gulim.ttc", "Gulim", 12, 1, 0, 17, HINTING_THRESHOLD_MEDIUM, nullptr }, + { "gulim.ttc", "Gulim", 12, 1, 0, 17, HINTING_THRESHOLD_MEDIUM, nullptr }, + { "gulim.ttc", "Gulim", 13, 1, 0, 20, HINTING_THRESHOLD_MEDIUM, nullptr }, } }; TTFFontSetDescriptor TTFFontArial = { { - { "arial.ttf", "Arial", 8, 0, -1, 6, nullptr }, - { "arial.ttf", "Arial", 10, 0, -1, 12, nullptr }, - { "arial.ttf", "Arial", 11, 0, -1, 12, nullptr }, - { "arial.ttf", "Arial", 12, 0, -1, 20, nullptr }, + { "arial.ttf", "Arial", 8, 0, -1, 6, HINTING_THRESHOLD_LOW, nullptr }, + { "arial.ttf", "Arial", 10, 0, -1, 12, HINTING_THRESHOLD_LOW, nullptr }, + { "arial.ttf", "Arial", 11, 0, -1, 12, HINTING_THRESHOLD_LOW, nullptr }, + { "arial.ttf", "Arial", 12, 0, -1, 20, HINTING_THRESHOLD_LOW, nullptr }, } }; #endif // NO_TTF @@ -85,13 +88,13 @@ static bool LoadCustomConfigFont() { static TTFFontSetDescriptor TTFFontCustom = { { { gConfigFonts.file_name, gConfigFonts.font_name, gConfigFonts.size_tiny, gConfigFonts.x_offset, gConfigFonts.y_offset, - gConfigFonts.height_tiny, nullptr }, + gConfigFonts.height_tiny, gConfigFonts.hinting_threshold, nullptr }, { gConfigFonts.file_name, gConfigFonts.font_name, gConfigFonts.size_small, gConfigFonts.x_offset, gConfigFonts.y_offset, - gConfigFonts.height_small, nullptr }, + gConfigFonts.height_small, gConfigFonts.hinting_threshold, nullptr }, { gConfigFonts.file_name, gConfigFonts.font_name, gConfigFonts.size_medium, gConfigFonts.x_offset, - gConfigFonts.y_offset, gConfigFonts.height_medium, nullptr }, + gConfigFonts.y_offset, gConfigFonts.height_medium, gConfigFonts.hinting_threshold, nullptr }, { gConfigFonts.file_name, gConfigFonts.font_name, gConfigFonts.size_big, gConfigFonts.x_offset, gConfigFonts.y_offset, - gConfigFonts.height_big, nullptr }, + gConfigFonts.height_big, gConfigFonts.hinting_threshold, nullptr }, } }; ttf_dispose();