Skip to content

Commit

Permalink
Merge pull request #579 from googlefonts/instantiator-copy-only-nonke…
Browse files Browse the repository at this point in the history
…rning-groups

Copy only non-kerning groups explicitly
  • Loading branch information
madig authored Sep 9, 2019
2 parents cced5c5 + 30f21d9 commit a552937
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
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

0 comments on commit a552937

Please sign in to comment.