Skip to content

Commit

Permalink
additionally support woff2
Browse files Browse the repository at this point in the history
  • Loading branch information
appgurueu committed Jan 9, 2025
1 parent 00eaa39 commit b4c9ff6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
25 changes: 14 additions & 11 deletions doc/lua_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,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.11, see notes below)
fonts: .ttf, .woff2 (since version 5.11, see notes below)

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)
Expand Down Expand Up @@ -345,18 +345,21 @@ and thus cause your model to render differently there.

#### Custom fonts

You can supply custom fonts in TrueType Font (TTF) format.
You can supply custom fonts in TrueType Font (`.ttf`) or Web Open Font Format 2 (`.woff2`) format.
The former is supported primarily for convenience. The latter is preferred due to its compression.
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`
It is recommended that this only be used by game mods to set a look and feel.

The stems (file names without extension) are self-explanatory:

* `regular`
* `bold`
* `italic`
* `bold_italic`
* `mono`
* `mono_bold`
* `mono_bold_italic`

Naming conventions
------------------
Expand Down
2 changes: 1 addition & 1 deletion src/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ bool Client::loadMedia(const std::string &data, const std::string &filename,
return true;
}

const char *font_ext[] = {".ttf", NULL};
const char *font_ext[] = {".ttf", ".woff2", NULL};
name = removeStringEnd(filename, font_ext);
if (!name.empty()) {
g_fontengine->setMediaFont(name, data);
Expand Down
2 changes: 1 addition & 1 deletion src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2544,7 +2544,7 @@ bool Server::addMediaFile(const std::string &filename,
// Translation file formats
".tr", ".po", ".mo",
// Fonts
".ttf",
".ttf", ".woff2",
NULL
};
if (removeStringEnd(filename, supported_ext).empty()) {
Expand Down

0 comments on commit b4c9ff6

Please sign in to comment.