How to render (fast) text on path?
How to render (开发者_C百科to image) text on path with any renderer working on linux?
Like this: text on path.
Performance is important.
Short answer:
I'm on a Debian Squeeze system with the python-cairo package installed. If I run the warped text example it provides (85 lines of Python):
python /usr/share/doc/python-cairo/examples/warpedtext.py
it produces a warpedtext.png file like this:
I imagine it'd be fairly easy to modify/adapt/port the example.
Long answer:
There are two things you need to do this.
- The ability to generate the transforms which will place individual letters with the correct position and orientation along the path. This is basic 2D transform geometry.
- The ability to render transformed characters/font glyphs with a decent level of quality (sub-pixel precision, antialiasing etc).
For the latter, I'd be looking at one of
- Qt's QPainterPath (this example seems to be exactly what you want, but see also this one).
- Cairo (another example).
- Anti-Grain Geometry.
精彩评论