1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Allow overriding fonts via media files (#15606)

Co-authored-by: sfan5 <sfan5@live.de>
This commit is contained in:
Lars Müller 2025-01-19 20:42:40 +01:00 committed by GitHub
parent eeb6cab4c4
commit 547e1476bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 270 additions and 138 deletions

View file

@ -9,6 +9,7 @@
#include <IFileSystem.h>
#include <json/json.h>
#include "client.h"
#include "client/fontengine.h"
#include "network/clientopcodes.h"
#include "network/connection.h"
#include "network/networkpacket.h"
@ -361,6 +362,9 @@ Client::~Client()
for (auto &csp : m_sounds_client_to_server)
m_sound->freeId(csp.first);
m_sounds_client_to_server.clear();
// Go back to our mainmenu fonts
g_fontengine->clearMediaFonts();
}
void Client::connect(const Address &address, const std::string &address_name,
@ -837,6 +841,13 @@ bool Client::loadMedia(const std::string &data, const std::string &filename,
return true;
}
const char *font_ext[] = {".ttf", ".woff", NULL};
name = removeStringEnd(filename, font_ext);
if (!name.empty()) {
g_fontengine->setMediaFont(name, data);
return true;
}
errorstream << "Client: Don't know how to load file \""
<< filename << "\"" << std::endl;
return false;