initial commit
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
"""Generate original, deliberately wide glyphs for real font-swap layout tests."""
|
||||
from pathlib import Path
|
||||
import hashlib
|
||||
import json
|
||||
from fontTools.fontBuilder import FontBuilder
|
||||
from fontTools.pens.ttGlyphPen import TTGlyphPen
|
||||
font = FontBuilder(1000, isTTF=True)
|
||||
chars = list(range(32, 127))
|
||||
glyphs = ['.notdef'] + [f'u{x:04X}' for x in chars]
|
||||
font.setupGlyphOrder(glyphs)
|
||||
font.setupCharacterMap(dict(zip(chars, glyphs[1:])))
|
||||
shapes = {}
|
||||
for name in glyphs:
|
||||
pen = TTGlyphPen(None)
|
||||
if name != 'u0020':
|
||||
pen.moveTo((80, 0)); pen.lineTo((80, 700)); pen.lineTo((1300, 700)); pen.lineTo((1300, 0)); pen.closePath()
|
||||
shapes[name] = pen.glyph()
|
||||
font.setupGlyf(shapes)
|
||||
font.setupHorizontalMetrics({name: (1400, 0) for name in glyphs})
|
||||
font.setupHorizontalHeader(ascent=800, descent=-200)
|
||||
font.setupNameTable({'familyName':'DocView Layout Test', 'styleName':'Regular', 'uniqueFontIdentifier':'DocView Layout Test 1', 'fullName':'DocView Layout Test', 'psName':'DocViewLayoutTest'})
|
||||
font.setupOS2(sTypoAscender=800, sTypoDescender=-200, usWinAscent=800, usWinDescent=200)
|
||||
font.setupPost()
|
||||
font.setupMaxp()
|
||||
font.font['head'].created = font.font['head'].modified = 2082844800
|
||||
font.font.recalcTimestamp = False
|
||||
path = Path(__file__).with_name('late-layout.ttf')
|
||||
font.save(path)
|
||||
path.with_suffix('.json').write_text(json.dumps({
|
||||
'file': path.name, 'sha256': hashlib.sha256(path.read_bytes()).hexdigest(),
|
||||
'generator': Path(__file__).name, 'purpose': 'Original wide rectangle glyphs for font-swap layout tests',
|
||||
}, indent=2) + '\n')
|
||||
Reference in New Issue
Block a user