Hacker News new | ask | show | jobs
by pavlov 1019 days ago
Postscript used cubic Béziers, but TrueType, specified some ten years later by Apple with the learnings from practical use of Postscript on Macs, opted to only support quadratics instead.

Donald E. Knuth seems to think pretty highly of this decision:

“The quadratic has the great advantage that there's a real cheap way to render them. You can make hardware to draw a quadratic spline lickety-split. It's all Greek mathematics, the conic sections. You can describe a quadratic spline by a quadratic equation (x, y) so that the value of f(x, y) is positive on one side of the curve and negative on the other side. And then you can just follow along pixel by pixel, and when x changes by one and y changes by one, you can see which way to move to draw the curve in the optimal way. And the mathematics is really simple for a quadratic. The corresponding thing for a cubic is six times as complicated, and it has extra very strange effects in it because cubic curves can have cusps in them that are hidden. They can have places where the function will be plus on both sides of the cubic, instead of plus on one side and minus on the other.

“The algorithm that's like the quadratic one, but for cubics, turns out that you can be in something that looks like a very innocuous curve, but mathematically you're passing a singular point. That's sort of like a dividing by zero even though it doesn't look like there's any reason to do so. The bottom line is that the quadratic curves that TrueType uses allow extremely fast hardware implementations, in parallel.”

https://lists.nongnu.org/archive/html/freetype-devel/2000-01...

3 comments

And then OpenType added cubic bezier back in.... by embedding postscript font definitions.... Before they went one better and added support for embedding SVG for emojis.

(I ported a tiny TrueType renderer from C to Ruby, and looked at what it'd take to add OpenType support, since OpenType uses the same container format; font file formats look like they were designed by a drunk student as a prank)

Wow, I didn't know Knuth said that. I would've been 7 years old at the time - wild.
Knuth has been saying interesting things for a very long time. He began _The Art of Computer Programming_ project in 1962.
Yeah, I’m thinking that I met DEK before the parent poster was born (he told me that I would be able to be his student because I wasn’t taller than him. Spoiler: I was never his student).
those are both Bezier curves. They're just second vs. first order Bezier curves, but all the same math applies, and polybeziers are so much harder to work with when they're quadratic instead of cubic, it's not even funny.