tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

math-text.py (1450B)


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