Calt rules differentiating bold, italic etc.?

When I make code in calt function, I want to make a rule that says something like
sub @letters @letters’ by @letters_alt;

But I want that to only apply to the bold versions. I know this would be wrong but something meaning:
sub @BOLDletters @BOLDletters’ by @BOLDletters_alt;

So if you write a regular letter than then a bold letter, it will not substitute that second one.

How do I code this?
Thank you!

You mean you have an multiple master setup and interpolating instances and like to only have the substitution in some of the instances?
The you can use a ‘Replace Feature’ custom parameter in the instances.

1 Like

I don’t want any interpolation. Perhaps I should explain what I’ve been doing so far. I made a regular font. Then in a separate file, I made a bold version of that font, with it’s own rules and it’s own glyphs, in another file, and exported that as a bold instance of the same font. Like that it can be accessed in use by making the text bold.

Now I got into colour, I see this kind of thing in the right side:
06

By the look of it I’m assuming I can make a copy of the whole regular font and name the copy ‘bold’ or ‘italic’ etc. and then use that menu to manually edit each glyph to edit the bold versions. I assume this means it would be defined as having multiple masters(?) On that point:

  • Can I duplicate the entire font and make those duplicates appear on that menu as ‘bold’, just as ‘regular’ appears there? And then edit them there?
  • Will interpolation happen automatically? If so can I switch it off?

Yes exactly. Got that to work great when the regular and bold were in different files, using calt code similar to the example I gave above, i.e. sub @letters @letters’ by @letters_alt;
Have not tried yet with all in one file but the idea of having them in the same file is very appealing, would make the work a lot easier. If I know how to make that work. From what I gather you are saying then that this would not be done in the calt function if all in one file?

So I found this window:


I’m guessing you mean I should click the + button and then name the new custom parameter ‘Replace Feature’ - is that correct? What would I do from there?

Thank you!

Also while we are on this topic… if I make bold in a separate file, I can change the colours used throughout the bold font via this menu:

If I have regular and bold in one Glyphs file, can I edit that colour palette for regular and bold separately? Via this menu or some other one? Or do I need to keep the regular and bold versions in separate files to do this?

N.B. if the answer is the latter, this does not affect my previous question as I may then use both methods for separate reasons.

Georg your assistance on this would be deeply appreciated. I still have no idea how to makes rules for just one style, e.g. bold. I can do it if I made the bold as a separate Glyphs file, using calt. But still no idea how to make it when both are in one file. Would really love to know!

Thanks! :pray:

Have you tried the Replace Feature parameter in Font Info > Instances? As value, use the feature tag, followed by a semicolon, followed by the new code.

1 Like

No. I do not know how to do that and cannot actually understand your last sentence. But I would love to learn! Would it be possible to tell me what to do in this case, where I want this rule (which I would usually put in the calt function), to only apply to the bold instance?
sub @letters @letters’ by @letters_alt;

  1. Understand what a custom parameter is: https://glyphsapp.com/tutorials/custom-parameters
  2. In this case, you need an instance parameter. That means you go to File > Font Info > Instances, pick an instance in the left sidebar (e.g. the Bold), and add a new custom parameter by clicking on the plus button next to the Custom Parameters field.
  3. As property, you pick Replace Feature. If you don’t know what that means, see 1.
  4. As value, you type the feature tag (e.g. calt or rlig), then a semicolon (;) as a separator, then the new feature code (sub x by x.alt;). So the complete parameter value could be calt; sub x by x.alt; sub y by y.alt;
  5. If you want to replace more features, you need to add more parameters. One Replace Feature parameter can only replace one feature.

So I have tried this, but I tried in a way that is maybe not allowed? Here’s the code I entered in the ‘value’:
calt; sub @base_reg @base_reg’ by @base_ss01;

And here’s the error message I get when trying to export:

So are we not allowed to use classes in this way of using calt?
If not then I guess I can enter the whole list in brakets for both classes?

Edit:
Weird, I changed that to listing all glyphs in those classes, space separated, in [square brackets]. But when I try to export I still get exactly the same error message. I had thought the ‘â’ might be referring to ‘@’. But apparently it’s indicating something else is wrong because there are definitely none of them left. How should I be scripting this? It needs to apply to dozens of glyphs. Here’s a simplified example of what my code looks like:
calt; sub [a b c] [a b c]’ by [a.ss01 b.ss01 c.ss01];

How can I make it work?
Thank you!

You have an accidental curly quote instead of a straight quote ' in there. In the error message, the curly quote gets garbled to â.

1 Like

Ah thanks! Never would have noticed!
Also I’m working through the tutorial you kindly posted on the other thread. Since I could not get the bold only script working I was trying just through calt, since I discovered that even when we have bold and regular in one file, when exported the calt rules actually seem to ‘break’ when you switch from regular to bold. So I can actually make code designed to trigger when switching between styles even without using this method. And found a workaround to not have that make changes to regular.

But, this master-specific code method will come in handy later - so thanks for helping me with that! And it saves me the workaround :slight_smile:

Oh now this also presents an issue. Is there a way we can make it not break the code when we need that? For example, if I have,
sub a b’ by b.ss01;

So if I type:
ab
the ‘b’ switches to ‘b.ss01’.

But if I type:
ab
the ‘b’ will not switch.

I very much want to be able to make some calt code apply even through switching between regular/bold etc. Is there a way I can write code to make that happen?
but then I type lets say

OpenType features can only access glyphs of the same font.

1 Like

OK thanks - I made a work around so can live with that :slight_smile:

You can do something like this in InDesign with a GREP or a nested style.

1 Like

I don’t have that app but could deal with it using a specific glyph as a trigger. Just a bit more awkward for input method at the user end but I think it should work well.