prep work (everything but fontengine)
This commit is contained in:
parent
12d861d295
commit
10623d003f
@ -266,7 +266,7 @@ The main Lua script. Running this script should register everything it
|
||||
wants to register. Subsequent execution depends on Luanti calling the
|
||||
registered callbacks.
|
||||
|
||||
### `textures`, `sounds`, `media`, `models`, `locale`
|
||||
### `textures`, `sounds`, `media`, `models`, `locale`, `fonts`
|
||||
|
||||
Media files (textures, sounds, whatever) that will be transferred to the
|
||||
client and will be available for use by the mod and translation files for
|
||||
@ -279,6 +279,7 @@ Accepted formats are:
|
||||
images: .png, .jpg, .tga
|
||||
sounds: .ogg vorbis
|
||||
models: .x, .b3d, .obj, (since version 5.10:) .gltf, .glb
|
||||
fonts: .ttf (since version 5.?, see notes below) <!-- TODO before merge -->
|
||||
|
||||
Other formats won't be sent to the client (e.g. you can store .blend files
|
||||
in a folder for convenience, without the risk that such files are transferred)
|
||||
@ -343,6 +344,22 @@ For example, if your model used an emissive material,
|
||||
you should expect that a future version of Luanti may respect this,
|
||||
and thus cause your model to render differently there.
|
||||
|
||||
#### Custom fonts
|
||||
|
||||
You can supply custom fonts in TrueType Font (TTF) format.
|
||||
In the future, having multiple custom fonts and the ability to switch between them is planned,
|
||||
but for now this feature is limited to the ability to override Luanti's default fonts via mods.
|
||||
It is recommended that this only be used by game mods. The names are self-explanatory:
|
||||
|
||||
* `regular.ttf`
|
||||
* `bold.ttf`
|
||||
* `italic.ttf`
|
||||
* `bold_italic.ttf`
|
||||
* `mono.ttf`
|
||||
* `mono_bold.ttf`
|
||||
* `mono_bold_italic.ttf`
|
||||
* `fallback.ttf` <!-- TODO is this a good idea? -->
|
||||
|
||||
Naming conventions
|
||||
------------------
|
||||
|
||||
|
@ -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"
|
||||
@ -360,6 +361,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,
|
||||
@ -833,6 +837,13 @@ bool Client::loadMedia(const std::string &data, const std::string &filename,
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *font_ext[] = {".ttf", 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;
|
||||
|
@ -2541,6 +2541,9 @@ bool Server::addMediaFile(const std::string &filename,
|
||||
".x", ".b3d", ".obj", ".gltf", ".glb",
|
||||
// Translation file formats
|
||||
".tr", ".po", ".mo",
|
||||
// Fonts
|
||||
// TODO throw a warning and ignore file if name is not one of the few recognized ones?
|
||||
".ttf",
|
||||
NULL
|
||||
};
|
||||
if (removeStringEnd(filename, supported_ext).empty()) {
|
||||
|
@ -87,5 +87,6 @@ void ServerModManager::getModsMediaPaths(std::vector<std::string> &paths) const
|
||||
fs::GetRecursiveDirs(paths, spec.path + DIR_DELIM + "media");
|
||||
fs::GetRecursiveDirs(paths, spec.path + DIR_DELIM + "models");
|
||||
fs::GetRecursiveDirs(paths, spec.path + DIR_DELIM + "locale");
|
||||
fs::GetRecursiveDirs(paths, spec.path + DIR_DELIM + "fonts");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user