Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save marcdama/293fc951af918951682a to your computer and use it in GitHub Desktop.

Select an option

Save marcdama/293fc951af918951682a to your computer and use it in GitHub Desktop.
FL: for selected glyphs: Center glyph vertically, according to specified box
from robofab.world import *
f = CurrentFont()
top = 880
bottom = -120
for i in f.selection:
glyf_h = f[i].box[3]- f[i].box[1]
t_s = top - f[i].box[3] #distance from top of bbox
b_s = f[i].box[1] - bottom #distance from bottom of bbox
base = (t_s - top) + glyf_h + bottom
f[i].move((0,base)) #move glyph to baselines
f[i].move((0,(t_s + b_s)/2)) #center glyph to box
f.update()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment