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

should a qcurve segment not preceded by any offcurves be interpreted as a straight line? #211

Closed
anthrotype opened this issue Nov 11, 2022 · 3 comments · Fixed by #212
Closed

Comments

@anthrotype
Copy link
Member

The current GLIF point types spec currently says about "curve"

https://unifiedfontobject.org/versions/ufo3/glyphs/glif/#point-types

curve

Draw a cubic bezier curve from the last non-offcurve point to this point. The number of offcurve points can be zero, one or two. If the number of offcurve points is zero, a straight line is drawn. If it is one, a quadratic curve is drawn. If it is two, a regular cubic bezier is drawn.

For the "qcurve" quadratic curve segment type, it simply says:

qcurve

Similar to curve, but uses quadratic curves, using the TrueType “implied on-curve points” principle.

It does not explicitly say what to do in the case of zero offcurve points preceding the oncurve point marked as "qcurve".

I think this situation should also be interpreted as a straight line, which it also appears to be what Robofont does.

Maybe the UFO spec should be updated to mention this explicitly if that's the case.

This issue came up in googlefonts/ufo2ft#468 (comment)

@anthrotype
Copy link
Member Author

anthrotype commented Nov 11, 2022

not sure if relevant here but I noticed that the fontTools BasePen (the mother of all pens!), while it does handle the variable number of off-curves in the curveTo method, it has this assertion in the qCurveTo method that seems to suggest for the quadratic with case zero offcurves are not expected (perhaps intentionally?, if so we should make it explicit)

https://github.com/fonttools/fonttools/blob/35856412485bce4a1e6c08cceb52c7a87c75c4ee/Lib/fontTools/pens/basePen.py#L303-L305

	def qCurveTo(self, *points):
		n = len(points) - 1  # 'n' is the number of control points
		assert n >= 0

/cc @justvanrossum @typemytype @jenskutilek

EDIT: it totally is expected if you understand the difference between > and >= 😅

@justvanrossum
Copy link
Contributor

n seems to be the number of off-curve points, and it's asserted to be zero or greater than zero.

I think this situation should also be interpreted as a straight line

That's for sure the intention.

@anthrotype
Copy link
Member Author

anthrotype commented Nov 11, 2022

oops sorry... can't even read python code.
Ok then, would be nice to get the spec updated accordingly to mention this explicitly

anthrotype added a commit to fonttools/skia-pathops that referenced this issue Nov 11, 2022
When constructing a pathops.Path using the PathPen, we should handle variable number of point arguments to curveTo and qCurveTo, following fontTools' BasePen which is the blueprint of all segment-based pens.

https://github.com/fonttools/fonttools/blob/35856412485bce4a1e6c08cceb52c7a87c75c4ee/Lib/fontTools/pens/basePen.py#L274-L329

Also see unified-font-object/ufo-spec#211

and googlefonts/ufo2ft#468 (comment)
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

Successfully merging a pull request may close this issue.

2 participants