On 10/21/06, Petter Urkedal <[EMAIL PROTECTED]> wrote:
I looked up this on Wikipedia, http://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm. The three coordinate components can be computed independently, so we only need to consider one component. If I'm looking at the right algorithm, it can be solved by n iterations over an array of n components, where n is the number of control points:
And since Truetype fonts use only qudratic Bezier curves with 3 control points.. it simplfies things even more. http://developer.apple.com/textfonts/TTRefMan/index.html http://en.wikipedia.org/wiki/TrueType Type 1 fonts use cubic bezier or 4 control points so is a little harder yet still no recursion is needed. http://en.wikipedia.org/wiki/Bezier_curve however even for cubic bezier there exists maybe better method. Point2D PointOnCubicBezier( Point2D* cp, float t ) { float ax, bx, cx; float ay, by, cy; float tSquared, tCubed; Point2D result; /* calculate the polynomial coefficients */ cx = 3.0 * (cp[1].x - cp[0].x); bx = 3.0 * (cp[2].x - cp[1].x) - cx; ax = cp[3].x - cp[0].x - cx - bx; cy = 3.0 * (cp[1].y - cp[0].y); by = 3.0 * (cp[2].y - cp[1].y) - cy; ay = cp[3].y - cp[0].y - cy - by; /* calculate the curve point at parameter value t */ tSquared = t * t; tCubed = tSquared * t; result.x = (ax * tCubed) + (bx * tSquared) + (cx * t) + cp[0].x; result.y = (ay * tCubed) + (by * tSquared) + (cy * t) + cp[0].y; return result; } And of course we'd probably want a non-float version.. a fixed point version. Truetype fonts seem to have coords of 1/64 of a pixel and IIRC the xrender extension subpixel addressing splits a 32 bit value in a 24 bit whole number and uses the other 8 bits for the fraction -- so 1/256 .... What I'm more concerned about is that plotting bezier curve points for the font outline is only a small part of the truetype font process... After you figure out the outline of the font in suffcient detail you still must fill in which pixels are black,white, or grey. Those rules involving griding, winding, dropout control mode, scan conversion, and other factors. http://developer.apple.com/textfonts/TTRefMan/RM02/Chap2.html "Font engine" might be a good thing to look up. Also a simplistic bezier curve to line segment convertor for these purposes might need more than one point per pixel but around two or three so it can tell if the center of the pixel is inside or outside the outline. It's the inflection point that mostly gets you so maybe a not completely even spaced set of points would work better. I'd need to think about problem more. Maybe it would be helpful for me to look at code of what others have already done in this area. -- http://dmoz.org/profiles/pollei.html http://sourceforge.net/users/stephen_pollei/ http://www.orkut.com/Profile.aspx?uid=2455954990164098214 http://stephen_pollei.home.comcast.net/ _______________________________________________ Open-graphics mailing list [email protected] http://lists.duskglow.com/mailman/listinfo/open-graphics List service provided by Duskglow Consulting, LLC (www.duskglow.com)
