Also interpolate components#1652
Conversation
No, and no. I think we have a CheckedGlyph somewhere, but maybe that was in fontbe.. |
if we are going to decompose a glyph in the end, then yes. But if a glyph stays composite then it's ok for it be 'sparse', i.e. have more or fewer locations than any of its component glyphs, so you don't want to do it upfront regardless |
that's a good point. Currently in https://github.com/robotools/fontMath/blob/99c3047efbba68134bd0b8617e504330d5c5bdce/Lib/fontMath/mathGlyph.py#L79-L83 which means when static interpolated UFO instances are generated by fontmake, the whole component.transform gets interpolated... (wrongly?) but wait.. having written all that, that's all tangential to our problem here, we are dealing with variable fonts (not interpolated UFO instances to be built into statics, which we don't currently support anyway). In VFs, components in all masters must must have the same 2x2 transform, can only vary in the X/Y offset and we already make sure we decompose those, so you shouldn't ever come acress those in this code if we have properly decomposed them already.. Have we not? |
426d86c to
c240c6b
Compare
not in all cases. For instance we flatten export glyphs before we do anything else, which means 2x2 transforms are not yet decomposed. Should decomposition happen first? |
|
oh right. Hm, ufo2ft preProcessor similarly decomposes those skipExportGlyphs before doing any subsequent filter, including the decomposition of components with non-matching 2x2... its SkipExportGlyphsIFilter (where "I" stands for "interpolatable" filter, zipping same-named glyph across all sources) uses the ufo2ft.instantiator to generate instances for missing components so... yeah what I said earlier about fontMath applies here too for VFs, not just to the static build pipeline... |
993dfa3 to
3afbd88
Compare
|
I think the problem of treating all the transform values as something that can be linearly interpolated would only really be a problem if a component contains some rotation or skew, if it's only scaled and/or translated (the most common scenario) it should be ok.. |
I definitely agree that it should be fine in the common case, but I'm trying not to ignore the edge cases. |
|
fonttools now has a DecomposedTransform that can decompose a 2x3 affine Transform into its separate translate, rotation, scale and skew components.. so technically we could have ufo2ft and fontMath do it right, by lerp'ing each of these independently and recomposing. I'll file an issue in ufo2ft |
|
|
||
| /// Interpolate components (specifically their transforms) | ||
| /// | ||
| /// Matching varLib, we will just blindly interpolate the scalar values, which |
There was a problem hiding this comment.
| /// Matching varLib, we will just blindly interpolate the scalar values, which | |
| /// Matching ufo2ft, we will just blindly interpolate the scalar values, which |
varLib errors out if component don't have matching 2x2, they are already decomposed by the time they reach varLib. It's in ufo2ft.instantiator that this blind element-wise interpolation of 2x3 affine transformations happens, through fontMath technically.
you could link googlefonts/ufo2ft#949
However interpolation of components only works when they have trivial (translation-only) transforms. If they have anything more fancy, we will need to decompose the components first?
Components need to be defined at each location in order for us to be able to generate contours for them.
74e8270 to
c68fd5b
Compare
Instead of just dropping complex transforms on the floor. This matches fonttools.
c68fd5b to
c7c16a5
Compare
On top of #1650, this adds the ability to interpolate components with simple transforms.
This doesn't handle complex transformations, because I'm not sure how we should be doing that.
More generally, I have some concerns with the overall control flow in this file. There's a lot going on, and there are lots of moving pieces.