fontMath
fontMath copied to clipboard
MathGlyph() should not add offcurves just to avoid awkward situations
While it might solve short term compatibility problems, it really makes it difficult to prepare outlines for variable fonts.
I propose MathGlyphPen() gets a flag, something like addOffCurves=False. Then line 373 can be conditional.
WIP! This needs a change in fontMath: https://github.com/robotools/fontMath/commit/3557715dc6651d8d79cd65b1322fea4a6f80c3a3 and probably also a change in fontParts: https://github.com/robotools/fontParts/commit/1358ecb8414c694413f7e8fbc2687b1e7b9f67db
- a strict mathGlyph is more likely to run into compatibility problems. Currently MathGlyph falls apart in a couple of different IndexErrors, perhaps these can be wrapped better.
This can now get worked on, due to #235
Hello, I'm running into the same problem as described above. In order to solve the problem I have sub classed my fontParts RGlyph and I add the strict = True parameter to all calls of the RGlyph._toMathGlyph() method - and I add the filterRedundantPoints = False parameter to all calls of the RGlyph._fromMathGlyph() method. Unfortunately this doesn't solve the problem. I suspect there is a bug in MathGlyph.getPointPen() method. This method ignores the strict attribute of the MathGlyph and always returns a MathGlyphPen with the default strict = False. As a result the strict = True parameter in the RGlyph._toMathGlyph() method call has no effect.
I have solved it in my fontParts RGlyph._toMathGlyph() method as follows:
def _toMathGlyph(self, scaleComponentTransform=True, strict=False):
"""
Subclasses may override this method.
"""
import fontMath
mathGlyph = fontMath.MathGlyph(
None, scaleComponentTransform=scaleComponentTransform, strict=strict
)
pen = mathGlyph.getPointPen()
pen.strict = strict
self.drawPoints(pen)
...
I have manually set the strict attribute of the pen which is returned by the mathGlyph.getPointPen() call. This solves the problem on my side but I think the mathGlyph.getPointPen() method should respect the strict attribute of the mathGlyph instance.
All the best Eigi
the mathGlyph.getPointPen() call should initiate a MathGlyphPen(self, strict=self.strict) here https://github.com/robotools/fontMath/blob/master/Lib/fontMath/mathGlyph.py#L293
could you make a PR?
thanks