How to add new metric to a master with a script?

I want to add a new metric to a master using a script.

master = Font.selectedFontMaster

newMetric = GSMetricValue
newMetric.position = 100 = "Test"
newMetric.overshoot = 0
newMetric.filter = None
newMetric.metric = None


But this doesn’t work. It seems that I can’t use GSMetricValue() instead of GSMetricValue

TypeError: Use class methods to instantiate new Objective-C objects

The error message already explains what you need to do:

newMetric = GSMetricValue.alloc().init()

It seems that I can’t set an attribute using GSMetricValue.alloc().init()

AttributeError: can't set attribute
newMetric = GSMetricValue.alloc().init()
newMetric.position = 100


Only “position” and “overshoot” work.
All others produce an AttributeError.

I’m still struggling with this issue.
I have found some methods to set position, overshoot, and filter, but none to set the name.

font = Glyphs.font
master = font.selectedFontMaster

new_metric = GSMetricValue.alloc().init()

How do I set the name attribute and append new_metric to master.metrics ?

The name (and actually also the .filter) are stored in the GSMetricin font.metrics. You can get to the corresponding object:new_metric.metric` but only after you added it to the font.

1 Like

And how to add it to the font ?


This don’t work.


Have anyone solved this problem?
I couldn’t find any clue about adding GSMetricValue to the master.metrics.
As HugoJ has mentioned, I can’t add GSMetricValue with ‘append()’ even though master.metrics is a ‘list’.
This thread is the only one I can find about master.metrics in this forum.

Thanks in advance.

What exactly are you trying to do. Add a new metric to the list or set the value for an existing one?


I’d like to add a new metrics to the list.
(I have tested setting value for an existing one already and gotten successful result.)


Does this help?

from GlyphsApp import GSMetricsTypeBodyHeight

metric =
metric.type = GSMetricsTypeBodyHeight
master = Font.masters[0]
metricValue =
metricValue.position = 800
metricValue.overshoot = 20
1 Like


type = GSMetricsTypeBodyHeight
name = None # or set a name
filter = None # or add a filter like "script == greek"
master.setMetricPosition_overshoot_type_name_filter_(800, 20, type, name, filter)

If there is a metrics with matching type, name and filter, it will overwrite it, otherwise it adds a new metric

1 Like

It is really helpful! I appreciate your support.


Is there some way I can see a list of all possible the different type classes?

For example how would I set the type to “Other”?

You can find some infos here :