From 845a812ebf34d97756f74f15656ac767b04b0c8a Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 18 Jul 2022 10:40:03 +0400 Subject: [PATCH] Drop fonts export - users are supposed to use TrueType fonts or mods with legacy format --- apps/openmw/engine.cpp | 8 +------- apps/openmw/engine.hpp | 3 --- apps/openmw/main.cpp | 1 - apps/openmw/mwgui/windowmanagerimp.cpp | 4 ++-- apps/openmw/mwgui/windowmanagerimp.hpp | 2 +- components/fontloader/fontloader.cpp | 24 +++--------------------- components/fontloader/fontloader.hpp | 6 ++---- 7 files changed, 9 insertions(+), 39 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 467d61bf12..c3ace78ac8 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -453,7 +453,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) , mScriptConsoleMode (false) , mActivationDistanceOverride(-1) , mGrab(true) - , mExportFonts(false) , mRandomSeed(0) , mFSStrict (false) , mScriptBlacklistUse (true) @@ -823,7 +822,7 @@ void OMW::Engine::prepareEngine() mWindowManager = std::make_unique(mWindow, mViewer, guiRoot, mResourceSystem.get(), mWorkQueue.get(), mCfgMgr.getLogPath().string() + std::string("/"), - mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts, + mScriptConsoleMode, mTranslationDataStorage, mEncoding, Version::getOpenmwVersionDescription(mResDir.string()), shadersSupported); mEnvironment.setWindowManager(*mWindowManager); @@ -1186,11 +1185,6 @@ void OMW::Engine::setScriptBlacklistUse (bool use) mScriptBlacklistUse = use; } -void OMW::Engine::enableFontExport(bool exportFonts) -{ - mExportFonts = exportFonts; -} - void OMW::Engine::setSaveGameFile(const std::string &savegame) { mSaveGameFile = savegame; diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index ba39132b04..329993a93e 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -160,7 +160,6 @@ namespace OMW // Grab mouse? bool mGrab; - bool mExportFonts; unsigned int mRandomSeed; Compiler::Extensions mExtensions; @@ -254,8 +253,6 @@ namespace OMW void setScriptBlacklistUse (bool use); - void enableFontExport(bool exportFonts); - /// Set the save game file to load after initialising the engine. void setSaveGameFile(const std::string& savegame); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 3274451243..f13d1b39b5 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -156,7 +156,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat Fallback::Map::init(variables["fallback"].as().mMap); engine.setSoundUsage(!variables["no-sound"].as()); engine.setActivationDistanceOverride (variables["activate-dist"].as()); - engine.enableFontExport(variables["export-fonts"].as()); engine.setRandomSeed(variables["random-seed"].as()); return true; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 5c780d764e..3915f3b9c4 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -129,7 +129,7 @@ namespace MWGui WindowManager::WindowManager( SDL_Window* window, osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const std::string& logpath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage, - ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, bool useShaders) + ToUTF8::FromType encoding, const std::string& versionDescription, bool useShaders) : mOldUpdateMask(0) , mOldCullMask(0) , mStore(nullptr) @@ -206,7 +206,7 @@ namespace MWGui // Load fonts mFontLoader = std::make_unique(encoding, resourceSystem->getVFS(), mScalingFactor); - mFontLoader->loadBitmapFonts(exportFonts); + mFontLoader->loadBitmapFonts(); //Register own widgets with MyGUI MyGUI::FactoryManager::getInstance().registerFactory("Widget"); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 090a2b52f9..6ff99665c2 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -136,7 +136,7 @@ namespace MWGui WindowManager(SDL_Window* window, osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const std::string& logpath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage, - ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, bool useShaders); + ToUTF8::FromType encoding, const std::string& versionDescription, bool useShaders); virtual ~WindowManager(); /// Set the ESMStore to use for retrieving of GUI-related strings. diff --git a/components/fontloader/fontloader.cpp b/components/fontloader/fontloader.cpp index b906554cc5..ffa1593318 100644 --- a/components/fontloader/fontloader.cpp +++ b/components/fontloader/fontloader.cpp @@ -196,12 +196,12 @@ namespace Gui mFonts.clear(); } - void FontLoader::loadBitmapFonts(bool exportToFile) + void FontLoader::loadBitmapFonts() { for (const auto& path : mVFS->getRecursiveDirectoryIterator("Fonts/")) { if (Misc::getFileExtension(path) == "fnt") - loadBitmapFont(path, exportToFile); + loadBitmapFont(path); } } @@ -246,7 +246,7 @@ namespace Gui float ascent; } GlyphInfo; - void FontLoader::loadBitmapFont(const std::string &fileName, bool exportToFile) + void FontLoader::loadBitmapFont(const std::string &fileName) { Files::IStreamPtr file = mVFS->get(fileName); @@ -307,17 +307,6 @@ namespace Gui std::string resourceName = name; - if (exportToFile) - { - osg::ref_ptr image = new osg::Image; - image->allocateImage(width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE); - assert (image->isDataContiguous()); - memcpy(image->data(), &textureData[0], textureData.size()); - - Log(Debug::Info) << "Writing " << resourceName + ".png"; - osgDB::writeImageFile(*image, resourceName + ".png"); - } - // Register the font with MyGUI MyGUI::ResourceManualFont* font = static_cast( MyGUI::FactoryManager::getInstance().createObject("Resource", "ResourceManualFont")); @@ -494,13 +483,6 @@ namespace Gui cursorCode->addAttribute("size", "0 0"); } - if (exportToFile) - { - Log(Debug::Info) << "Writing " << resourceName + ".xml"; - xmlDocument.createDeclaration(); - xmlDocument.save(resourceName + ".xml"); - } - font->deserialization(root, MyGUI::Version(3,2,0)); MyGUI::ResourceManualFont* bookFont = static_cast( diff --git a/components/fontloader/fontloader.hpp b/components/fontloader/fontloader.hpp index eb705fdd4a..1f1137614e 100644 --- a/components/fontloader/fontloader.hpp +++ b/components/fontloader/fontloader.hpp @@ -28,8 +28,7 @@ namespace Gui FontLoader (ToUTF8::FromType encoding, const VFS::Manager* vfs, float scalingFactor); ~FontLoader(); - /// @param exportToFile export the converted fonts (Images and XML with glyph metrics) to files? - void loadBitmapFonts (bool exportToFile); + void loadBitmapFonts (); void loadTrueTypeFonts (); void loadFontFromXml(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version); @@ -49,8 +48,7 @@ namespace Gui std::string getInternalFontName(const std::string& name); - /// @param exportToFile export the converted font (Image and XML with glyph metrics) to files? - void loadBitmapFont (const std::string& fileName, bool exportToFile); + void loadBitmapFont (const std::string& fileName); FontLoader(const FontLoader&); void operator=(const FontLoader&);