Is Copy PostScript Hints scriptable?

I’d like to do Copy PostScript Hints (available in the context menu if the TT tool is selected) for the whole font. Is that possible?

You mean this one, right?

image

Yes, exactly. In Glyphs 2, it says “PostScript” instead of “PS”. I’d like to do that for the whole font.

Quick answer: GlyphsToolTrueTypeInstructor has a method copyPSHints_(). I’ll follow up with a sample in a minute. Unless you beat me to it. :slight_smile:

Bad news. I just checked, the method is not very abstract. It only operates on the layer currently opened for editing.

But it is very simple. It goes through every hint and if it is horizontal and of type Stem, it creates a copy of the hint with hint.copy() and changes its type to TTStem. In analogy, it does the same with BottomGhost and TopGhost hints and turns them into TTSnap type hints. Collects them all in an array, then iteratively adds them to layer.hints.

Thanks. Yes, it is indeed a fairly easy operation. Maybe I’ll script that then.

Btw, the preview image in the background is rather blurred. Maybe some kind of bicubic resampling at work? Would it be possible to switch to primitive re-scaling that results in unicolour pixels? Or make it possible to switch it off entirely?

Oh, and this handy vertical waterfall in Glyphs 3 often doesn’t update when I switch to a different glyph (just shows black squares).

This is what I have come up with. It copies both x and y direction hints.

from GlyphsApp import *
import copy

for layer in Glyphs.currentDocument.selectedLayers():
	# delete all TT instructions:
	for i in range( len( layer.hints ) -1, -1, -1 ):
		if layer.hints[i].type in [TTSTEM, TTANCHOR]:
			del layer.hints[i]
	# existing PS hints to TT instructions:
	existing_hints_count = len( layer.hints )
	for i in range( existing_hints_count ):
		hint = layer.hints[i]
		if hint.type == BOTTOMGHOST or hint.type == TOPGHOST:
			layer.hints.append( copy.copy( hint ) )
			layer.hints[-1].type = TTANCHOR
		elif hint.type == STEM:
			layer.hints.append( copy.copy( hint ) )
			layer.hints[-1].type = TTSTEM

That is a bug in Big Sur.

1 Like