Files
workinf_Blender_Wasm/web/tests/fixtures/font-main-snapshots.py
mes123456 f3e21c6b98
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
chore: checkpoint web Blender migration source, tools and docs
Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer,
web workflow engine and protocol, tooling, docs and task records.
Large generated evidence, user-testing archives, build snapshots and
imported test assets remain untracked.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-10 11:18:01 +08:00

28 lines
1.4 KiB
Python

"""Read font layout and packed font links from saved native Main artifacts."""
import hashlib
import json
from pathlib import Path
import sys
import bpy
directory = Path(sys.argv[sys.argv.index("--") + 1])
result = {}
for blend in sorted(directory.glob("*.blend")):
bpy.ops.wm.open_mainfile(filepath=str(blend), load_ui=False)
texts = []
for obj in sorted(bpy.data.objects, key=lambda value: value.name):
if obj.type != "FONT":
continue
curve = obj.data
texts.append({
"object": obj.name, "data": curve.name, "body": curve.body,
"boxes": [{"x": box.x, "y": box.y, "width": box.width, "height": box.height} for box in curve.text_boxes],
"characters": [{"kern": char.kerning, "material": char.material_index, "bold": char.use_bold, "italic": char.use_italic, "underline": char.use_underline} for char in curve.body_format],
"links": {name: getattr(curve, name).name if getattr(curve, name) else None for name in ("font", "font_bold", "font_italic", "font_bold_italic")},
})
fonts = [{"name": font.name, "packedSha256": hashlib.sha256(bytes(font.packed_file.data)).hexdigest() if font.packed_file else None} for font in sorted(bpy.data.fonts, key=lambda value: value.name)]
result[blend.stem] = {"texts": texts, "fonts": fonts}
(directory / "native-font-snapshots.json").write_text(json.dumps(result, sort_keys=True, separators=(",", ":")), encoding="utf-8")