Improve TrueType font appearance for scrolling texts.

This makes the scrolling text drawing code respect banner font y-offset definitions.
Font definitions are also adjusted accordingly. Definitions set prior were ignored
by the game thus far, hence the need for adjustment.
This commit is contained in:
Aaron van Geffen 2018-02-09 15:57:32 +01:00
parent a5da22d5c7
commit 1809eec079
2 changed files with 34 additions and 29 deletions

View File

@ -1501,7 +1501,7 @@ static void scrolling_text_set_bitmap_for_sprite(utf8 *text, sint32 scroll, uint
sint32 characterWidth = font_sprite_get_codepoint_width(FONT_SPRITE_BASE_TINY, codepoint);
uint8 *characterBitmap = font_sprite_get_codepoint_bitmap(codepoint);
for (; characterWidth != 0; characterWidth--, characterBitmap++) {
// Skip any none displayed columns
// Skip any non-displayed columns
if (scroll != 0) {
scroll--;
continue;
@ -1566,41 +1566,46 @@ static void scrolling_text_set_bitmap_for_ttf(utf8 *text, sint32 scroll, uint8 *
sint32 pitch = surface->pitch;
sint32 width = surface->w;
sint32 height = surface->h;
auto src = (const uint8 *)surface->pixels;
// Offset
height -= 3;
src += 3 * pitch;
height = std::min(height, 8);
// Pitch offset
src += 2 * pitch;
sint32 x = 0;
while (true) {
// Skip any none displayed columns
if (scroll == 0) {
// Line height offset
sint32 min_vpos = -fontDesc->offset_y;
sint32 max_vpos = std::min(surface->h - 2, min_vpos + 7);
for (sint32 x = 0; ; x++)
{
if (x >= width)
x = 0;
// Skip any non-displayed columns
if (scroll == 0)
{
sint16 scrollPosition = *scrollPositionOffsets;
if (scrollPosition == -1) return;
if (scrollPosition > -1) {
if (scrollPosition == -1)
return;
if (scrollPosition > -1)
{
uint8 *dst = &bitmap[scrollPosition];
for (sint32 y = 0; y < height; y++)
for (sint32 y = min_vpos; y < max_vpos; y++)
{
if (src[y * pitch + x] > 92 || (src[y * pitch + x] != 0 && !gConfigFonts.enable_hinting))
{
*dst = colour;
}
// Jump to next row
dst += 64;
}
}
scrollPositionOffsets++;
} else {
}
else
{
scroll--;
}
x++;
if (x >= width) x = 0;
}
#endif // NO_TTF
}

View File

@ -31,70 +31,70 @@ uint8 const HINTING_THRESHOLD_MEDIUM = 60;
// clang-format off
TTFFontSetDescriptor TTFFontMSGothic = { {
{ "msgothic.ttc", "MS PGothic", 9, 1, -1, 10, HINTING_THRESHOLD_MEDIUM, nullptr },
{ "msgothic.ttc", "MS PGothic", 9, 1, 1, 9, HINTING_THRESHOLD_MEDIUM, nullptr },
{ "msgothic.ttc", "MS PGothic", 12, 1, 0, 14, HINTING_THRESHOLD_MEDIUM, nullptr },
{ "msgothic.ttc", "MS PGothic", 12, 1, 0, 14, HINTING_THRESHOLD_MEDIUM, nullptr },
{ "msgothic.ttc", "MS PGothic", 13, 1, 0, 15, HINTING_THRESHOLD_MEDIUM, nullptr },
} };
TTFFontSetDescriptor TTFFontHiragano = { {
{ u8"ヒラギノ丸ゴ ProN W4.ttc", "Hiragino Maru Gothic ProN", 8, 1, -1, 9, HINTING_THRESHOLD_MEDIUM, nullptr },
{ u8"ヒラギノ丸ゴ ProN W4.ttc", "Hiragino Maru Gothic ProN", 9, 1, 1, 9, HINTING_THRESHOLD_MEDIUM, nullptr },
{ u8"ヒラギノ丸ゴ ProN W4.ttc", "Hiragino Maru Gothic ProN", 11, 1, 0, 13, HINTING_THRESHOLD_MEDIUM, nullptr },
{ u8"ヒラギノ丸ゴ ProN W4.ttc", "Hiragino Maru Gothic ProN", 11, 1, 0, 13, HINTING_THRESHOLD_MEDIUM, nullptr },
{ u8"ヒラギノ丸ゴ ProN W4.ttc", "Hiragino Maru Gothic ProN", 12, 1, 0, 14, HINTING_THRESHOLD_MEDIUM, nullptr },
} };
TTFFontSetDescriptor TTFFontMingLiu = { {
{ "msjh.ttc", "JhengHei", 9, -1, -3, 6, HINTING_THRESHOLD_MEDIUM, nullptr },
{ "msjh.ttc", "JhengHei", 9, -1, -1, 9, HINTING_THRESHOLD_MEDIUM, nullptr },
{ "mingliu.ttc", "MingLiU", 11, 1, 1, 14, HINTING_THRESHOLD_MEDIUM, nullptr },
{ "mingliu.ttc", "MingLiU", 12, 1, 0, 15, HINTING_THRESHOLD_MEDIUM, nullptr },
{ "mingliu.ttc", "MingLiU", 13, 1, 0, 15, HINTING_THRESHOLD_MEDIUM, nullptr },
} };
TTFFontSetDescriptor TTFFontHeiti = { {
{ u8"华文黑体.ttf", "STHeiti", 9, -1, -3, 6, HINTING_THRESHOLD_MEDIUM, nullptr },
{ u8"华文黑体.ttf", "STHeiti", 9, -1, -1, 9, HINTING_THRESHOLD_MEDIUM, nullptr },
{ u8"华文黑体.ttf", "STHeiti", 11, 1, 1, 14, HINTING_THRESHOLD_MEDIUM, nullptr },
{ u8"华文黑体.ttf", "STHeiti", 12, 1, 0, 15, HINTING_THRESHOLD_MEDIUM, nullptr },
{ u8"华文黑体.ttf", "STHeiti", 13, 1, 0, 15, HINTING_THRESHOLD_MEDIUM, nullptr },
} };
TTFFontSetDescriptor TTFFontSimSun = { {
{ "msyh.ttc", "YaHei", 9, -1, -3, 6, HINTING_THRESHOLD_MEDIUM, nullptr },
{ "msyh.ttc", "YaHei", 9, -1, -1, 9, HINTING_THRESHOLD_MEDIUM, nullptr },
{ "simsun.ttc", "SimSun", 11, 1, -1, 14, HINTING_THRESHOLD_MEDIUM, nullptr },
{ "simsun.ttc", "SimSun", 12, 1, -2, 15, HINTING_THRESHOLD_MEDIUM, nullptr },
{ "simsun.ttc", "SimSun", 13, 1, 0, 16, HINTING_THRESHOLD_MEDIUM, nullptr },
} };
TTFFontSetDescriptor TTFFontLiHeiPro = { {
{ u8"儷黑 Pro.ttf", "LiHei Pro", 9, 1, -1, 10, HINTING_THRESHOLD_MEDIUM, nullptr },
{ u8"儷黑 Pro.ttf", "LiHei Pro", 9, 1, -1, 9, HINTING_THRESHOLD_MEDIUM, nullptr },
{ u8"儷黑 Pro.ttf", "LiHei Pro", 11, 1, 0, 14, HINTING_THRESHOLD_MEDIUM, nullptr },
{ u8"儷黑 Pro.ttf", "LiHei Pro", 12, 1, 0, 15, HINTING_THRESHOLD_MEDIUM, nullptr },
{ u8"儷黑 Pro.ttf", "LiHei Pro", 13, 1, 0, 16, HINTING_THRESHOLD_MEDIUM, nullptr },
} };
TTFFontSetDescriptor TTFFontGulim = { {
{ "gulim.ttc", "Gulim", 11, 1, 0, 13, HINTING_THRESHOLD_MEDIUM, nullptr },
{ "gulim.ttc", "Gulim", 10, 1, 0, 10, HINTING_THRESHOLD_MEDIUM, 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", 11, 1, 0, 13, HINTING_THRESHOLD_LOW, nullptr },
{ "NanumGothic.ttc", "Nanum Gothic", 10, 1, 0, 10, HINTING_THRESHOLD_LOW, 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 },
} };
TTFFontSetDescriptor TTFFontArial = { {
{ "arial.ttf", "Arial", 8, 0, -1, 6, HINTING_THRESHOLD_LOW, nullptr },
{ "arial.ttf", "Arial", 9, 0, -1, 9, 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, 14, HINTING_THRESHOLD_LOW, nullptr },
} };
TTFFontSetDescriptor TTFFontArialUnicode = { {
{ "arialuni.ttf", "Arial Unicode MS", 8, 0, -1, 6, HINTING_THRESHOLD_LOW, nullptr },
{ "arialuni.ttf", "Arial Unicode MS", 9, 0, -1, 9, HINTING_THRESHOLD_LOW, nullptr },
{ "arialuni.ttf", "Arial Unicode MS", 10, 0, -1, 12, HINTING_THRESHOLD_LOW, nullptr },
{ "arialuni.ttf", "Arial Unicode MS", 11, 0, -1, 12, HINTING_THRESHOLD_LOW, nullptr },
{ "arialuni.ttf", "Arial Unicode MS", 12, 0, -1, 14, HINTING_THRESHOLD_LOW, nullptr },