1#!/usr/bin/python 2 3from __future__ import print_function 4import fontforge 5 6font = fontforge.font() 7font.em = 1000 8lineHeight = 5000 9name = "math-text" 10font.fontname = name 11font.familyname = name 12font.fullname = name 13font.copyright = "Copyright (c) 2019 Igalia" 14 15glyph = font.createChar(ord(" "), "space") 16glyph.width = 1000 17glyph = font.createChar(ord("A")) 18pen = glyph.glyphPen() 19pen.moveTo(0, -500) 20pen.lineTo(0, 500) 21pen.lineTo(1000, 500) 22pen.lineTo(1000, -500) 23pen.closePath(); 24 25glyph = font.createChar(ord("B")) 26pen = glyph.glyphPen() 27pen.moveTo(0, 0) 28pen.lineTo(0, 1000) 29pen.lineTo(1000, 1000) 30pen.lineTo(1000, 0) 31pen.closePath(); 32 33glyph = font.createChar(ord("C")) 34pen = glyph.glyphPen() 35pen.moveTo(0, -1000) 36pen.lineTo(0, 0) 37pen.lineTo(1000, 0) 38pen.lineTo(1000, -1000) 39pen.closePath(); 40 41font.os2_typoascent_add = False 42font.os2_typoascent = lineHeight / 2 43font.os2_typodescent_add = False 44font.os2_typodescent = -lineHeight / 2 45font.os2_typolinegap = 0 46font.hhea_ascent = lineHeight / 2 47font.hhea_ascent_add = False 48font.hhea_descent = -lineHeight / 2 49font.hhea_descent_add = False 50font.hhea_linegap = 0 51font.os2_winascent = lineHeight / 2 52font.os2_winascent_add = False 53font.os2_windescent = lineHeight / 2 54font.os2_windescent_add = False 55 56font.os2_use_typo_metrics = True 57 58path = "../../fonts/math/math-text.woff" 59print("Generating %s..." % path, end="") 60font.generate(path) 61if font.validate() == 0: 62 print(" done.") 63else: 64 print(" validation error!") 65 exit(1) 66