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

Copy only non-kerning groups explicitly #579

Merged
merged 1 commit into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 10 additions & 5 deletions Lib/fontmake/instantiator.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class Instantiator:

axis_bounds: AxisBounds # Design space!
copy_feature_text: str
copy_groups: Mapping[str, List[str]]
copy_nonkerning_groups: Mapping[str, List[str]]
copy_info: ufoLib2.objects.Info
copy_lib: Mapping[str, Any]
default_design_location: Location
Expand Down Expand Up @@ -228,7 +228,11 @@ def from_designspace(

# Construct defaults to copy over
copy_feature_text: str = default_font.features.text
copy_groups: Mapping[str, List[str]] = default_font.groups
copy_nonkerning_groups: Mapping[str, List[str]] = {
key: glyph_names
for key, glyph_names in default_font.groups.items()
if not key.startswith(("public.kern1.", "public.kern2."))
} # Kerning groups are taken care of by the kerning Variator.
copy_info: ufoLib2.objects.Info = default_font.info
copy_lib: Mapping[str, Any] = default_font.lib

Expand All @@ -241,7 +245,7 @@ def from_designspace(
return cls(
axis_bounds,
copy_feature_text,
copy_groups,
copy_nonkerning_groups,
copy_info,
copy_lib,
designspace.default.location,
Expand Down Expand Up @@ -285,8 +289,9 @@ def generate_instance(
# Info
self._generate_instance_info(instance, location_normalized, location, font)

# Groups
for key, glyph_names in self.copy_groups.items():
# Non-kerning groups. Kerning groups have been taken care of by the kerning
# instance.
for key, glyph_names in self.copy_nonkerning_groups.items():
font.groups[key] = [name for name in glyph_names]

# Features
Expand Down
14 changes: 14 additions & 0 deletions tests/data/DesignspaceTest/MyFont-Light.ufo/groups.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>nonkerning_group</key>
<array>
<string>A</string>
</array>
<key>public.kern2.asdf</key>
<array>
<string>A</string>
</array>
</dict>
</plist>
13 changes: 13 additions & 0 deletions tests/test_instantiator.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,19 @@ def test_raise_anisotropic_location(data_dir):
)


def test_copy_nonkerning_group(data_dir):
designspace = designspaceLib.DesignSpaceDocument.fromfile(
data_dir / "DesignspaceTest" / "DesignspaceTest.designspace"
)
generator = fontmake.instantiator.Instantiator.from_designspace(designspace)

instance_font = generator.generate_instance(designspace.instances[0])
assert instance_font.groups == {
"nonkerning_group": ["A"],
"public.kern2.asdf": ["A"],
}


def test_interpolation(data_dir):
designspace = designspaceLib.DesignSpaceDocument.fromfile(
data_dir / "DesignspaceTest" / "DesignspaceTest.designspace"
Expand Down