Manipulating Points
RGlyph objects have methods that allow the objects to behave a bit like variables in simple math. These methods do not do additions or substractions of the surface area of the glyphs, like layering two glyphs on top of each other and than doing "remove overlap". Instead, they return new glyph objects in which each coordinate in each contour is the product of the two glyphs.
Objects
All glyph math operations in have new, orphaned, objects as result. For instance a substraction of two FontLab RoboFab glyphs will result in a new glyph object, but it won't be part of the font. If you want the result to be part of the font you have to add it explicitly, see the example at the bottom of this page. There are several reasons for this:
- the result might not even come from glyphs in the same font, i.e. you can substract a glyph in one font from a glyph in another font. Where should the result live? you decide.
- You might not want the result to be part of your font when you're using it for further calculations. So: results from glyphmath operations are orphan glyphs that do not belong to any font.
- the results need to use floating point (19.234943) numbers for precision, FontLab only stores integer numbers (19)
someNewGlyph = aFont.newGlyph("someNewGlyph") someNewGlyph.appendGlyph(restultFromGlyphMath) # note you have to set the width, appendGlyph does not automatically # take the value. someNewGlyph.width = restultFromGlyphMath.width