"""FontForge script: make an OpenType mathbb-one with the 1 at U+1D7D9.

Usage: fontforge -lang=py -script build_otf.py mathbb-one10.pfb OUT.otf

For unicode-math users who want only this glyph from mathbb-one:
  \\setmathfont[range="1D7D9]{mathbb-one.otf}
The 1 is also kept at U+0031 so the font works as a plain text font.
"""
import sys

import fontforge

src, out = sys.argv[1:3]
font = fontforge.open(src)
font.encoding = "UnicodeFull"
font.fontname = "MathbbOne"
font.familyname = "MathbbOne"
font.fullname = "MathbbOne"

font.selection.select("one")
font.copy()
font.selection.select(("unicode",), 0x1D7D9)
font.paste()
glyph = font[0x1D7D9]
glyph.glyphname = "u1D7D9"
glyph.width = font["one"].width

font.generate(out)
print(f"wrote {out}")
