Skip to content

Text to vertical video in 100+ styles: AI codes each scene (HTML/SVG/WebGL), renders a 9:16 MP4 with music and English/Vietnamese voice. MCP, CLI and REST for AI agents.

1.6 KB
Raw Blame
"""Builds Be Vietnam Pro TTF files (600, 700, 800) for the draft captions, by joining LumReels' own
woff2 subsets (latin, latin-ext, vietnamese) from engine/fonts with fontTools. PIL needs one file
per face; the subsets split the letters across three.

    python fonts.py <engine/fonts> <out dir>
"""
import sys
from pathlib import Path

from fontTools.merge import Merger
from fontTools.ttLib import TTFont

NEED = "ăâđêôơưàảãáạằẳẵắặầẩẫấậèẻẽéẹềểễếệìỉĩíịòỏõóọồổỗốộờởỡớợùủũúụừửữứựỳỷỹýỵĂÂĐÊÔƠƯ"


def build(src: Path, weight: int, out: Path) -> None:
    parts = []
    for sub in ("latin", "latin-ext", "vietnamese"):
        f = TTFont(src / f"be-vietnam-pro-{sub}-{weight}-normal.woff2")
        f.flavor = None
        p = out.with_name(f"{out.stem}.{sub}.part.ttf")
        f.save(p)
        parts.append(p)
    merged = Merger().merge([str(p) for p in parts])
    merged.save(out)
    for p in parts:
        p.unlink()
    cmap = TTFont(out).getBestCmap()
    missing = [c for c in NEED + "AZaz09" if ord(c) not in cmap]
    if missing:
        raise SystemExit(f"{out.name} is missing {''.join(missing)}")


def main() -> int:
    src, dest = Path(sys.argv[1]), Path(sys.argv[2])
    dest.mkdir(parents=True, exist_ok=True)
    for w in (600, 700, 800):
        out = dest / f"BeVietnamPro-{w}.ttf"
        if not out.exists():
            build(src, w, out)
    print(f"  fonts ready: Be Vietnam Pro 600/700/800 in {dest}")
    return 0


if __name__ == "__main__":
    sys.exit(main())