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:
parent
eeb6cab4c4
commit
547e1476bb
8 changed files with 270 additions and 138 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue