-
Notifications
You must be signed in to change notification settings - Fork 51
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
Allow brace layers with the same coordinates to have different associatedMasterId #956
Draft
belluzj
wants to merge
3
commits into
main
Choose a base branch
from
fix-brace-layer-in-multiple-masters
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,40 +166,49 @@ def _to_designspace_source_layer(self): | |
for key, master_ids in layer_to_master_ids.items(): | ||
brace_coordinates = list(key[1]) | ||
layer_name = key[0] | ||
for master_id in master_ids: | ||
# ... as they may need to be filled up with the values of the associated | ||
# master. | ||
master = self._sources[master_id] | ||
master_coordinates = brace_coordinates | ||
if len(master_coordinates) < len(designspace.axes): | ||
master_locations = [master.location[a.name] for a in designspace.axes] | ||
master_coordinates = ( | ||
brace_coordinates + master_locations[len(brace_coordinates) :] | ||
) | ||
elif len(master_coordinates) > len(designspace.axes): | ||
logger.warning( | ||
"Glyph(s) %s, brace layer '%s' defines more locations than " | ||
"there are design axes.", | ||
layer_to_glyph_names[key], | ||
layer_name, | ||
) | ||
|
||
# If we have more locations than axes, ignore the extra locations. | ||
layer_coordinates_mapping = collections.OrderedDict( | ||
(axis.name, location) | ||
for axis, location in zip(designspace.axes, master_coordinates) | ||
# In a designspace, we can't create the brace layers with the same | ||
# location under different UFOs because that would lead to several | ||
# <source> elements with the same location. Instead we'll pick the first | ||
# (after sorting) master and stick all the brace layers with the same | ||
# key = location there. | ||
# Redirect other masters who have brace layers at the same location to | ||
# the "chosen" one. | ||
master_id = sorted(master_ids)[0] | ||
for other_master_id in master_ids: | ||
self._where_to_put_brace_layers[key, other_master_id] = master_id | ||
# ... as they may need to be filled up with the values of the | ||
# associated master. | ||
master = self._sources[master_id] | ||
Comment on lines
+179
to
+181
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are you sure you're filling up the values from the actually associated master and not from the first one that you picked when multiple ones are available? |
||
master_coordinates = brace_coordinates | ||
if len(master_coordinates) < len(designspace.axes): | ||
master_locations = [master.location[a.name] for a in designspace.axes] | ||
master_coordinates = ( | ||
brace_coordinates + master_locations[len(brace_coordinates) :] | ||
) | ||
elif len(master_coordinates) > len(designspace.axes): | ||
logger.warning( | ||
"Glyph(s) %s, brace layer '%s' defines more locations than " | ||
"there are design axes.", | ||
layer_to_glyph_names[key], | ||
layer_name, | ||
) | ||
|
||
s = fontTools.designspaceLib.SourceDescriptor() | ||
s.filename = master.filename | ||
s.font = master.font | ||
s.layerName = layer_name | ||
s.name = f"{master.name} {layer_name}" | ||
s.location = layer_coordinates_mapping | ||
|
||
# We collect all generated SourceDescriptors first, grouped by the masters | ||
# they belong to, so we can insert them in a defined order in the next step. | ||
layers_to_insert[master_id].append(s) | ||
# If we have more locations than axes, ignore the extra locations. | ||
layer_coordinates_mapping = collections.OrderedDict( | ||
(axis.name, location) | ||
for axis, location in zip(designspace.axes, master_coordinates) | ||
) | ||
|
||
s = fontTools.designspaceLib.SourceDescriptor() | ||
s.filename = master.filename | ||
s.font = master.font | ||
s.layerName = layer_name | ||
s.name = f"{master.name} {layer_name}" | ||
s.location = layer_coordinates_mapping | ||
|
||
# We collect all generated SourceDescriptors first, grouped by the masters | ||
# they belong to, so we can insert them in a defined order in the next step. | ||
layers_to_insert[master_id].append(s) | ||
|
||
# Splice brace layers into the appropriate location after their master. | ||
for master_id, brace_layers in layers_to_insert.items(): | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like you are doing this twice (also in builder/builders.py:150-152)? why?