Files
ZMMO/Scripts/import_fonts.py
Mateus Rodrigues 1c06d69174 feat(ui): sistema de UI Style (tokens C++ por tema) + fontes Aurora Arcana
Camada de estilo data-driven do cliente ZMMO, portando o nucleo do projeto de referencia (Hyper) para C++ conforme ARQUITETURA.md (BP Struct proibido):

- Source/ZMMO/Data/UI: UIStyleTypes.h (enums EUI*), UIStyleTokens.h (tokens primitive/semantic/component), UIStyleRow.h (FUIStyle + FUIStyleRow). - ZMMOThemeSubsystem: GetActiveUIStyle() resolve DT_UI_Styles por ThemeId com fallback Default. - Fontes: 8 UFontFace Inline (Cinzel/Rajdhani) em Content/ZMMO/UI/Fonts + DT_UI_Styles preenchido. - ARQUITETURA.md: prefixo de widget UI_, classes base UUI*_Base (UCLASS Abstract) sem prefixo ZMMO. - Config/DefaultGame.ini: UIStyleTable apontando DT_UI_Styles. - Scripts/import_fonts.py (importador idempotente). Inclui tambem o scaffolding do modulo ZMMO ainda nao versionado (Source/ZMMO/Data, Game/UI, Content/ZMMO, uproject, Build.cs).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 21:21:32 -03:00

91 lines
3.1 KiB
Python

"""
import_fonts.py — Importa as fontes Aurora Arcana para o cliente ZMMO.
Cria (UFontFace, loading policy = Inline; .ttf embutido no .uasset):
Content/ZMMO/UI/Fonts/Cinzel/ FF_Cinzel_Regular | _SemiBold | _Bold | _ExtraBold
Content/ZMMO/UI/Fonts/Rajdhani/ FF_Rajdhani_Regular | _Medium | _SemiBold | _Bold
Source dos .ttf: Tools/Templates/Zeus_Widget/shared/assets/fonts/ (source-of-truth,
não duplicar — UFontFace importa como Inline e embute o .ttf no .uasset).
Nota: Typeface/TypefaceEntry/FontData NÃO são expostos ao Python (UE 5.7), então
a Composite Font (Font_Cinzel/Font_Rajdhani) não é criada por script. Como o
FUIStyleText usa um peso fixo por papel, o FSlateFontInfo referencia o FF_* direto.
Idempotente. Como rodar:
- Editor: console Python -> exec(open(r"f:/.../Scripts/import_fonts.py").read())
- Ou via MCP nwiro execute_python.
"""
import os
import unreal
SRC_DIR = r"f:/ZeusProject/Tools/Templates/Zeus_Widget/shared/assets/fonts"
DEST_ROOT = "/Game/ZMMO/UI/Fonts"
FAMILIES = {
"Cinzel": [
("Regular", "Cinzel-Regular.ttf"),
("SemiBold", "Cinzel-SemiBold.ttf"),
("Bold", "Cinzel-Bold.ttf"),
("ExtraBold", "Cinzel-ExtraBold.ttf"),
],
"Rajdhani": [
("Regular", "Rajdhani-Regular.ttf"),
("Medium", "Rajdhani-Medium.ttf"),
("SemiBold", "Rajdhani-SemiBold.ttf"),
("Bold", "Rajdhani-Bold.ttf"),
],
}
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
def import_font_face(ttf_path, dest_pkg_path, asset_name):
task = unreal.AssetImportTask()
task.filename = ttf_path
task.destination_path = dest_pkg_path
task.destination_name = asset_name
task.replace_existing = True
task.automated = True
task.save = True
task.factory = unreal.FontFileImportFactory()
asset_tools.import_asset_tasks([task])
full = "{}/{}".format(dest_pkg_path, asset_name)
face = unreal.load_asset(full)
if face is None:
unreal.log_error("[import_fonts] FALHOU import: {}".format(full))
return False
try:
face.set_editor_property("loading_policy", unreal.FontLoadingPolicy.INLINE)
unreal.EditorAssetLibrary.save_asset(full)
except Exception as e:
unreal.log_warning("[import_fonts] loading_policy INLINE falhou em {}: {}".format(full, e))
unreal.log_warning("[import_fonts] OK {} (class={})".format(full, type(face).__name__))
return True
def main():
unreal.log_warning("[import_fonts] === inicio ===")
ok = 0
total = 0
for family, weights in FAMILIES.items():
dest_pkg = "{}/{}".format(DEST_ROOT, family)
for weight_name, ttf in weights:
total += 1
ttf_path = os.path.join(SRC_DIR, ttf).replace("\\", "/")
if not os.path.isfile(ttf_path):
unreal.log_error("[import_fonts] .ttf nao encontrado: {}".format(ttf_path))
continue
asset_name = "FF_{}_{}".format(family, weight_name)
if import_font_face(ttf_path, dest_pkg, asset_name):
ok += 1
unreal.log_warning("[import_fonts] === fim: {}/{} faces ===".format(ok, total))
main()