Bug 16805 - Text on a path is all wonky
Summary: Text on a path is all wonky
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL: http://treebuilder.de/default.asp?fil...
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-09 14:04 PST by Oliver Hunt
Modified: 2010-07-08 01:50 PDT (History)
1 user (show)

See Also:


Attachments
Simple minimised text case. (526 bytes, image/svg+xml)
2008-01-09 14:04 PST, Oliver Hunt
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Hunt 2008-01-09 14:04:02 PST
Scaled textPath text is very jaggedly positioned.  I would suspect it were a CG bug, but it seems to effect SVG fonts as well.
Comment 1 Oliver Hunt 2008-01-09 14:04:53 PST
Created attachment 18353 [details]
Simple minimised text case.
Comment 2 Nikolas Zimmermann 2008-01-09 14:42:03 PST
Hey Oliver,

this is a known bug since ages. The root lies in Path.cpp, in following function:
static void pathLengthApplierFunction(void* info, const PathElement* element)

quoting parts of the code here:

if ...   (traversalState.m_totalLength >= traversalState.m_desiredLength)) {
        FloatSize change = traversalState.m_current - traversalState.m_previous;
        float slope = atan2f(change.height(), change.width());

        if (traversalState.m_action == PathTraversalState::TraversalPointAtLength) {
            float offset = traversalState.m_desiredLength - traversalState.m_totalLength;
            traversalState.m_current.move(offset * cosf(slope), offset * sinf(slope));

I can't exactly remember what the problem was, but it's related to the slope calculation. We're really only doing a bad approimation of the actual "point at length" (ie. gimme the path point at 30% of the path length). If the path consisted of _one_ large curve segment, we're approximating _the whole_ segment using a line, as you can see above - this doesn't make too much sense and results in whacky layout....

Please fix :-)

Greetings,
Niko
Comment 3 Eric Seidel (no email) 2008-01-19 02:22:06 PST
Hum... I'm pretty sure I wrote the path point finding code.  Perhaps i'll get a chance to fix it some day. :)
Comment 4 Nikolas Zimmermann 2010-07-08 01:50:01 PDT
Works in trunk, the root of the problem was missing subpixel positioning.