mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-19 05:51:05 +01:00
Instancing a CFF2 font with only empty outlines leaves the head bounds accumulator at its inverted initialization sentinels. These are then serialized as xMin=yMin=32767 and xMax=yMax=-32767. Reset an empty accumulator to zero after collecting CFF2 extents. This also provides a valid FontBBox if the instance is downgraded to CFF1. Add a reproducible synthetic font and an API regression that fails before the fix. The regression also checks preservation of the empty glyph's advance and bearing. The complete Meson suite passes: 272 tests passed, one skipped. Assisted-by: Codex <noreply@openai.com>
23 lines
943 B
Python
23 lines
943 B
Python
#!/usr/bin/env python3
|
|
"""Generate the empty-outline CFF2 instancing regression font (fontTools)."""
|
|
from pathlib import Path
|
|
|
|
from fontTools.fontBuilder import FontBuilder
|
|
from fontTools.misc.psCharStrings import T2CharString
|
|
|
|
builder = FontBuilder(1000, isTTF=False)
|
|
builder.font.recalcBBoxes = False
|
|
builder.font.recalcTimestamp = False
|
|
builder.font["head"].created = builder.font["head"].modified = 2082844800
|
|
names = [".notdef", "space"]
|
|
builder.setupGlyphOrder(names)
|
|
builder.setupCharacterMap({32: "space"})
|
|
builder.setupHorizontalMetrics({name: (500, 50) for name in names})
|
|
builder.setupHorizontalHeader(ascent=800, descent=-200)
|
|
builder.setupNameTable({"familyName": "Empty CFF2", "styleName": "Regular"})
|
|
builder.setupOS2()
|
|
builder.setupPost()
|
|
builder.setupFvar([("wght", 0, 0, 1, "Weight")], [])
|
|
builder.setupCFF2({name: T2CharString(program=[]) for name in names})
|
|
builder.save(Path(__file__).parent / "fonts" / "cff2-empty.otf")
|