[ttLib.removeOverlaps] Force calling new arguments by name

This commit is contained in:
Khaled Hosny 2024-05-25 19:08:18 +03:00
parent 525ab7733a
commit 246bede217

View File

@ -104,6 +104,7 @@ def _round_path(
def _simplify( def _simplify(
path: pathops.Path, path: pathops.Path,
debugGlyphName: str, debugGlyphName: str,
*,
round: Callable[[float], float] = otRound, round: Callable[[float], float] = otRound,
) -> pathops.Path: ) -> pathops.Path:
# skia-pathops has a bug where it sometimes fails to simplify paths when there # skia-pathops has a bug where it sometimes fails to simplify paths when there
@ -179,6 +180,7 @@ def removeTTGlyphOverlaps(
def _remove_glyf_overlaps( def _remove_glyf_overlaps(
*,
font: ttFont.TTFont, font: ttFont.TTFont,
glyphNames: Iterable[str], glyphNames: Iterable[str],
glyphSet: _TTGlyphMapping, glyphSet: _TTGlyphMapping,
@ -218,6 +220,7 @@ def _remove_glyf_overlaps(
def _remove_charstring_overlaps( def _remove_charstring_overlaps(
*,
glyphName: str, glyphName: str,
glyphSet: _TTGlyphMapping, glyphSet: _TTGlyphMapping,
cffFontSet: CFFFontSet, cffFontSet: CFFFontSet,
@ -237,6 +240,7 @@ def _remove_charstring_overlaps(
def _remove_cff_overlaps( def _remove_cff_overlaps(
*,
font: ttFont.TTFont, font: ttFont.TTFont,
glyphNames: Iterable[str], glyphNames: Iterable[str],
glyphSet: _TTGlyphMapping, glyphSet: _TTGlyphMapping,
@ -249,9 +253,9 @@ def _remove_cff_overlaps(
for glyphName in glyphNames: for glyphName in glyphNames:
try: try:
if _remove_charstring_overlaps( if _remove_charstring_overlaps(
glyphName, glyphName=glyphName,
glyphSet, glyphSet=glyphSet,
cffFontSet, cffFontSet=cffFontSet,
): ):
modified.add(glyphName) modified.add(glyphName)
except RemoveOverlapsError: except RemoveOverlapsError:
@ -277,6 +281,7 @@ def removeOverlaps(
glyphNames: Optional[Iterable[str]] = None, glyphNames: Optional[Iterable[str]] = None,
removeHinting: bool = True, removeHinting: bool = True,
ignoreErrors: bool = False, ignoreErrors: bool = False,
*,
removeUnusedSubroutines: bool = True, removeUnusedSubroutines: bool = True,
) -> None: ) -> None:
"""Simplify glyphs in TTFont by merging overlapping contours. """Simplify glyphs in TTFont by merging overlapping contours.
@ -314,16 +319,22 @@ def removeOverlaps(
glyphSet = font.getGlyphSet() glyphSet = font.getGlyphSet()
if "glyf" in font: if "glyf" in font:
_remove_glyf_overlaps(font, glyphNames, glyphSet, removeHinting, ignoreErrors) _remove_glyf_overlaps(
font=font,
glyphNames=glyphNames,
glyphSet=glyphSet,
removeHinting=removeHinting,
ignoreErrors=ignoreErrors,
)
if "CFF " in font: if "CFF " in font:
_remove_cff_overlaps( _remove_cff_overlaps(
font, font=font,
glyphNames, glyphNames=glyphNames,
glyphSet, glyphSet=glyphSet,
removeHinting, removeHinting=removeHinting,
ignoreErrors, ignoreErrors=ignoreErrors,
removeUnusedSubroutines, removeUnusedSubroutines=removeUnusedSubroutines,
) )