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

Bracket layer generation: update components to reference bracket layer base glyphs #535

Closed
punchcutter opened this issue Jul 23, 2019 · 12 comments

Comments

@punchcutter
Copy link

punchcutter commented Jul 23, 2019

If a bracket layer is made up of components the components also need to be updated to point to the newly created layer. For example we have lowercase "a" with bracket at [150]. This creates "a.BRACKET.150", but "aogonek" also has [150] so "aogonek.BRACKET.150" should be updated so that the "a" component points to "a.BRACKET.150". I did this real quick and it seems fine, but I don't have time to mess with it more right now...

        # Finally, copy bracket layers to their own glyphs.
        bracket_layer_names = []
        for location, layers in bracket_layer_map.items():
            for layer in layers:
                ufo_font = self._sources[
                    layer.associatedMasterId or layer.layerId
                ].font.layers.defaultLayer
                ufo_glyph_name = "{glyph_name}.BRACKET.{location}".format(
                    glyph_name=layer.parent.name, location=location
                )
                bracket_layer_names.append(ufo_glyph_name)
                ufo_glyph = ufo_font.newGlyph(ufo_glyph_name)
                self.to_ufo_glyph(ufo_glyph, layer, layer.parent)
                ufo_glyph.unicodes = []  # Avoid cmap interference
                ufo_glyph.lib[GLYPHLIB_PREFIX + "_originalLayerName"] = layer.name

        for location, layers in bracket_layer_map.items():
            for layer in layers:
                ufo_font = self._sources[
                    layer.associatedMasterId or layer.layerId
                ].font.layers.defaultLayer
                for bracket_layer_name in bracket_layer_names:
                    for comp in ufo_font[bracket_layer_name].components:
                        comp_glyph_name = "{glyph_name}.BRACKET.{location}".format(
                        glyph_name=comp._baseGlyph, location=location)
                        if comp_glyph_name in bracket_layer_names:
                            comp.baseGlyph = comp_glyph_name
@anthrotype
Copy link
Member

I guess this is the same issue that @madig reported in #468 (comment) ?

@anthrotype
Copy link
Member

@punchcutter by the way, does Glyphs.app itself support composite glyphs with bracket layers? I think it doesn't yet, see https://forum.glyphsapp.com/t/the-bracket-layer-does-not-work-with-the-component-in-vb-font/11577/6

@punchcutter
Copy link
Author

I didn’t even think about the automation of all this. I explicitly added bracket layers to the composites and Glyphs then generated the correct thing.

@anthrotype
Copy link
Member

I would love to see an example. Can you share the glyphs file with us?

@punchcutter
Copy link
Author

I can’t share this one, but it’s pretty simple. Just 4 masters with a bracket layer somewhere in the middle where the “a” has a different tail. That all works fine from Glyphs including kerning so that the kerning from “a” gets applied to the new “a.BRACKET.???” layer as well.

@anthrotype
Copy link
Member

anthrotype commented Jul 23, 2019

yeah, I am afraid I'd need to look at a concrete example to understand what is (supposed to be) going on, as the details of this can get complicated.

you said you "added bracket layers to the composites": did you simply duplicate the default layer and named it the same as the bracket layer in the parent glyph, without other changes?

@punchcutter
Copy link
Author

Exactly, I duplicated the layers and gave the same bracket as the parent glyph. So the "a" and all composites have this:

brackets

Ah, I was mistaken about what Glyphs does. I just checked again and in Glyphs it looks like it's fine when clicking on the bracket layers, but exporting doesn't do the swap.

@anthrotype
Copy link
Member

anthrotype commented Jul 23, 2019

So you confirm it doesn't work in Glyphs.app either.

It feels to me it's a bit redundant to require the user duplicating the bracket layers in all the composites where the bracketed base component is referenced. GlyphsLib should be able to determine what these are and automatically do the right thing, i.e. use the replaced component in the new composite glyph that is substituted whenever the glyph used as component is.

Now.. things can get messier when a composite glyph references multiple components that are swapped via bracket layers at different thresholds.

I think some of the confusion around this is that Glyphs sees these as "layers" within the same glyph, whereas GSUB FeatureVariations (like Designspace rules) substitute whole glyphs.

@punchcutter
Copy link
Author

Yes, I think it's redundant to duplicate the bracket layers on the composites, but at the moment doing so got glyphsLib to build those glyphs and that's one thing I wanted to see happen.

@schriftgestalt
Copy link
Collaborator

This is on my list for some time.

@madig
Copy link
Collaborator

madig commented Jul 24, 2019

@schriftgestalt Have you considered supporting bracket layers as external glyphs, i.e. dollar and dollar.rvrn123,456 or something? That would simplify the mapping to how OpenType (and UFO+Designspace) works.

@anthrotype
Copy link
Member

this was fixed by #538

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants