RoboFab Sidebearings Script ?

RachelR's picture

Hi all,

Is it possible to use RoboFab control the sidebearing of glyphs.

I was thinking something like this might work.

This code just prints the sidebearing - 20, what I really wanted to do is decrease the left sidebearing by 20.

from import CurrentFont
f = CurrentFont()

A = f['A'].leftMargin


print A


k.l.'s picture

Have you tried this?

print "before", f['A'].leftMargin
f['A'].leftMargin = f['A'].leftMargin -20
print "after", f['A'].leftMargin

William Berkson's picture

That's easy to do in Font Lab also. Select the glyphs you want to change, and then go to: actions/metrics/set side bearings.

RachelR's picture


Thanks that worked, still getting to grips with the RoboFab syntax

I think I was trying to do this with my first attempt.

from import CurrentFont
f = CurrentFont()

f['A'].leftMargin -=20


PabloImpallari's picture

How can I do the same, but using the 'measurement line'?
I mean: To measures the distance from, let say, the middle of the x-height instead if the first left point.

vanblokland's picture

Pablo, have a look at the marginPen module in RoboFab/pens. It will calculate the margins of a glyph at a requested height (or width)

link to on

PabloImpallari's picture

Erik, thanks!
marginPen is awesome.

I'm working on a spacing macro, will release it shortly.

Syndicate content Syndicate content