Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MathGlyph() should not add offcurves just to avoid awkward situations #127

Open
LettError opened this issue Sep 4, 2018 · 4 comments
Open

Comments

@LettError
Copy link
Member

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.

@LettError
Copy link
Member Author

WIP!
This needs a change in fontMath:
3557715
and probably also a change in fontParts:
robotools/fontParts@1358ecb

  • 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.

@benkiel
Copy link
Member

benkiel commented Jun 22, 2021

This can now get worked on, due to #235

@Eigi
Copy link

Eigi commented Jul 19, 2023

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

@typemytype
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants