mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-21 05:53:02 +01:00
Make the hinting threshold configurable per font.
This addresses the issue that tofu would not show up in Arial on macOS if the threshold was set to 60. It being the fallback font, it is important that they do, which requires lowering to at most 43. However, it is even more important that the threshold is left at 60 for kanji in e.g. Japanese to render properly. Hence, for the moment, Arial is the only font now using a hinting threshold of 40, for now.
This commit is contained in:
committed by
Marijn van der Werf
parent
899c859948
commit
551fdabc7f
@@ -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()
|
||||
|
||||
@@ -192,6 +192,7 @@ typedef struct FontConfiguration
|
||||
sint32 height_medium;
|
||||
sint32 height_big;
|
||||
bool enable_hinting;
|
||||
sint32 hinting_threshold;
|
||||
} FontConfiguration;
|
||||
|
||||
enum SORT
|
||||
|
||||
@@ -48,6 +48,7 @@ typedef struct TTFFontDescriptor {
|
||||
sint32 offset_x;
|
||||
sint32 offset_y;
|
||||
sint32 line_height;
|
||||
sint32 hinting_threshold;
|
||||
TTF_Font * font;
|
||||
} TTFFontDescriptor;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user