fontMath icon indicating copy to clipboard operation
fontMath copied to clipboard

translate

Open typemytype opened this issue 6 years ago • 5 comments

I came in to a situation where I needed to translate a mathGlyph

if there is interest I can add the full translate as a PR

see https://gist.github.com/typemytype/52de64953b7486ae9090f19525e22c9b

typemytype avatar Oct 01 '19 13:10 typemytype

Yes, please!

benkiel avatar Oct 01 '19 14:10 benkiel

fontmath objects have __mul__ operator which takes a number value as a factor, while the __add__ operator must be another compatible fontmath object. Maybe this translate method could simply be __add__ but when the type of the second addend is not a fontmath object but an int/float?

anthrotype avatar Oct 01 '19 15:10 anthrotype

Ehm, I actually meant a tuple of int/float E.g. MathGlyph(glyph) + (10, 10)

similarly for __sub__ ofc

anthrotype avatar Oct 01 '19 15:10 anthrotype

or maybe this could lead to confusions, and an explicit translate method is better.. 🤔

anthrotype avatar Oct 01 '19 15:10 anthrotype

Adding this to __add__ is not a good idea as this implies __mul__ should also take a mathGlyph, instead of a factor only.

A separate translate is better...

typemytype avatar Oct 01 '19 18:10 typemytype