Skip to content

Commit

Permalink
Generalize helper func, because who knows
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Jul 13, 2024
1 parent ed34d8c commit f08bf1e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/fontra_compile/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,9 @@ async def buildFont(self) -> TTFont:

builder.setupHorizontalHeader()
builder.setupHorizontalMetrics(
addLSB(
getGlyphInfoAttributes(self.glyphInfos, "leftSideBearing"),
dictZip(
getGlyphInfoAttributes(self.glyphInfos, "xAdvance"),
getGlyphInfoAttributes(self.glyphInfos, "leftSideBearing"),
)
)
hvarTable = self.buildHVAR(axisTags)
Expand Down Expand Up @@ -815,13 +815,11 @@ def prepareCFFVarData(charStrings, charStringSupports):
return varDataList, regionList


def addLSB(
leftSideBearings: dict[str, int], metrics: dict[str, int]
) -> dict[str, tuple[int, int]]:
return {
glyphName: (xAdvance, leftSideBearings.get(glyphName, 0))
for glyphName, xAdvance in metrics.items()
}
def dictZip(*dicts: dict) -> dict:
keys = dicts[0].keys()
if not all(keys == d.keys() for d in dicts[1:]):
raise ValueError("all input dicts must have the same set of keys")
return {key: tuple(d[key] for d in dicts) for key in keys}


def applyAxisMapToAxisValues(axis) -> tuple[float, float, float]:
Expand Down

0 comments on commit f08bf1e

Please sign in to comment.