From 698a7d4fe46d2ffcf70a1d2f4652e5582a4be1a1 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Wed, 2 Nov 2022 16:19:14 -0400 Subject: [PATCH] textdraw.cpp: Only reinit iV_Text if already init --- lib/ivis_opengl/textdraw.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/ivis_opengl/textdraw.cpp b/lib/ivis_opengl/textdraw.cpp index 0a69a72b394..01a3d221f6a 100644 --- a/lib/ivis_opengl/textdraw.cpp +++ b/lib/ivis_opengl/textdraw.cpp @@ -116,6 +116,7 @@ struct GlyphMetrics int32_t bearing_y; }; +static bool bLoadedTextSystem = false; static std::unordered_map>> m_loadedFontDataCache; static std::shared_ptr> loadFontData(const std::string &fileName) @@ -1184,6 +1185,8 @@ void iV_TextInit(unsigned int horizScalePercentage, unsigned int vertScalePercen // hb_language_get_default: "To avoid problems, call this function once before multiple threads can call it." hb_language_get_default(); + + bLoadedTextSystem = true; } void iV_TextShutdown() @@ -1195,10 +1198,15 @@ void iV_TextShutdown() textureID = nullptr; fontToEllipsisMap.clear(); clearFontDataCache(); + bLoadedTextSystem = false; } void iV_TextUpdateScaleFactor(unsigned int horizScalePercentage, unsigned int vertScalePercentage) { + if (!bLoadedTextSystem) + { + return; + } iV_TextShutdown(); iV_TextInit(horizScalePercentage, vertScalePercentage); }