feat: font generation from ttf (#882)

* chore: add file variant of json fonts

* chore: add stb dependency

* feat: generate fonts from ttf files

* chore: add option to add yOffset to file font

* chore: dynamically adjust generated font bitmap size

* fix: printable characters should respect ISO-8859-1 control characters

* chore: do not write missing glyphs into the bitmap

* chore: remove test texture conversion

* chore: adjust font compiler for iw3,iw4,iw5,t4,t5

* chore: add possibility to fill color channels when converting

* fix: games other than t6 use rgba for fonts

* fix: make sure no mipmaps are set on loaddef

* fix: t4 and iw3 use dimensions in image loaddef

* chore: also include optional glyphs in fonts
This commit is contained in:
Jan Laupetin
2026-07-08 23:35:58 +02:00
committed by GitHub
parent c385f50a0e
commit 0874f0c36f
21 changed files with 724 additions and 30 deletions
+5 -2
View File
@@ -238,7 +238,10 @@ namespace
}
const auto jFont = jRoot.get<JsonFont>();
if (CreateFontFromJson(jFont, *font, registration, context))
if (!std::holds_alternative<JsonCompiledFont>(jFont.font))
return AssetCreationResult::NoAction();
if (CreateFontFromJson(std::get<JsonCompiledFont>(jFont.font), *font, registration, context))
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
}
catch (const json::exception& e)
@@ -250,7 +253,7 @@ namespace
}
private:
bool CreateFontFromJson(const JsonFont& jFont, Font_s& font, AssetRegistration<AssetFont>& registration, AssetCreationContext& context) const
bool CreateFontFromJson(const JsonCompiledFont& jFont, Font_s& font, AssetRegistration<AssetFont>& registration, AssetCreationContext& context) const
{
font.pixelHeight = static_cast<decltype(Font_s::pixelHeight)>(jFont.pixelHeight);