Use wildcards for feature classes?

Is there a way to automatically generate my classes in the features panel using wildcards? Like for example, I needed every /A glyph inside one class so I can just A* them away. (Or is there a better way to handle this than using classes…)

Yes. You can use predicates.

You can use both the LIKE or the Regex proper MATCHES predicates.

Be careful when using just the glyph names to create classes. For example, all glyphs starting with “E” also includes “Eng” (Ŋ) and “Eth” (Ð). Similarly, “Germandbls” (ẞ) starts with a “G” but is not related to G. There are many other such issues, especially if your font includes multiple scripts.

I would assign a tag to the glyphs you want in a group and then use predicates to collect all glyphs with the same tag into a class: @SomeClass = [$["some-tag" in tags]];

I can recommend my Guten Tag plugin for quickly assigning tags to glyphs:

3 Likes

Thanks for the information @clauseggers ! Though I also understand @FlorianPircher 's concern with other characters starting in similar letters while being completely unrelated, but using the tags, while can be more intuitive than directly writing in the classes, is still an extra step than what I am trying to achieve/automate.

Is there a way to put all the /A glyphs for example, all its stylistic sets and accented glyphs easily into a class? (will ignoremarks work inside a class?)

I am afraid some manual work is required, using tags or otherwise. Glyphs cannot fully automate creating a class for all the “A” glyphs because it is not clear where to draw the line. Does Æ still count? What about Ⱥ, Ꜳ, Ɐ, …? There is not one correct answer as it depends on your projects and what you instead to do with the class.

Maybe this works for you:

@A = [A $["A" in layer0.componentNames]];

This class contains the A glyph itself and any glyph that uses the A as a component.

3 Likes

Thank you for this @FlorianPircher ! I just want all the A’s in my current file of course, and I feel that the line you sent would work well for my use. Is there a way for me to check like an expanded list of the result of line of code?

Hold the Option (⌥) key and click on a token to reveal the list of glyphs that the token expands to:

4 Likes

That’s neat, thanks a lot!

Can you take a class and then use operators to make other classes based on that?

For example:
@glyphs_base = [A B C]
@glyphs_init = @glyphs_base beginswith “.init”
@glyphs_fina = @glyphs_base endswith “.fina”

Hi @FlorianPircher
I cant find any sign of componentNames in Tokens Tutorial page, also explain for Complex objects is really short.
which parameter can I add after layer0? Is there any tutorial?
If no
can you name some parameter here?

Its any property defined on GSLayer as described in the Core documentation:

https://docu.glyphsapp.com/Core/Classes/GSLayer.html

But that documentation is written primarily for other purposes (plugin development), so I think we could create a list of the most common/useful properties and how to use them. Maybe I will have something ready by the end of next week.

I’m waiting and hoping you have time
I think that’s very important and useful for predicate token

@mekkablue can you update Tokens Tutorial page exactly Complex objects?

Can anybody write here which parameter can I add after layer0 ?
@GeorgSeifert can you?

There are too many things that you can write after layer0 for me to list them all here. You can get a much more comprehensive listing on the Core documentation that I have linked above. To get you started, here are a few examples:

  • Access dimensions of the layer like layer0.minX (maxX, minY, maxY).
  • Access metrics like layer0.width, layer0.LSB, layer0.RSB.
  • Access metrics keys like layer0.widthMetricsKey.
  • Access shapes like layer0.countOfShapes.
  • Access the position of anchors like layer0.anchors.top.x.

Similar code can be used to access guides, the background image, graphic attributes. The Code documentation has info about the names for those properties.

The tokens tutorial goes into more details what you can do with these values.

I found these codes:

  • width: The width of the layer.
  • Example: layer0.width
  • LSB: Left sidebearing.
  • Example: layer0.LSB
  • RSB: Right sidebearing.
  • Example: layer0.RSB
  • height: The height of the bounding box of the layer’s paths.
  • Example: layer0.height
  • anchors: A list of anchors in the layer.
  • Example: layer0.anchors
  • paths: A list of paths in the layer.
    • metrics: Accesses custom metrics for the layer.
  • Example: layer0.metrics
  • selectionBounds: The bounding box of the selected paths, components, and anchors.
  • Example: layer0.selectionBounds
  • associatedMaster: The master associated with this layer.
  • Example: layer0.associatedMaster
  • userData: Accesses custom user data attached to the layer.
  • Example: layer0.userData
  • hintOriginNodes: Accesses the origin nodes for hints in the layer.
  • Example: layer0.hintOriginNodes
  • backgroundImage: The background image object in the layer, if any.
  • Example: layer0.backgroundImage
  • hints: A list of hints in the layer.
  • Example: layer0.hints
  • parentLayer: Returns the parent layer if the layer is a background or mask.
  • Example: layer0.parentLayer
  • mask: The mask of the layer.
  • Example: layer0.mask
  • italicAngle: The italic angle of the layer.
  • Example: layer0.italicAngle
  • associatedLayer: The associated layer if this is a special layer (like a brace or bracket layer).
  • Example: layer0.associatedLayer
  • Example: layer0.paths
  • components: A list of components in the layer.
  • Example: layer0.components
  • guides: A list of guides in the layer.
  • Example: layer0.guides
  • hints: A list of hints in the layer.
  • Example: layer0.hints
  • background: Accesses the background layer.
  • Example: layer0.background
  • bounds: The bounding box of the layer’s paths as a rectangle.
  • Example: layer0.bounds
  • selection: The current selection on the layer (nodes, components, etc.).
  • Example: layer0.selection
  • name: The name of the layer.
  • Example: layer0.name
  • parent: The GSGlyph object that this layer belongs to.
  • Example: layer0.parent
  • color: The color label assigned to the layer (if any).
  • Example: layer0.color
  • layerId: The unique identifier for the layer.
  • Example: layer0.layerId
  • associatedMasterId: The ID of the associated master.
  • Example: layer0.associatedMasterId
  • hints: A list of hints in the layer.
  • Example: layer0.hints