Run a script on an instance level with LayerGeek


#1

Hello!
I’ve finally got to work my script to generate and add a “kern” feature! to my font! Hurra!!!

But now, I’m trying to use LayerGeek to make this script to run on instances level only, to get the right kern values for each of them.

I’ve searched on this forum, the web and read the documentation but I can’t find any help ;(
I guess it should be
{
Filter = “LayerGeek; something”;
}

Could anyone please help?

Thanks :slight_smile:


#2

You want to add a feature? Use the Replace Feature parameter instead.


#3

I want to add some code that differs from instance to instance. Replace feature will not fit my need I guess.
And, in general, I find more powerful to be able to run a custom script for an instance without having it as a plugin (to make it not showing in the menus


#4

To be clearer, my script looks at some kerns of each instance, makes some math and outputs N strings into the pos x x’ number x; format. Then my script generates the kern feature.
Replace Feature just puts some code in place of another; I need to run a sort of FEA code generator.


#5

You can do that and put the result in the “Replace Feature” with the “kern” feature. Add “# Automatic Code End” to the beginning of your feature code.


#6

Sorry but I don’t understand.
I have to run my script in order to generate the feature’s code. How can I run this code on an instance level (that means on export, a different code is generated for each instance).
Even if I modify my script to output “# Automatic Code End” as 1st line, how do I run it?


#7

I mean, the script must run on its own on instance level. that’s why I need to run a SCRIPT as custom parameter.


#8

You can run the script before the export and store the feature code in the CP.


#9

Sorry again, I’m afraid you don’t get my point.

As I said, my script recalculates some kerning adjusents based on kerns already present. That means each instance has different kernings or same kerning couples but different values. Therefore I need this script to run as custom parameter > filter.
In a post @mekkablue said LayerGeek can do it but there is no docu nowhere. Could you please help me on this point?


#10

You can run the script manually before you export, of if you change some kerning. You calculate it for each instance and put the code in the custom parameter of each instance. Then the code will be picked up on export.


#11

Frankly, there are hundreds of kern couples and 40 instances. Doing it by hand it’s just dumb.
Can’t you just tell how to run this layergeek? What’s the problem with it?


#12

And I can’t know the values before interpolating. I’d have to manually generate all instances to be able to run the script and get the good values. Once again, it’s not a smart workflow and I just need to run this script at instance level ( as rmx tools do for instance)


#13

I don’t know what you want to do in LayerGeek. It is a plug-in that lets you apply GSLayer methods on every glyph at export time. It cannot do much in terms of kerning.


#14

My English must be very poor… The kerning stuff it’s coded in a script I did. I just need to run this script (.py file in scripts folder) as custom parameter > filter: at instance level.
In al old forum post you’ve written it’s easily doable with layer geek


#15

if layergeek is not appropriate, is there any way to fire any custom script at instance level?


#16

Why do you think you need to run the script on export time?

You don’t need to much by hand. Make your script run for all instances at once.


#17

Can I send you my script in PM? Maybe it will be clearer


#18

I need to run it at export time because instances must be generated to obtain interpolated kerns. My script looks for these interpolated kerning values to calculate new values for many combos of 3 glyhps. If I run my script on master level, the values will be wrong as relative only for 1 master.


#19

You can get the interpolated font from the instance. Have a look: https://docu.glyphsapp.com/#GSInstance.interpolatedFont


#20

This could work :blush: I’ll dig into it, thanks. I suppose I use a for cicle with the .customParameters. command to set my resulting code as a replacefeature?