fontParts icon indicating copy to clipboard operation
fontParts copied to clipboard

Expose mathGlyph filterRedundantPoints in RGlyph.fromMathGlyph() and .toMathGlyph()

Open LettError opened this issue 4 years ago • 9 comments

This issue is part of a problem that spans fontMath.MathGlyph / fontParts.RGlyph / UFOProcessor. It should be possible to get data in and out of MathGlyph without the filterRedundantPoints filter. MathGlyph already has support for this.

History: by default MathGlyph adds on-point bcps to all straight segments on init, and filters the on-point bcps out on extraction. This was to reduce compatibility issues. Currently a lot of the work is done towards variable fonts and these are a lot stricter and the adding / filtering of bcps is just too invasive. The filtering even takes out points that were intended to be part of the outlines (see this UFOProcessor issue.)

MathGlyph has a flag to switch this filtering off. But I need to make sure it doesn't also add them at initialisation. We abstracted the way fontParts.RGlyph makes and gets MathGlyphs. So fontParts and its users can not get to those flags directly. And maintaining forked versions of mathGlyph / fontParts and ufoProcessor is a hassle.

Proposal: I would like to add a filterRedundantPoints or suitably renamed flag to toMathGlyph and fromMathGlyph. Default set to current behaviour, True. In an old (and stale) sketch I named this flag strict. Then I can add a similar flag to ufoProcessor and all its users too.

LettError avatar Mar 29 '21 09:03 LettError

Agree. Let me know if you want help with this.

benkiel avatar Mar 29 '21 14:03 benkiel

What's better: a separate branch here, or a fork to my own account and then a PR? (are those even options)

LettError avatar Mar 29 '21 15:03 LettError

either, whatever is easiest for you

benkiel avatar Mar 29 '21 16:03 benkiel

WIP https://github.com/robotools/fontParts/commit/6f2c5868644409007c33ee2e909ca1bca46cb975 See also https://github.com/robotools/fontMath/issues/232#issuecomment-812554325

LettError avatar Apr 02 '21 14:04 LettError

What to do with the calls that to toMathGlyph in fontParts.base.glyph, for instance add, sub and friends: https://github.com/robotools/fontParts/blob/4a55d73d049e8122fb43fd32ce53b0dcbde10340/Lib/fontParts/base/glyph.py#L1679

Can we tell what the intent is here? toMathGlyph will have strict=False as a default. So how would I control the strictness in g1 + g2?

Maybe base.glyph needs its own strict flag?

LettError avatar Apr 02 '21 14:04 LettError

+1 for base.glyph strict flag which defaults False (the current implementation)

typemytype avatar Apr 02 '21 21:04 typemytype

@LettError Yes, I guess so, with the default behavior of False (shoot @typemytype just beat me to it)

benkiel avatar Apr 02 '21 21:04 benkiel

So that means adding a def _get_strict(self): and def _set_strict(self, value):, correct?

Then perhaps it is too much to also add def toMathGlyph(self, strict=None): -- if the flag can already be set as an attribute of the glyph, it would not necessary to be able to override it in toMathGlyph.

LettError avatar Apr 03 '21 10:04 LettError

Upstream updated: https://github.com/LettError/ufoProcessor/pull/41

lianghai avatar Jun 08 '23 15:06 lianghai