GlyphsSDK icon indicating copy to clipboard operation
GlyphsSDK copied to clipboard

`needsExtraMainOutlineDrawingForActiveLayer` does not yet hide corner/cap components

Open Mark2Mark opened this issue 3 years ago • 11 comments

When needsExtraMainOutlineDrawingForActiveLayer returns NO, don’t draw:

  • [ ] The thick blue component stroke
  • [ ] "Color Layer" content (e.g. Stroke, Fill, Shadow, Gradient, etc)

Mark2Mark avatar Jan 25 '22 08:01 Mark2Mark

This still happens, and does not make sense IMO. Hiding the layer drawing should hide all things drawn on the layer.

Here an example with the hiding setting active in Variable Font Preview. You can see how everything is nicely hidden, making way for the reporter’s drawings, but the corner halos still show:

https://github.com/schriftgestalt/GlyphsSDK/assets/5824595/aea00532-6488-4296-a41e-1111593513b2

Mark2Mark avatar Mar 13 '24 11:03 Mark2Mark

any insights on this @schriftgestalt / @florianpircher?

Mark2Mark avatar Apr 10 '24 11:04 Mark2Mark

The thick blue component stroke is drawn as part of the background by the tool. A reporter only draws additional background content, so that cannot suppress the blue lines.

The same goes for the color layer drawing.

Either we add a new API for a reporter to suppress the background of the tool, or maybe needsExtraMainOutlineDrawingForActiveLayer should also control the background. @schriftgestalt?

florianpircher avatar Apr 10 '24 12:04 florianpircher

Thanks for explaining. Both options would be nice to have.

Mark2Mark avatar Apr 10 '24 16:04 Mark2Mark

I think I might have a reporter use case where I don’t want the main outline and color drawing, but the blue corner paths should stay.

To future-proof this, we could offer a new API where a reporter returns an option set like

GSDrawSkipLayerMainOutline | GSDrawSkipLayerColorContent | GSDrawSkipLayerCornerHighlight

or similar.

florianpircher avatar Apr 10 '24 20:04 florianpircher

Should the option set also offer anchors? I think currently they are hidden along with the outlines, if I’m not mistaken. Could imagine cases similar to your blue corners.

Mark2Mark avatar Apr 10 '24 20:04 Mark2Mark

It may make sense to consolidate anchors and other stuff like metrics, mark cloud, etc. into the option set. NSUInteger has 64 bits, so there should be more than enough room for any current and future options.

florianpircher avatar Apr 10 '24 20:04 florianpircher

That goes out of hand very quickly. So keep the options low. Also adding things later needs to be done in a way that we don’t need to update all code that uses this to add the new flags.

schriftgestalt avatar Apr 10 '24 20:04 schriftgestalt

The idea would be to suppress specific, small things per bit in the option set. That way, a reporter can be selective about what it needs suppressed. For common groups, we can offer named constants combining multiple small things, e.g.

GSSuppressDrawingLayerContent = GSSuppressDrawingLayerMainOutline
    | GSSuppressDrawingLayerColorContent
    | GSSuppressDrawingLayerCornerHighlight
    | ...;

Adding things later would not be an issue as we would use the higher, previously unused bits for that. Existing reporters have those bits set to 0, so they would not suppress new things unless they opt into doing so with an update.

The named groups, like GSSuppressDrawingLayerContent can get changed in a Glyphs update, so if a reporter is not selective and just wants to get rid of ”all layer content drawing“ or “all metrics drawing” or similar, those reporters would use the named option groups and be automatically updated to suppress new stuff as it is introduced by Glyphs, as long as the new stuff fits into one of the existing named groups.

florianpircher avatar Apr 10 '24 21:04 florianpircher

But if that extra bit means we do not hide certain things any more (if we e.g. discern between anchor and corner highlights), then all code that relies on hiding both needs an update. Or we need to provide enums with various levels of hiding so that we split a bit but provide the old enum with a new value that triggers both new bits. That is confusing.

schriftgestalt avatar Apr 10 '24 21:04 schriftgestalt

The old bit would become legacy. Say bit 3 hides anchors and corner highlights. Reporters use bit 3. Time passes. We now want to discern between the two. Bits 0–5 are already assigned. So bit 6 becomes anchors and bit 7 becomes corner highlights. For backwards compatibility, if bit 3 is set, we assume 6 and 7 are set.

florianpircher avatar Apr 10 '24 21:04 florianpircher