mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-18 20:43:04 +01:00
Remove use of gUseTrueTypeFont
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <openrct2/interface/themes.h>
|
||||
#include <openrct2/interface/Window.h>
|
||||
#include <openrct2/localisation/Language.h>
|
||||
#include <openrct2/localisation/LocalisationService.h>
|
||||
#include <openrct2/Version.h>
|
||||
#include "InGameConsole.h"
|
||||
|
||||
@@ -256,7 +257,7 @@ void InGameConsole::Draw(rct_drawpixelinfo * dpi) const
|
||||
}
|
||||
|
||||
// TTF looks far better without the outlines
|
||||
if (!gUseTrueTypeFont)
|
||||
if (!LocalisationService_UseTrueTypeFont())
|
||||
{
|
||||
textColour |= COLOUR_FLAG_OUTLINE;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2/localisation/Localisation.h>
|
||||
#include <openrct2/localisation/LocalisationService.h>
|
||||
#include <openrct2/sprites.h>
|
||||
|
||||
#define WW 400
|
||||
@@ -249,7 +250,7 @@ static void window_about_openrct2_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
|
||||
// Copyright disclaimer; hidden when using truetype fonts to prevent
|
||||
// the text from overlapping the changelog button.
|
||||
if (!gUseTrueTypeFont)
|
||||
if (!LocalisationService_UseTrueTypeFont())
|
||||
{
|
||||
gfx_draw_string_centred_wrapped(dpi, nullptr, x, y, width, STR_ABOUT_OPENRCT2_DESCRIPTION_3, w->colours[2]);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <openrct2/interface/themes.h>
|
||||
#include <openrct2/localisation/Date.h>
|
||||
#include <openrct2/localisation/Localisation.h>
|
||||
#include <openrct2/localisation/LocalisationService.h>
|
||||
#include <openrct2/scenario/ScenarioRepository.h>
|
||||
#include <openrct2/scenario/ScenarioSources.h>
|
||||
#include <openrct2/sprites.h>
|
||||
@@ -282,7 +283,7 @@ static void window_scenarioselect_mousedown(rct_window *w, rct_widgetindex widge
|
||||
|
||||
static sint32 get_scenario_list_item_size()
|
||||
{
|
||||
if (!gUseTrueTypeFont)
|
||||
if (!LocalisationService_UseTrueTypeFont())
|
||||
return 24;
|
||||
|
||||
// Scenario title
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "../core/Util.hpp"
|
||||
#include "../localisation/FormatCodes.h"
|
||||
#include "../localisation/Language.h"
|
||||
#include "../localisation/LocalisationService.h"
|
||||
#include "../sprites.h"
|
||||
#include "Drawing.h"
|
||||
#include "Font.h"
|
||||
@@ -158,7 +159,7 @@ sint32 font_get_line_height(sint32 fontSpriteBase)
|
||||
{
|
||||
sint32 fontSize = font_get_size_from_sprite_base(fontSpriteBase);
|
||||
#ifndef NO_TTF
|
||||
if (gUseTrueTypeFont) {
|
||||
if (LocalisationService_UseTrueTypeFont()) {
|
||||
return gCurrentTTFFontSet->size[fontSize].line_height;
|
||||
} else {
|
||||
#endif // NO_TTF
|
||||
@@ -265,7 +266,7 @@ bool font_supports_string_ttf(const utf8 *text, sint32 fontSize)
|
||||
|
||||
bool font_supports_string(const utf8 *text, sint32 fontSize)
|
||||
{
|
||||
if (gUseTrueTypeFont) {
|
||||
if (LocalisationService_UseTrueTypeFont()) {
|
||||
return font_supports_string_ttf(text, fontSize);
|
||||
} else {
|
||||
return font_supports_string_sprite(text);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "../config/Config.h"
|
||||
#include "../interface/Colour.h"
|
||||
#include "../localisation/Localisation.h"
|
||||
#include "../localisation/LocalisationService.h"
|
||||
#include "../paint/Paint.h"
|
||||
#include "../sprites.h"
|
||||
#include "Drawing.h"
|
||||
@@ -1459,7 +1460,7 @@ sint32 scrolling_text_setup(paint_session * session, rct_string_id stringId, uin
|
||||
const sint16* scrollingModePositions = _scrollPositions[scrollingMode];
|
||||
|
||||
memset(scrollText->bitmap, 0, 320 * 8);
|
||||
if (gUseTrueTypeFont) {
|
||||
if (LocalisationService_UseTrueTypeFont()) {
|
||||
scrolling_text_set_bitmap_for_ttf(scrollString, scroll, scrollText->bitmap, scrollingModePositions);
|
||||
} else {
|
||||
scrolling_text_set_bitmap_for_sprite(scrollString, scroll, scrollText->bitmap, scrollingModePositions);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "../drawing/Drawing.h"
|
||||
#include "../interface/Viewport.h"
|
||||
#include "../localisation/Localisation.h"
|
||||
#include "../localisation/LocalisationService.h"
|
||||
#include "../platform/platform.h"
|
||||
#include "../sprites.h"
|
||||
#include "../util/Util.h"
|
||||
@@ -822,7 +823,7 @@ void ttf_draw_string(rct_drawpixelinfo *dpi, const_utf8string text, sint32 colou
|
||||
info.x = x;
|
||||
info.y = y;
|
||||
|
||||
if (gUseTrueTypeFont) {
|
||||
if (LocalisationService_UseTrueTypeFont()) {
|
||||
info.flags |= TEXT_DRAW_FLAG_TTF;
|
||||
}
|
||||
|
||||
@@ -851,7 +852,7 @@ static sint32 ttf_get_string_width(const utf8 *text)
|
||||
info.maxY = 0;
|
||||
|
||||
info.flags |= TEXT_DRAW_FLAG_NO_DRAW;
|
||||
if (gUseTrueTypeFont) {
|
||||
if (LocalisationService_UseTrueTypeFont()) {
|
||||
info.flags |= TEXT_DRAW_FLAG_TTF;
|
||||
}
|
||||
|
||||
@@ -877,7 +878,7 @@ void gfx_draw_string_with_y_offsets(rct_drawpixelinfo *dpi, const utf8 *text, si
|
||||
|
||||
info.flags |= TEXT_DRAW_FLAG_Y_OFFSET_EFFECT;
|
||||
|
||||
if (!forceSpriteFont && gUseTrueTypeFont) {
|
||||
if (!forceSpriteFont && LocalisationService_UseTrueTypeFont()) {
|
||||
info.flags |= TEXT_DRAW_FLAG_TTF;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "../config/Config.h"
|
||||
#include "../localisation/Localisation.h"
|
||||
#include "../localisation/LocalisationService.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../platform/platform.h"
|
||||
#include "TTF.h"
|
||||
@@ -157,7 +158,7 @@ static void ttf_surface_cache_dispose_all()
|
||||
|
||||
void ttf_toggle_hinting()
|
||||
{
|
||||
if (!gUseTrueTypeFont)
|
||||
if (!LocalisationService_UseTrueTypeFont())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
|
||||
#include "../drawing/TTF.h"
|
||||
#include "../localisation/Language.h"
|
||||
#include "../localisation/LocalisationService.h"
|
||||
|
||||
using namespace OpenRCT2::Localisation;
|
||||
|
||||
#ifndef NO_TTF
|
||||
uint8 const HINTING_DISABLED = 0;
|
||||
@@ -100,19 +103,19 @@ TTFFontSetDescriptor TTFFontArialUnicode = { {
|
||||
// clang-format on
|
||||
#endif // NO_TTF
|
||||
|
||||
static void LoadSpriteFont()
|
||||
static void LoadSpriteFont(LocalisationService& localisationService)
|
||||
{
|
||||
ttf_dispose();
|
||||
gUseTrueTypeFont = false;
|
||||
localisationService.UseTrueTypeFont(false);
|
||||
#ifndef NO_TTF
|
||||
gCurrentTTFFontSet = nullptr;
|
||||
#endif // NO_TTF
|
||||
}
|
||||
|
||||
#ifndef NO_TTF
|
||||
static bool LoadFont(TTFFontSetDescriptor * font)
|
||||
static bool LoadFont(LocalisationService& localisationService, TTFFontSetDescriptor * font)
|
||||
{
|
||||
gUseTrueTypeFont = true;
|
||||
localisationService.UseTrueTypeFont(true);
|
||||
gCurrentTTFFontSet = font;
|
||||
|
||||
ttf_dispose();
|
||||
@@ -120,7 +123,7 @@ static bool LoadFont(TTFFontSetDescriptor * font)
|
||||
return fontInitialised;
|
||||
}
|
||||
|
||||
static bool LoadCustomConfigFont()
|
||||
static bool LoadCustomConfigFont(LocalisationService& localisationService)
|
||||
{
|
||||
static TTFFontSetDescriptor TTFFontCustom = { {
|
||||
{ gConfigFonts.file_name, gConfigFonts.font_name, gConfigFonts.size_tiny, gConfigFonts.x_offset, gConfigFonts.y_offset,
|
||||
@@ -134,7 +137,7 @@ static bool LoadCustomConfigFont()
|
||||
} };
|
||||
|
||||
ttf_dispose();
|
||||
gUseTrueTypeFont = true;
|
||||
localisationService.UseTrueTypeFont(true);
|
||||
gCurrentTTFFontSet = &TTFFontCustom;
|
||||
|
||||
bool fontInitialised = ttf_initialise();
|
||||
@@ -142,7 +145,7 @@ static bool LoadCustomConfigFont()
|
||||
}
|
||||
#endif // NO_TTF
|
||||
|
||||
void TryLoadFonts()
|
||||
void TryLoadFonts(LocalisationService& localisationService)
|
||||
{
|
||||
#ifndef NO_TTF
|
||||
TTFontFamily const * fontFamily = LanguagesDescriptors[gCurrentLanguage].font_family;
|
||||
@@ -151,7 +154,7 @@ void TryLoadFonts()
|
||||
{
|
||||
if (!String::IsNullOrEmpty(gConfigFonts.file_name))
|
||||
{
|
||||
if (LoadCustomConfigFont())
|
||||
if (LoadCustomConfigFont(localisationService))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -160,7 +163,7 @@ void TryLoadFonts()
|
||||
|
||||
for (auto &font : *fontFamily)
|
||||
{
|
||||
if (LoadFont(font))
|
||||
if (LoadFont(localisationService, font))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -175,7 +178,7 @@ void TryLoadFonts()
|
||||
|
||||
for (auto &font : TTFFamilySansSerif)
|
||||
{
|
||||
if (LoadFont(font))
|
||||
if (LoadFont(localisationService, font))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -188,5 +191,5 @@ void TryLoadFonts()
|
||||
}
|
||||
}
|
||||
#endif // NO_TTF
|
||||
LoadSpriteFont();
|
||||
LoadSpriteFont(localisationService);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
#ifndef OPENRCT2_FONTS_H
|
||||
#define OPENRCT2_FONTS_H
|
||||
|
||||
namespace OpenRCT2::Localisation
|
||||
{
|
||||
class LocalisationService;
|
||||
}
|
||||
|
||||
#include "../drawing/Font.h"
|
||||
|
||||
#ifndef NO_TTF
|
||||
@@ -35,6 +40,6 @@ extern TTFFontSetDescriptor TTFFontArialUnicode;
|
||||
#define FONT(x) FONT_OPENRCT2_SPRITE
|
||||
#endif // NO_TTF
|
||||
|
||||
void TryLoadFonts();
|
||||
void TryLoadFonts(OpenRCT2::Localisation::LocalisationService& localisationService);
|
||||
|
||||
#endif // OPENRCT2_FONTS_H
|
||||
|
||||
@@ -87,7 +87,6 @@ struct language_descriptor {
|
||||
extern const language_descriptor LanguagesDescriptors[LANGUAGE_COUNT];
|
||||
|
||||
extern sint32 gCurrentLanguage;
|
||||
extern bool gUseTrueTypeFont;
|
||||
|
||||
extern const utf8 BlackUpArrowString[];
|
||||
extern const utf8 BlackDownArrowString[];
|
||||
|
||||
@@ -93,7 +93,7 @@ void LocalisationService::OpenLanguage(sint32 id, IObjectManager& objectManager)
|
||||
if (_languageCurrent != nullptr)
|
||||
{
|
||||
_currentLanguage = id;
|
||||
TryLoadFonts();
|
||||
TryLoadFonts(*this);
|
||||
|
||||
// Objects and their localised strings need to be refreshed
|
||||
objectManager.ResetObjects();
|
||||
|
||||
@@ -42,7 +42,8 @@ namespace OpenRCT2::Localisation
|
||||
|
||||
public:
|
||||
sint32 GetCurrentLanguage() const { return _currentLanguage; }
|
||||
sint32 UseTrueTypeFont() const { return _useTrueTypeFont; }
|
||||
bool UseTrueTypeFont() const { return _useTrueTypeFont; }
|
||||
void UseTrueTypeFont(bool value) { _useTrueTypeFont = value; }
|
||||
|
||||
LocalisationService(const std::shared_ptr<IPlatformEnvironment>& env);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "../drawing/Drawing.h"
|
||||
#include "../interface/Viewport.h"
|
||||
#include "../localisation/Localisation.h"
|
||||
#include "../localisation/LocalisationService.h"
|
||||
#include "Paint.h"
|
||||
#include "sprite/Sprite.h"
|
||||
#include "tile_element/TileElement.h"
|
||||
@@ -1201,7 +1202,7 @@ void paint_draw_money_structs(rct_drawpixelinfo * dpi, paint_string_struct * ps)
|
||||
// Use sprite font unless the currency contains characters unsupported by the sprite font
|
||||
bool forceSpriteFont = false;
|
||||
const currency_descriptor& currencyDesc = CurrencyDescriptors[gConfigGeneral.currency_format];
|
||||
if (gUseTrueTypeFont && font_supports_string_sprite(currencyDesc.symbol_unicode))
|
||||
if (LocalisationService_UseTrueTypeFont() && font_supports_string_sprite(currencyDesc.symbol_unicode))
|
||||
{
|
||||
forceSpriteFont = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user