Add Number Values by Script

is there a way to access “Number Values” parameter in each master via script?

Thank you.

Manage number values on the font level:

Access their values on a master level:

image

1 Like

I added it to the wrapper and the docu (both will be online soon).

1 Like

Thank you!

I’m trying to access value with this code :

font = Glyphs.font
master = font.selectedFontMaster
print(master.numberValueForName_("newNumber").value)

It return me

<native-selector value of <GSInfoValue 0x60000467d680> 0>

What I’m doing wrong ?

Add a () after the value, like this: numberValueForName_(“name”).value()

2 Likes

Which is the method to add a Number Value to Font ?
I tried all method with GSFont, but I didn’t succeed.

Number values are set on masters.

I also tried all GSFontMaster Method…

I see, the wrapper code is not yet in the latest shipping version.

Here is what you can do in the meantime:

someMaster.setNumberValueValue_forName_(15, 'SomeName')
1 Like

Got a couple questions on this same topic.

  1. How to access the Name and Value of each Number Value in a Master?
font = Glyphs.font
master = font.selectedFontMaster
print (master.numbers())

prints out something like this

(
    "<GSInfoValue 0x600005be3120> 70",
    "<GSInfoValue 0x600039b31920> 100",
)
  1. I am able to set number values but do not see them updating in the actually Master tab menu UI. Is there another way to achieve this or force the UI to update?
# Access the current font
font = Glyphs.font

font.disableUpdateInterface()
# Iterate through all font masters
for master in font.masters:
    # Check if the master's name is in our predefined dictionary
    if master.name in master_values:
        # Iterate through each name-value pair for this master
        for name, value in master_values[master.name].items():
            # Set the number value for this name
            master.setNumberValueValue_forName_(value, name)
            print(f"Set {name} to {value} for {master.name}")
    else:
        print(f"No predefined values for {master.name}")
font.enableUpdateInterface()