make the ttf sample pass FontValidator
I used FontValidator to validate the ttf font. I made some changes to address the errors. Now it passes, but still trying to preview the font in windows raises the same error.
This commit is contained in:
parent
56c1a32744
commit
f51c1145df
@ -31,6 +31,7 @@ Here is how to build a minimal TTF:
|
|||||||
from fontTools.fontBuilder import FontBuilder
|
from fontTools.fontBuilder import FontBuilder
|
||||||
from fontTools.pens.ttGlyphPen import TTGlyphPen
|
from fontTools.pens.ttGlyphPen import TTGlyphPen
|
||||||
|
|
||||||
|
|
||||||
def drawTestGlyph(pen):
|
def drawTestGlyph(pen):
|
||||||
pen.moveTo((100, 100))
|
pen.moveTo((100, 100))
|
||||||
pen.lineTo((100, 1000))
|
pen.lineTo((100, 1000))
|
||||||
@ -38,35 +39,39 @@ def drawTestGlyph(pen):
|
|||||||
pen.lineTo((500, 100))
|
pen.lineTo((500, 100))
|
||||||
pen.closePath()
|
pen.closePath()
|
||||||
|
|
||||||
fb = FontBuilder(1024, isTTF=True)
|
|
||||||
fb.setupGlyphOrder([".notdef", ".null", "A", "a"])
|
|
||||||
fb.setupCharacterMap({65: "A", 97: "a"})
|
|
||||||
|
|
||||||
advanceWidths = {".notdef": 600, "A": 600, "a": 600, ".null": 600}
|
fb = FontBuilder(1024, isTTF=True)
|
||||||
|
fb.setupGlyphOrder([".notdef", ".null", ".space", "A", "a"])
|
||||||
|
fb.setupCharacterMap({32: ".space", 65: "A", 97: "a"})
|
||||||
|
advanceWidths = {".notdef": 600, ".space": 500, "A": 600, "a": 600, ".null": 0}
|
||||||
|
|
||||||
familyName = "HelloTestFont"
|
familyName = "HelloTestFont"
|
||||||
styleName = "TotallyNormal"
|
styleName = "TotallyNormal"
|
||||||
nameStrings = dict(familyName=dict(en="HelloTestFont", nl="HalloTestFont"),
|
version = "0.1"
|
||||||
styleName=dict(en="TotallyNormal", nl="TotaalNormaal"))
|
|
||||||
nameStrings['psName'] = familyName + "-" + styleName
|
nameStrings = dict(
|
||||||
|
familyName=dict(en=familyName, nl="HalloTestFont"),
|
||||||
|
styleName=dict(en=styleName, nl="TotaalNormaal"),
|
||||||
|
uniqueFontIdentifier="fontBuilder: " + familyName + "." + styleName,
|
||||||
|
fullName=familyName + "-" + styleName,
|
||||||
|
psName=familyName + "-" + styleName,
|
||||||
|
version="Version " + version,
|
||||||
|
)
|
||||||
|
|
||||||
pen = TTGlyphPen(None)
|
pen = TTGlyphPen(None)
|
||||||
drawTestGlyph(pen)
|
drawTestGlyph(pen)
|
||||||
glyph = pen.glyph()
|
glyph = pen.glyph()
|
||||||
glyphs = {".notdef": glyph, "A": glyph, "a": glyph, ".null": glyph}
|
glyphs = {".notdef": glyph, ".space": glyph, "A": glyph, "a": glyph, ".null": glyph}
|
||||||
fb.setupGlyf(glyphs)
|
fb.setupGlyf(glyphs)
|
||||||
|
|
||||||
metrics = {}
|
metrics = {}
|
||||||
glyphTable = fb.font["glyf"]
|
glyphTable = fb.font["glyf"]
|
||||||
for gn, advanceWidth in advanceWidths.items():
|
for gn, advanceWidth in advanceWidths.items():
|
||||||
metrics[gn] = (advanceWidth, glyphTable[gn].xMin)
|
metrics[gn] = (advanceWidth, glyphTable[gn].xMin)
|
||||||
fb.setupHorizontalMetrics(metrics)
|
fb.setupHorizontalMetrics(metrics)
|
||||||
|
fb.setupHorizontalHeader(ascent=824, descent=-200)
|
||||||
fb.setupHorizontalHeader(ascent=824, descent=200)
|
|
||||||
fb.setupNameTable(nameStrings)
|
fb.setupNameTable(nameStrings)
|
||||||
fb.setupOS2()
|
fb.setupOS2(sTypoAscender=824)
|
||||||
fb.setupPost()
|
fb.setupPost()
|
||||||
|
|
||||||
fb.save("test.ttf")
|
fb.save("test.ttf")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user