summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPavel Stupnikov <dp@dpointer.org>2018-04-17 20:41:31 +0300
committerPeterN <peter@fuzzle.org>2018-04-17 18:41:31 +0100
commit9175c349dac23cb236aa981e93bac28a4857c19e (patch)
tree1c29c42f7072c97e0c0e8d21a3c7d9c716b90400 /src
parent4d6a5fbec48d0b9967c219c6614566b5a0ef8baa (diff)
downloadopenttd-9175c349dac23cb236aa981e93bac28a4857c19e.tar.xz
Fix #6465: Add {NORMAL_FONT} and {MONO_FONT} control codes to GS strings (#6726)
Diffstat (limited to 'src')
-rw-r--r--src/gfx_layout.cpp6
-rw-r--r--src/strings.cpp6
-rw-r--r--src/table/control_codes.h10
-rw-r--r--src/table/strgen_tables.h2
4 files changed, 13 insertions, 11 deletions
diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp
index f5463d401..de59fc5c8 100644
--- a/src/gfx_layout.cpp
+++ b/src/gfx_layout.cpp
@@ -596,10 +596,8 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, const char *&str,
state.SetColour((TextColour)(c - SCC_BLUE));
} else if (c == SCC_PREVIOUS_COLOUR) { // Revert to the previous colour.
state.SetPreviousColour();
- } else if (c == SCC_TINYFONT) {
- state.SetFontSize(FS_SMALL);
- } else if (c == SCC_BIGFONT) {
- state.SetFontSize(FS_LARGE);
+ } else if (c >= SCC_FIRST_FONT && c <= SCC_LAST_FONT) {
+ state.SetFontSize((FontSize)(c - SCC_FIRST_FONT));
} else {
/* Filter out text direction characters that shouldn't be drawn, and
* will not be handled in the fallback non ICU case because they are
diff --git a/src/strings.cpp b/src/strings.cpp
index fd7420259..82669ddb2 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -2014,10 +2014,8 @@ bool MissingGlyphSearcher::FindMissingGlyphs(const char **str)
FontSize size = this->DefaultSize();
if (str != NULL) *str = text;
for (WChar c = Utf8Consume(&text); c != '\0'; c = Utf8Consume(&text)) {
- if (c == SCC_TINYFONT) {
- size = FS_SMALL;
- } else if (c == SCC_BIGFONT) {
- size = FS_LARGE;
+ if (c >= SCC_FIRST_FONT && c <= SCC_LAST_FONT) {
+ size = (FontSize)(c - SCC_FIRST_FONT);
} else if (!IsInsideMM(c, SCC_SPRITE_START, SCC_SPRITE_END) && IsPrintable(c) && !IsTextDirectionChar(c) && c != '?' && GetGlyph(size, c) == question_mark[size]) {
/* The character is printable, but not in the normal font. This is the case we were testing for. */
return true;
diff --git a/src/table/control_codes.h b/src/table/control_codes.h
index d6b1ad6f4..ad620197a 100644
--- a/src/table/control_codes.h
+++ b/src/table/control_codes.h
@@ -26,9 +26,13 @@ enum StringControlCode {
/* This must be the first entry. It's encoded in strings that are saved. */
SCC_ENCODED = SCC_CONTROL_START,
- /* Display control codes */
- SCC_TINYFONT, ///< Switch to small font
- SCC_BIGFONT, ///< Switch to large font
+ /* Font selection codes, must be in same order as FontSize enum */
+ SCC_FIRST_FONT,
+ SCC_NORMALFONT = SCC_FIRST_FONT, ///< Switch to normal size font
+ SCC_TINYFONT, ///< Switch to small font
+ SCC_BIGFONT, ///< Switch to large font
+ SCC_MONOFONT, ///< Switch to monospaced font
+ SCC_LAST_FONT = SCC_MONOFONT,
/* Formatting control codes */
SCC_REVISION,
diff --git a/src/table/strgen_tables.h b/src/table/strgen_tables.h
index 322f1bc6b..d4294fa84 100644
--- a/src/table/strgen_tables.h
+++ b/src/table/strgen_tables.h
@@ -37,8 +37,10 @@ extern void EmitGender(Buffer *buffer, char *buf, int value);
static const CmdStruct _cmd_structs[] = {
/* Font size */
+ {"NORMAL_FONT", EmitSingleChar, SCC_NORMALFONT, 0, -1, C_NONE},
{"TINY_FONT", EmitSingleChar, SCC_TINYFONT, 0, -1, C_NONE},
{"BIG_FONT", EmitSingleChar, SCC_BIGFONT, 0, -1, C_NONE},
+ {"MONO_FONT", EmitSingleChar, SCC_MONOFONT, 0, -1, C_NONE},
/* Colours */
{"BLUE", EmitSingleChar, SCC_BLUE, 0, -1, C_DONTCOUNT},