Hi, I’m updating my custom script for automatic instance creation from G2 to G3 API. Before, I used instance.customParameters["familyName"] = "..."
, but if I’m not mistaken, familyName
moved to parameters
in G3. I can’t figure out how to set it though. I’m quite sure it’s dead simple, but with my limited skills I can’t figure out how to do it. Any help would be much appreciated. Thank you! Ondrej
@setuptype, this should work
from GlyphsApp import GSFontInfoValueLocalized, GSFontInfoValue
def changeDefaultFamilyNameForInstance(instanceObj, newName):
"""
function that allows you to change the "Localized Family Name" instance property.
It works specifically for default language tag (dflt).
"""
languageTag = "dflt"
for p in instanceObj.properties:
if p.key == "familyNames":
for value in p.values:
if value.languageTag == languageTag:
value.value = newName
return
localizedCustomFamilyName = GSFontInfoValueLocalized()
localizedCustomFamilyName.key = "familyNames"
nameValue = GSFontInfoValue()
nameValue.languageTag = languageTag
nameValue.value = newName
localizedCustomFamilyName.values.addObject_(nameValue)
instanceObj.properties.addObject_(localizedCustomFamilyName)
# end of function
for instance in Glyphs.font.instances:
changeDefaultFamilyNameForInstance(instance, "myNewFamilyName2")
I created this function changeDefaultFamilyNameForInstance
. You should use it in order to change the family name for your instance. Below the function, you can see an example of how to implement it. It should be rather simple.
I hope it helps. If you will have any issues just write
Cheers
2 Likes
There is a method: instance.setProperty_value_languageTag_("familyNames", value, "dflt")
that does exactly that.
1 Like