Friday, September 7, 2012

[android-developers] Using DrawTextOnPath without it being ugly.

Anybody have experience using drawTextOnPath without it looking ugly?

I'm trying to fit an arbitrary label on an arbitrary polyline. At first glance, this seems like the perfect application for canvas.drawTextOnPath();

Except for the fact that it looks really bad.
I might expect it to neatly Place the characters according to the Path.
Instead, when the path is concave, it squishes and overlaps several characters, looking like a miscalibrated calculator.
When the path is convex, it stretches whichever unfortunate letter is on the curve, making it look like an ink spill.

These features are most pronounced in a sharp curve, but it doesn't take much of any bend in the Path to make it look weird. It only looks good on the occasions where the Path happens to be completely straight for the duration of the entire text.

As an example: I am pretty sure that when Google Maps labels a curved road, they are prerendering that tile on the server and not using drawTextOnPath. Why do I think that? Because it doesn't look awful.

I've made some progress by simplifying the path for the label. It doesn't have to be as dense as the path it is labelling of course.

I've put in a cornerPathEffect in hope of smoothing, and it hasn't helped one bit as far as I can tell.

Was drawTextOnPath() really only designed to work well with cubic curves? I don't have cubic curves with C2 continuity. If anything, I would have to make them up based on the polylines.

Nathan

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment