From 97ae74081a0e461885aa1c59ac9edd9b5027f826 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 4 Mar 2019 20:06:19 +0100 Subject: [PATCH] - special remapping for the Hungarian double accented letters. Instead of entirely stripping away the accent when they are not found, let's go to the Umlaut-variants first. --- src/gamedata/fonts/font.cpp | 12 ++++++++++++ src/gamedata/fonts/v_font.cpp | 13 +++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/gamedata/fonts/font.cpp b/src/gamedata/fonts/font.cpp index 92ebb03ed..195195316 100644 --- a/src/gamedata/fonts/font.cpp +++ b/src/gamedata/fonts/font.cpp @@ -751,12 +751,24 @@ int FFont::GetCharCode(int code, bool needpic) const } } + code = originalcode; if (myislower(code)) { int upper = upperforlower[code]; // Stripping accents did not help - now try uppercase for lowercase if (upper != code) return GetCharCode(upper, needpic); } + + // Same for the uppercase character. Since we restart at the accented version this must go through the entire thing again. + while ((newcode = stripaccent(code)) != code) + { + code = newcode; + if (code >= FirstChar && code <= LastChar && (!needpic || Chars[code - FirstChar].TranslatedPic != nullptr)) + { + return code; + } + } + } return -1; diff --git a/src/gamedata/fonts/v_font.cpp b/src/gamedata/fonts/v_font.cpp index 9218c5d19..bd88bf48f 100644 --- a/src/gamedata/fonts/v_font.cpp +++ b/src/gamedata/fonts/v_font.cpp @@ -838,8 +838,17 @@ int stripaccent(int code) } else if (code >= 0x100 && code < 0x180) { - static const char accentless[] = "AaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgHhHhIiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnnNnOoOoOoOoRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwYyYZzZzZz "; - return accentless[code -0x100]; + // For the double-accented Hungarian letters it makes more sense to first map them to the very similar looking Umlauts. + // (And screw the crappy specs here that do not allow UTF-8 multibyte characters here.) + if (code == 0x150) code = 0xd6; + else if (code == 0x151) code = 0xf6; + else if (code == 0x170) code = 0xdc; + else if (code == 0x171) code = 0xfc; + else + { + static const char accentless[] = "AaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgHhHhIiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnnNnOoOoOoOoRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwYyYZzZzZz "; + return accentless[code - 0x100]; + } } else if (code >= 0x200 && code < 0x21c) {