# How do I restore implied on-curve points in TTF Fonts?

I'm trying to find the coordinates of the implied point p2 using the control points p1 and p3. See here:

In the TTF spec they say:

Connected quadratic curves have first degree continuity and tangent continuity if each curve point is on the line connecting the two flanking control points.

And also the quadratic Bezier curves are defined as follows:

p(t) = (1-t)2p0 + 2t(1-t)p1 + t2p2

Using the fact that the the three points are collinear wouldn't be enough. I need one more equation so that I would be able to express p2 using the other two control points.

I know I'm missing here something rather simple but I can't make it out easily without help.

Thanks!

-
Is the curve connecting $p_0$, $p_2$, and $p_4$ a single curve, or is $p_2$ a break-point? – J. M. Apr 30 '11 at 10:20
It's more like piece-wise. Two quadratic curves, connected in p<sub>2</sub> and required to have first degree continuity and tangent continuity in this point. – Albus Dumbledore Apr 30 '11 at 10:22
I see, and all the points except $p_2$ are known? – J. M. Apr 30 '11 at 10:25
I'm looking at some old TTF code I wrote, and it seems I used the midpoint between $p_1$ and $p_3$ -- I'll try to reconstruct why I did it that way. This page: digitalsupporttech.com/mskb/243/… also says to use the midpoint. – joriki Apr 30 '11 at 10:39
Thanks joriki. I seem to have found some code from Apache Batik that does exactly that. – Albus Dumbledore Apr 30 '11 at 11:03

I believe the answer depends on what is meant by "first degree continuity and tangent continuity". For the two quadratic splines for $(p_0,p_1,p_2)$ and $(p_2,p_3,p_4)$, the derivatives of the curve with respect to the parameter $t$ at $p_2$ are $2(p_2-p_1)$ and $2(p_3-p_2)$, respectively. The tangents at this point will coincide if these two vectors have the same direction, which is the case iff $p_2$ lies on the line $p_1p_3$. This is presumably what is meant by "tangent continuity". This property is independent of the parametrization.
The magnitude of the derivative, by contrast, depends on the parametrization, and is thus in a sense arbitrary -- we could rescale the derivatives to make them coincide, by scaling the parameter $t$; the result would still be a quadratic function of $t$. I presume that "first degree continuity" refers to the parametrization-dependent constraint that the derivatives coincide not only in direction but also in magnitude (though that would render the formulation redundant, since "first degree continuity" would then imply "tangent continuity").
Interpreting the constraints in this way leads to $p_2-p_1=p_3-p_2$, so that $p_2$ must be chosen as the midpoint between $p_1$ and $p_3$.