css-units.py (617B)
1 #!/usr/bin/env python3 2 3 from utils import mathfont 4 5 # Create a font with glyphs for all the font-relative CSS units 6 # (so that they all have length 1em). 7 # See https://drafts.csswg.org/css-values-4/#lengths 8 f = mathfont.create("css-units", 9 "Copyright (c) 2025 Igalia S.L.") 10 11 mathfont.drawRectangleGlyph(f.createChar(ord("x")), mathfont.em, mathfont.em // 2) # ex = 0.5em 12 mathfont.createSquareGlyph(f, ord("O")) # cap = 1em 13 mathfont.createSquareGlyph(f, ord("0")) # ch = 1em 14 mathfont.createSquareGlyph(f, ord("水")) # ic = 1em 15 16 assert f.capHeight == 1000 17 assert f.xHeight == 500 18 19 mathfont.save(f)