Measurements of stems of instances

Is there a way to measure the stems of instances other than generating the static instances, opening them in Glyphs, and measure them there?

With a plugin of mine which I want to release soon, it is. Sorry for the (yet) unfullfilling teaser.

2 Likes

Betatest?

Try this:

# --- Get instances' stems ---

# get stems from each master involved in interpolation
font = Glyphs.font
instances = font.instances

for instance in instances:
	instanceInterpolations = instance.instanceInterpolations
	instanceStems = []
	for i in range(len(font.masters[0].stems)):
		masterStems = []
		for masterID, influence in instanceInterpolations.items():
			master = font.masters[masterID]
			stem = master.stems[i]
			masterStems.append((influence, stem))
		
		# get instance stem (rounded)
		instanceStems.append(int(sum(influence * stem for influence, stem in masterStems)))
		
	print(instance.name, instanceStems)
	
	# open the instance in glyphs if you want to check (careful with many instances though)
	# Glyphs.fonts.append(instance.interpolatedFont)