Pyphon command for setting left and right bearings

Ken Krugh's picture

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.


eigi's picture

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)


Ken Krugh's picture

Thanks Eigi, worked just right.


Syndicate content Syndicate content