Typophile

Pyphon command for setting left and right bearings

Ken Krugh

Sorry, desperately posting here. We recently enlarged a bunch of glyphs and discovered the wonderful Fontlab bug of negative side bearings. Fontlab changed all the negative bearings in a wrong direction.

I've writtin a Python script to help me fix them and I'm able to read old bearings on a glyph (from a previous version of the Fontlab file) change to my font in progress, read the bearings there and calculate the numbers I need.

The only thing I can't find is how to set the bearings to my new numbers.

I'm sure there is something I'm missing something and any help would be greatly appreciated.

Ken

You can do something like this:

from FL import *

def setSidebearing(glyph, lsb=0, rsb=0, mask=False, composites=False):
  code = 19
  text = '%d %d 0 0 0 0 0 %d %d' % (lsb, rsb, mask, composites)
  fl.TransformGlyph(glyph, code, text)
  glyph.modified = 1
	
setSidebearing(fl.font[fl.iglyph], 22, 25, True, True)
fl.UpdateGlyph(fl.iglyph)

Best
Eigi

Thanks Eigi, worked just right.

Ken

Captured from web.archive.org on 6 Dec 2011. view this capture