Skip to content

Commit

Permalink
Merge pull request #60 from googlefonts/add-gasp-flag
Browse files Browse the repository at this point in the history
Add flag to add minimal gasp table
  • Loading branch information
justvanrossum authored Oct 21, 2024
2 parents f62b3b6 + 279b262 commit 92f23ef
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/fontra_compile/compile_fontmake_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class CompileFontMakeAction:
destination: str
options: dict[str, str] = field(default_factory=dict)
setOverlapSimpleFlag: bool = False
addMinimalGaspTable: bool = False
ufoTempDir: str | None = None
input: ReadableFontBackend | None = field(init=False, default=None)

Expand Down Expand Up @@ -81,6 +82,9 @@ async def process(
addInstances(sourcePath)
addGlyphOrder(sourcePath)

if self.addMinimalGaspTable:
addMinimalGaspTable(sourcePath)

extraArguments = []
for option, value in self.options.items():
extraArguments.append(f"--{option}")
Expand Down Expand Up @@ -176,3 +180,20 @@ def addGlyphOrder(designspacePath):
glyphSet = ufo.getGlyphSet()
lib["public.glyphOrder"] = sorted(glyphSet.keys(), key=_glyphSortKeyFunc)
ufo.writeLib(lib)


class UFOFontInfo:
pass


def addMinimalGaspTable(designspacePath):
backend = getFileSystemBackend(designspacePath)
dsDoc = backend.dsDoc
defaultSource = dsDoc.findDefault()
ufo = UFOReaderWriter(defaultSource.path)
fontInfo = UFOFontInfo()
ufo.readInfo(fontInfo)
fontInfo.openTypeGaspRangeRecords = [
{"rangeMaxPPEM": 0xFFFF, "rangeGaspBehavior": [0, 1, 2, 3]}
]
ufo.writeInfo(fontInfo)
4 changes: 4 additions & 0 deletions tests/data/MutatorSans-fontmake.ttx
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,10 @@
</extraNames>
</post>

<gasp>
<gaspRange rangeMaxPPEM="65535" rangeGaspBehavior="15"/>
</gasp>

<HVAR>
<Version value="0x00010000"/>
<VarStore Format="1">
Expand Down
1 change: 1 addition & 0 deletions tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ async def processGlyph(self, glyph: VariableGlyph) -> VariableGlyph:
options:
flatten-components: # no value
destination: "output-fontmake.ttf"
addMinimalGaspTable: true
""",
"MutatorSans-fontmake.ttx",
),
Expand Down

0 comments on commit 92f23ef

Please sign in to comment.