Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instantiator support for non-default layer sources #980

Merged
merged 4 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/fontmake/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def parse_mutually_exclusive_inputs(parser, args):
):
ufo_paths.append(filename)
else:
parser.error(f"Unknown input file extension: '{filename}'")
verbosus marked this conversation as resolved.
Show resolved Hide resolved
parser.error("Unknown input file extension: {!r}".format(filename))

count = sum(bool(p) for p in (glyphs_path, ufo_paths, designspace_path))
if count == 0:
Expand Down
2 changes: 1 addition & 1 deletion Lib/fontmake/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, msg, source_file):

def __str__(self):
trail = " -> ".join(
f"'{str(_try_relative_path(s))}'"
"{!r}".format(f"{str(_try_relative_path(s))}")
verbosus marked this conversation as resolved.
Show resolved Hide resolved
for s in reversed(self.source_trail)
if s is not None
)
Expand Down
7 changes: 5 additions & 2 deletions Lib/fontmake/font_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ def save_otfs(
warnings.warn(
"the 'subroutinize' argument is deprecated, use 'optimize_cff'",
UserWarning,
stacklevel=2,
)
if subroutinize:
optimize_cff = CFFOptimization.SUBROUTINIZE
Expand Down Expand Up @@ -909,13 +910,15 @@ def interpolate_instance_ufos(
if include is not None and not fullmatch(include, instance.name):
continue

logger.info(f'Generating instance UFO for "{instance.name}"')
logger.info("Generating instance UFO for {!r}".format(instance.name))

try:
instance.font = generator.generate_instance(instance)
except instantiator.InstantiatorError as e:
raise FontmakeError(
f"Interpolating instance '{instance.styleName}' failed.",
"Interpolating instance {!r} failed.".format(
instance.styleName
),
designspace.path,
) from e

Expand Down
13 changes: 7 additions & 6 deletions Lib/fontmake/instantiator.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def from_designspace(
glyph_mutators[glyph_name] = Variator.from_masters(items, axis_order)
except varLib.errors.VarLibError as e:
raise InstantiatorError(
f"Cannot set up glyph '{glyph_name}' for interpolation: {e}'"
f"Cannot set up glyph {glyph_name} for interpolation: {e}'"
verbosus marked this conversation as resolved.
Show resolved Hide resolved
) from e
glyph_name_to_unicodes[glyph_name] = default_font[glyph_name].unicodes

Expand Down Expand Up @@ -396,7 +396,7 @@ def generate_instance(
# whatever reason (usually outline incompatibility)...
if glyph_name not in self.skip_export_glyphs:
raise InstantiatorError(
f"Failed to generate instance of glyph '{glyph_name}': "
f"Failed to generate instance of glyph {glyph_name}: "
verbosus marked this conversation as resolved.
Show resolved Hide resolved
f"{str(e)}. (Note: the most common cause for an error here is "
"that the glyph outlines are not point-for-point compatible or "
"have the same starting point or are in the same order in all "
Expand Down Expand Up @@ -508,9 +508,9 @@ def _error_msg_no_default(designspace: designspaceLib.DesignSpaceDocument) -> st

return (
"Can't generate UFOs from this Designspace because there is no default "
f"master source at location '{default_location}'. Check that all 'default' "
"master source at location {!r}. Check that all 'default' "
"values of all axes together point to a single actual master source. "
f"{bonus_msg}"
"{!s}".format(default_location, bonus_msg)
)


Expand Down Expand Up @@ -683,8 +683,9 @@ def swap_glyph_names(font: ufoLib2.Font, name_old: str, name_new: str):

if name_old not in font or name_new not in font:
raise InstantiatorError(
f"Cannot swap glyphs '{name_old}' and '{name_new}', as either or both are "
"missing."
"Cannot swap glyphs {!r} and {!r}, as either or both are missing".format(
name_old, name_new
)
)

# 1. Swap outlines and glyph width. Ignore lib content and other properties.
Expand Down