tor-browser

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

use-typo-lineheight.py (1323B)


      1 #!/usr/bin/env python3
      2 
      3 import fontforge
      4 
      5 font = fontforge.font()
      6 font.em = 1000
      7 typoLineHeight = 2300
      8 winHeight = 5000
      9 name = "font-lineheight%d-typolineheight%d" % (winHeight, typoLineHeight)
     10 font.fontname = name
     11 font.familyname = name
     12 font.fullname = name
     13 font.copyright = "Copyright (c) 2016 MathML Association"
     14 
     15 glyph = font.createChar(ord(" "), "space")
     16 glyph.width = 1000
     17 glyph = font.createChar(ord("O"))
     18 pen = glyph.glyphPen()
     19 pen.moveTo(0, -200)
     20 pen.lineTo(0, 800)
     21 pen.lineTo(1000, 800)
     22 pen.lineTo(1000, -200)
     23 pen.closePath()
     24 
     25 font.os2_typoascent_add = False
     26 font.os2_typoascent = 800
     27 font.os2_typodescent_add = False
     28 font.os2_typodescent = -200
     29 font.os2_typolinegap = typoLineHeight - \
     30    (font.os2_typoascent - font.os2_typodescent)
     31 
     32 font.hhea_ascent = winHeight // 2
     33 font.hhea_ascent_add = False
     34 font.hhea_descent = -winHeight // 2
     35 font.hhea_descent_add = False
     36 font.hhea_linegap = 0
     37 
     38 font.os2_winascent = winHeight // 2
     39 font.os2_winascent_add = False
     40 font.os2_windescent = winHeight // 2
     41 font.os2_windescent_add = False
     42 
     43 font.os2_use_typo_metrics = True
     44 
     45 path = "../../fonts/math/lineheight%d-typolineheight%d.woff" % (
     46    winHeight, typoLineHeight)
     47 print("Generating %s..." % path, end="")
     48 font.generate(path)
     49 if font.validate() == 0:
     50    print(" done.")
     51 else:
     52    print(" validation error!")
     53    exit(1)