mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
made fonts available without installing system-wide
This commit is contained in:
+8
-1
@@ -64,7 +64,14 @@
|
|||||||
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x64-windows-static",
|
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x64-windows-static",
|
||||||
"buildCommandArgs": "-v",
|
"buildCommandArgs": "-v",
|
||||||
"ctestCommandArgs": "",
|
"ctestCommandArgs": "",
|
||||||
"inheritEnvironments": [ "msvc_x64_x64" ]
|
"inheritEnvironments": [ "msvc_x64_x64" ],
|
||||||
|
"variables": [
|
||||||
|
{
|
||||||
|
"name": "VCPKG_MANIFEST_FEATURES",
|
||||||
|
"value": "fonts",
|
||||||
|
"type": "STRING"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,9 @@
|
|||||||
|
|
||||||
#include <util/prec.hpp>
|
#include <util/prec.hpp>
|
||||||
#include <data/font.hpp>
|
#include <data/font.hpp>
|
||||||
|
#include <wx/stdpaths.h>
|
||||||
|
#include <wx/dir.h>
|
||||||
|
#include <wx/font.h>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Font
|
// ----------------------------------------------------------------------------- : Font
|
||||||
|
|
||||||
@@ -24,6 +27,41 @@ Font::Font()
|
|||||||
, flags(FONT_NORMAL)
|
, flags(FONT_NORMAL)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
bool Font::PreloadResourceFonts() {
|
||||||
|
#if wxUSE_PRIVATE_FONTS
|
||||||
|
wxUniChar pathSeparator = wxFileName::GetPathSeparator();
|
||||||
|
String appPath( wxFileName(wxStandardPaths::Get().GetExecutablePath()).GetPath() );
|
||||||
|
String fontsPath = appPath + pathSeparator + "resource" + pathSeparator + "fonts" + pathSeparator;
|
||||||
|
|
||||||
|
if (!wxDirExists(fontsPath))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
wxDir fontsDirectory(fontsPath);
|
||||||
|
vector<String> fontFilePaths;
|
||||||
|
String fontFileName = "";
|
||||||
|
|
||||||
|
// are there any font files in the resource/fonts directory?
|
||||||
|
if (!fontsDirectory.GetFirst(&fontFileName, "*.ttf"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
fontFilePaths.push_back(fontsPath + fontFileName);
|
||||||
|
while (fontsDirectory.GetNext(&fontFileName))
|
||||||
|
fontFilePaths.push_back(fontsPath + fontFileName);
|
||||||
|
|
||||||
|
bool preloadHadErrors = false;
|
||||||
|
for (String fn : fontFilePaths) {
|
||||||
|
if (!wxFont::AddPrivateFont(fn)) {
|
||||||
|
preloadHadErrors = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return preloadHadErrors;
|
||||||
|
|
||||||
|
#endif // wxUSE_PRIVATE_FONTS
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Font::update(Context& ctx) {
|
bool Font::update(Context& ctx) {
|
||||||
bool changes = false;
|
bool changes = false;
|
||||||
changes |= name .update(ctx);
|
changes |= name .update(ctx);
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ public:
|
|||||||
|
|
||||||
Font();
|
Font();
|
||||||
|
|
||||||
|
/// Load fonts (.ttf) from the resource/fonts directory
|
||||||
|
static bool PreloadResourceFonts();
|
||||||
/// Update the scritables, returns true if there is a change
|
/// Update the scritables, returns true if there is a change
|
||||||
bool update(Context& ctx);
|
bool update(Context& ctx);
|
||||||
/// Add the given dependency to the dependent_scripts list for the variables this font depends on
|
/// Add the given dependency to the dependent_scripts list for the variables this font depends on
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include <data/locale.hpp>
|
#include <data/locale.hpp>
|
||||||
#include <data/installer.hpp>
|
#include <data/installer.hpp>
|
||||||
#include <data/format/formats.hpp>
|
#include <data/format/formats.hpp>
|
||||||
|
#include <data/font.hpp>
|
||||||
#include <cli/cli_main.hpp>
|
#include <cli/cli_main.hpp>
|
||||||
#include <cli/text_io_handler.hpp>
|
#include <cli/text_io_handler.hpp>
|
||||||
#include <gui/welcome_window.hpp>
|
#include <gui/welcome_window.hpp>
|
||||||
@@ -86,6 +87,7 @@ int MSE::OnRun() {
|
|||||||
// Platform friendly appname
|
// Platform friendly appname
|
||||||
SetAppName(_("magicseteditor"));
|
SetAppName(_("magicseteditor"));
|
||||||
#endif
|
#endif
|
||||||
|
Font::PreloadResourceFonts();
|
||||||
wxInitAllImageHandlers();
|
wxInitAllImageHandlers();
|
||||||
wxFileSystem::AddHandler(new wxInternetFSHandler); // needed for update checker
|
wxFileSystem::AddHandler(new wxInternetFSHandler); // needed for update checker
|
||||||
wxSocketBase::Initialize();
|
wxSocketBase::Initialize();
|
||||||
|
|||||||
Reference in New Issue
Block a user