From 44c8c2a79cccdd1d7b929b15fb40365153960fa3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Feb 2019 23:18:28 +0100 Subject: [PATCH] - added German Umlauts for the BigFont and fixed the character substitution logic. For pure uppercase fonts it makes no sense to try a lowercase substitution as a first step. --- src/gamedata/fonts/font.cpp | 54 +++++++++++++----- src/gamedata/fonts/v_font.h | 1 + .../game-doomchex/fonts/bigfont/00C4.lmp | Bin 0 -> 301 bytes .../game-doomchex/fonts/bigfont/00D6.lmp | Bin 0 -> 353 bytes .../game-doomchex/fonts/bigfont/00DC.lmp | Bin 0 -> 296 bytes 5 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 wadsrc_extra/static/filter/game-doomchex/fonts/bigfont/00C4.lmp create mode 100644 wadsrc_extra/static/filter/game-doomchex/fonts/bigfont/00D6.lmp create mode 100644 wadsrc_extra/static/filter/game-doomchex/fonts/bigfont/00DC.lmp diff --git a/src/gamedata/fonts/font.cpp b/src/gamedata/fonts/font.cpp index a151f1095..a777cdef0 100644 --- a/src/gamedata/fonts/font.cpp +++ b/src/gamedata/fonts/font.cpp @@ -708,24 +708,52 @@ int FFont::GetCharCode(int code, bool needpic) const return code; } - int originalcode = code; - int newcode; - - // Try stripping accents from accented characters. This may repeat to allow multi-step fallbacks. - while ((newcode = stripaccent(code)) != code) + // Use different substitution logic based on the fonts content: + // In a font which has both upper and lower case, prefer unaccented small characters over capital ones. + // In a pure upper-case font, do not check for lower case replacements. + if (!MixedCase) { - code = newcode; - if (code >= FirstChar && code <= LastChar && (!needpic || Chars[code - FirstChar].TranslatedPic != nullptr)) + // Try converting lowercase characters to uppercase. + if (myislower(code)) { - return code; + code = upperforlower[code]; + if (code >= FirstChar && code <= LastChar && (!needpic || Chars[code - FirstChar].TranslatedPic != nullptr)) + { + return code; + } + } + // Try stripping accents from accented characters. + int newcode = stripaccent(code); + if (newcode != code) + { + code = newcode; + if (code >= FirstChar && code <= LastChar && (!needpic || Chars[code - FirstChar].TranslatedPic != nullptr)) + { + return code; + } } } - - if (myislower(code)) + else { - int upper = upperforlower[code]; - // Stripping accents did not help - now try uppercase for lowercase - if (upper != code) return GetCharCode(upper, needpic); + int originalcode = code; + int newcode; + + // Try stripping accents from accented characters. This may repeat to allow multi-step fallbacks. + while ((newcode = stripaccent(code)) != code) + { + code = newcode; + if (code >= FirstChar && code <= LastChar && (!needpic || Chars[code - FirstChar].TranslatedPic != nullptr)) + { + return code; + } + } + + if (myislower(code)) + { + int upper = upperforlower[code]; + // Stripping accents did not help - now try uppercase for lowercase + if (upper != code) return GetCharCode(upper, needpic); + } } return -1; diff --git a/src/gamedata/fonts/v_font.h b/src/gamedata/fonts/v_font.h index 0702781e9..18ca18978 100644 --- a/src/gamedata/fonts/v_font.h +++ b/src/gamedata/fonts/v_font.h @@ -126,6 +126,7 @@ protected: char Cursor; bool noTranslate; bool translateUntranslated; + bool MixedCase = false; struct CharData { FTexture *TranslatedPic = nullptr; // Texture for use with font translations. diff --git a/wadsrc_extra/static/filter/game-doomchex/fonts/bigfont/00C4.lmp b/wadsrc_extra/static/filter/game-doomchex/fonts/bigfont/00C4.lmp new file mode 100644 index 0000000000000000000000000000000000000000..88866e396cb066b679a54aaf0e546f47d13e7402 GIT binary patch literal 301 zcmd;Q;9&p(7X}6f9|i`7SOx}$d|tPFIKjZcaD#z? z;UxnD!!HH~25v?M1{p>M22SQI5ctmkq1jopva(`gva-Me(OFq+Y*|@}(cv(Wz^p75 z4v>=Yz`$sbDxR#Yz^tsqnDEfx#4L~iS5{VhR#Hr4B!ml6oD~xp4U%JI&&rC92Z?9> z2eBh#Kx(u8GjeBT1tw-?C4pQ5GJ^-iNQ#e-k55cYf(k@ug-1q4Mn^{{LInb|qN8JC Vq9eoO;Q}d%@rg)UK&HU(e*pccUo!vz literal 0 HcmV?d00001 diff --git a/wadsrc_extra/static/filter/game-doomchex/fonts/bigfont/00D6.lmp b/wadsrc_extra/static/filter/game-doomchex/fonts/bigfont/00D6.lmp new file mode 100644 index 0000000000000000000000000000000000000000..b3cff0d2e82676ec9eb09a401387b5075b6f2de1 GIT binary patch literal 353 zcmWe+;9&p(9|i`7Xa)v`ECvRKDh39IE(QjM*$fN}YZw?9_A)RqoMT{MxX-}A@PUDW zfsv7cL5PuoL79<(!I+VO!I_bPA&8NIfq^*-1Xv-|e+I6stmv$)ti+g@tgNj64BS~+ zfmum`p`oFHNpOBZaCmrdU^Ix&la&>p6&@ZF6B!&B4;9GD3Qx+)$_ft$2{5u`Wd+1! zWpP01|0n_=Gr$5#P!(`3P=Vl-tSpF@M2L#eM7S-HDOp)rkuhL*@qnBi9UUK^7@r6h o06RP;CMGc{F$Saq%ufoBj894g842=dJjkDkiC}+1yblWn05LXf0ssI2 literal 0 HcmV?d00001 diff --git a/wadsrc_extra/static/filter/game-doomchex/fonts/bigfont/00DC.lmp b/wadsrc_extra/static/filter/game-doomchex/fonts/bigfont/00DC.lmp new file mode 100644 index 0000000000000000000000000000000000000000..ce8fc1b10317b6c9eee4a2694398c756773b5ddb GIT binary patch literal 296 zcmWe&;9&p(4+aK?PzDBu6b1%{5(Wl_76t}}sSFGZ%NQ6K)-y0L>|kJEILN@jaEgI} z;Wh&U!y5($hCd7p3_Oes4AP7Y3=AAuaPXgjD=RBHD?TYDB`GT_>puf`R#sqEbP@=p zA@LIv6BA=Ve4ebV_^jx}#Q2!Vm=vf0)U?pR#H_6U94uK`0Wd~j5>zA