diff --git a/openrct2.vcxproj b/openrct2.vcxproj
index d2f142d7bc..99c831daf7 100644
--- a/openrct2.vcxproj
+++ b/openrct2.vcxproj
@@ -89,6 +89,7 @@
+
@@ -417,6 +418,7 @@
+
diff --git a/src/config.c b/src/config.c
index 5bc9656b75..241910f853 100644
--- a/src/config.c
+++ b/src/config.c
@@ -334,7 +334,6 @@ sound_configuration gConfigSound;
twitch_configuration gConfigTwitch;
network_configuration gConfigNetwork;
notification_configuration gConfigNotifications;
-font_configuration gConfigFonts;
title_sequences_configuration gConfigTitleSequences;
static bool config_open(const utf8string path);
diff --git a/src/interface/Fonts.cpp b/src/interface/Fonts.cpp
new file mode 100644
index 0000000000..407f7ffc6a
--- /dev/null
+++ b/src/interface/Fonts.cpp
@@ -0,0 +1,157 @@
+#pragma region Copyright(c) 2014 - 2016 OpenRCT2 Developers
+/*****************************************************************************
+ * OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
+ *
+ * OpenRCT2 is the work of many authors, a full list can be found in contributors.md
+ * For more information, visit https://github.com/OpenRCT2/OpenRCT2
+ *
+ * OpenRCT2 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * A full copy of the GNU General Public License can be found in licence.txt
+ *****************************************************************************/
+#pragma endregion
+
+#include "../common.h"
+#include "Fonts.h"
+#include "../core/Console.hpp"
+#include "../core/String.hpp"
+#include "../localisation/LanguagePack.h"
+
+extern "C" {
+#include "../config.h"
+#include "../drawing/drawing.h"
+#include "../localisation/language.h"
+font_configuration gConfigFonts;
+}
+
+static 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 },
+} };
+
+static 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 },
+} };
+
+static 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 },
+} };
+
+static 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 },
+} };
+
+static 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 },
+} };
+
+const language_descriptor LanguagesDescriptors[LANGUAGE_COUNT] = {
+ { "", "", "", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_UNDEFINED
+ { "en-GB", "English (UK)", "English (UK)", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_ENGLISH_UK
+ { "en-US", "English (US)", "English (US)", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_US }, // LANGUAGE_ENGLISH_US
+ { "de-DE", "German", "Deutsch", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_GERMAN }, // LANGUAGE_GERMAN
+ { "nl-NL", "Dutch", "Nederlands", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_DUTCH }, // LANGUAGE_DUTCH
+ { "fr-FR", "French", u8"Français", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_FRENCH }, // LANGUAGE_FRENCH
+ { "hu-HU", "Hungarian", "Magyar", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_HUNGARIAN
+ { "pl-PL", "Polish", "Polski", &TTFFontArial, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_POLISH
+ { "es-ES", "Spanish", u8"Español", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_SPANISH }, // LANGUAGE_SPANISH
+ { "sv-SE", "Swedish", "Svenska", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_SWEDISH }, // LANGUAGE_SWEDISH
+ { "it-IT", "Italian", "Italiano", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ITALIAN }, // LANGUAGE_ITALIAN
+ { "pt-BR", "Portuguese (BR)", u8"Português (BR)", FONT_OPENRCT2_SPRITE,
+ RCT2_LANGUAGE_ID_PORTUGUESE }, // LANGUAGE_PORTUGUESE_BR
+ { "zh-TW", "Chinese (Traditional)", "Chinese (Traditional)", &TTFFontMingLiu,
+ RCT2_LANGUAGE_ID_CHINESE_TRADITIONAL }, // LANGUAGE_CHINESE_TRADITIONAL
+ { "zh-CN", "Chinese (Simplified)", "Chinese (Simplified)", &TTFFontSimSun,
+ RCT2_LANGUAGE_ID_CHINESE_SIMPLIFIED }, // LANGUAGE_CHINESE_SIMPLIFIED
+ { "fi-FI", "Finnish", "Suomi", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_FINNISH
+ { "ko-KR", "Korean", "Korean", &TTFFontGulim, RCT2_LANGUAGE_ID_KOREAN }, // LANGUAGE_KOREAN
+ { "ru-RU", "Russian", "Russian", &TTFFontArial, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_RUSSIAN
+ { "cs-CZ", "Czech", "Czech", &TTFFontArial, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_CZECH
+ { "ja-JP", "Japanese", "Japanese", &TTFFontMSGothic, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_JAPANESE
+ {
+ "nb-NO", "Norwegian", "Norsk", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK,
+ }, // LANGUAGE_NORWEGIAN
+};
+
+static void LoadSpriteFont()
+{
+ ttf_dispose();
+ gUseTrueTypeFont = false;
+ gCurrentTTFFontSet = nullptr;
+}
+
+static bool LoadFont(TTFFontSetDescriptor * font)
+{
+ gUseTrueTypeFont = true;
+ gCurrentTTFFontSet = font;
+
+ bool fontInitialised = ttf_initialise();
+ return fontInitialised;
+}
+
+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.file_name, gConfigFonts.font_name, gConfigFonts.size_small, gConfigFonts.x_offset, gConfigFonts.y_offset,
+ gConfigFonts.height_small, nullptr },
+ { gConfigFonts.file_name, gConfigFonts.font_name, gConfigFonts.size_medium, gConfigFonts.x_offset,
+ gConfigFonts.y_offset, gConfigFonts.height_medium, nullptr },
+ { gConfigFonts.file_name, gConfigFonts.font_name, gConfigFonts.size_big, gConfigFonts.x_offset, gConfigFonts.y_offset,
+ gConfigFonts.height_big, nullptr },
+ } };
+
+ ttf_dispose();
+ gUseTrueTypeFont = true;
+ gCurrentTTFFontSet = &TTFFontCustom;
+
+ bool fontInitialised = ttf_initialise();
+ return fontInitialised;
+}
+
+void TryLoadFonts()
+{
+ TTFFontSetDescriptor * font = LanguagesDescriptors[gCurrentLanguage].font;
+ if (font != FONT_OPENRCT2_SPRITE)
+ {
+ if (!String::IsNullOrEmpty(gConfigFonts.file_name))
+ {
+ if (LoadCustomConfigFont())
+ {
+ return;
+ }
+ Console::Error::WriteLine("Unable to initialise configured TrueType font -- falling back to Language default.");
+ }
+
+ if (LoadFont(font))
+ {
+ return;
+ }
+ Console::Error::WriteLine("Unable to initialise prefered TrueType font -- falling back to Arial.");
+
+ if (LoadFont(&TTFFontArial))
+ {
+ return;
+ }
+ Console::Error::WriteLine("Unable to initialise prefered TrueType font -- Falling back to sprite font.");
+ }
+ LoadSpriteFont();
+}
diff --git a/src/interface/Fonts.h b/src/interface/Fonts.h
new file mode 100644
index 0000000000..7ae6308317
--- /dev/null
+++ b/src/interface/Fonts.h
@@ -0,0 +1,32 @@
+#pragma region Copyright(c) 2014 - 2016 OpenRCT2 Developers
+/*****************************************************************************
+ * OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
+ *
+ * OpenRCT2 is the work of many authors, a full list can be found in contributors.md
+ * For more information, visit https://github.com/OpenRCT2/OpenRCT2
+ *
+ * OpenRCT2 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * A full copy of the GNU General Public License can be found in licence.txt
+ *****************************************************************************/
+#pragma endregion
+
+#ifndef OPENRCT2_FONTS_H
+#define OPENRCT2_FONTS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "../drawing/font.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+void TryLoadFonts();
+
+#endif // OPENRCT2_FONTS_H
diff --git a/src/localisation/language.cpp b/src/localisation/language.cpp
index b6b5952e7e..935c12c804 100644
--- a/src/localisation/language.cpp
+++ b/src/localisation/language.cpp
@@ -21,81 +21,13 @@
#include "../core/String.hpp"
#include "../core/StringBuilder.hpp"
#include "../object/ObjectManager.h"
+#include "../interface/Fonts.h"
#include "LanguagePack.h"
extern "C" {
-#include "../config.h"
-#include "../drawing/drawing.h"
-#include "../object.h"
-#include "../openrct2.h"
-#include "../util/util.h"
#include "localisation.h"
-static 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 },
-}};
-
-static 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 },
-}};
-
-static 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 },
-}};
-
-static 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 },
-}};
-
-static 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 },
-}};
-
-const language_descriptor LanguagesDescriptors[LANGUAGE_COUNT] =
-{
- { "", "", "", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_UNDEFINED
- { "en-GB", "English (UK)", "English (UK)", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_ENGLISH_UK
- { "en-US", "English (US)", "English (US)", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_US }, // LANGUAGE_ENGLISH_US
- { "de-DE", "German", "Deutsch", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_GERMAN }, // LANGUAGE_GERMAN
- { "nl-NL", "Dutch", "Nederlands", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_DUTCH }, // LANGUAGE_DUTCH
- { "fr-FR", "French", u8"Français", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_FRENCH }, // LANGUAGE_FRENCH
- { "hu-HU", "Hungarian", "Magyar", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_HUNGARIAN
- { "pl-PL", "Polish", "Polski", &TTFFontArial, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_POLISH
- { "es-ES", "Spanish", u8"Español", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_SPANISH }, // LANGUAGE_SPANISH
- { "sv-SE", "Swedish", "Svenska", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_SWEDISH }, // LANGUAGE_SWEDISH
- { "it-IT", "Italian", "Italiano", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ITALIAN }, // LANGUAGE_ITALIAN
- { "pt-BR", "Portuguese (BR)", u8"Português (BR)", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_PORTUGUESE }, // LANGUAGE_PORTUGUESE_BR
- { "zh-TW", "Chinese (Traditional)", "Chinese (Traditional)", &TTFFontMingLiu, RCT2_LANGUAGE_ID_CHINESE_TRADITIONAL }, // LANGUAGE_CHINESE_TRADITIONAL
- { "zh-CN", "Chinese (Simplified)", "Chinese (Simplified)", &TTFFontSimSun, RCT2_LANGUAGE_ID_CHINESE_SIMPLIFIED }, // LANGUAGE_CHINESE_SIMPLIFIED
- { "fi-FI", "Finnish", "Suomi", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_FINNISH
- { "ko-KR", "Korean", "Korean", &TTFFontGulim, RCT2_LANGUAGE_ID_KOREAN }, // LANGUAGE_KOREAN
- { "ru-RU", "Russian", "Russian", &TTFFontArial, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_RUSSIAN
- { "cs-CZ", "Czech", "Czech", &TTFFontArial, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_CZECH
- { "ja-JP", "Japanese", "Japanese", &TTFFontMSGothic, RCT2_LANGUAGE_ID_ENGLISH_UK }, // LANGUAGE_JAPANESE
- { "nb-NO", "Norwegian", "Norsk", FONT_OPENRCT2_SPRITE, RCT2_LANGUAGE_ID_ENGLISH_UK, }, // LANGUAGE_NORWEGIAN
-};
-
int gCurrentLanguage = LANGUAGE_UNDEFINED;
bool gUseTrueTypeFont = false;
@@ -155,69 +87,6 @@ static utf8 * GetLanguagePath(utf8 * buffer, size_t bufferSize, uint32 languageI
return buffer;
}
-static void LoadSpriteFont()
-{
- ttf_dispose();
- gUseTrueTypeFont = false;
- gCurrentTTFFontSet = nullptr;
-}
-
-static bool LoadFont(TTFFontSetDescriptor * font)
-{
- gUseTrueTypeFont = true;
- gCurrentTTFFontSet = font;
-
- bool fontInitialised = ttf_initialise();
- return fontInitialised;
-}
-
-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.file_name, gConfigFonts.font_name, gConfigFonts.size_small, gConfigFonts.x_offset, gConfigFonts.y_offset, gConfigFonts.height_small, nullptr },
- { gConfigFonts.file_name, gConfigFonts.font_name, gConfigFonts.size_medium, gConfigFonts.x_offset, gConfigFonts.y_offset, gConfigFonts.height_medium, nullptr },
- { gConfigFonts.file_name, gConfigFonts.font_name, gConfigFonts.size_big, gConfigFonts.x_offset, gConfigFonts.y_offset, gConfigFonts.height_big, nullptr },
- }};
-
- ttf_dispose();
- gUseTrueTypeFont = true;
- gCurrentTTFFontSet = &TTFFontCustom;
-
- bool fontInitialised = ttf_initialise();
- return fontInitialised;
-}
-
-static void TryLoadFonts()
-{
- TTFFontSetDescriptor * font = LanguagesDescriptors[gCurrentLanguage].font;
- if (font != FONT_OPENRCT2_SPRITE)
- {
- if (!String::IsNullOrEmpty(gConfigFonts.file_name))
- {
- if (LoadCustomConfigFont())
- {
- return;
- }
- Console::Error::WriteLine("Unable to initialise configured TrueType font -- falling back to Language default.");
- }
-
- if (LoadFont(font))
- {
- return;
- }
- Console::Error::WriteLine("Unable to initialise prefered TrueType font -- falling back to Arial.");
-
- if (LoadFont(&TTFFontArial))
- {
- return;
- }
- Console::Error::WriteLine("Unable to initialise prefered TrueType font -- Falling back to sprite font.");
- }
- LoadSpriteFont();
-}
-
bool language_open(int id)
{
char filename[MAX_PATH];