开发者

How to render (fast) text on path?

开发者 https://www.devze.com 2023-04-09 06:52 出处:网络
How to render (开发者_C百科to image) text on path with any renderer working on linux? Like this: 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:

How to render (fast) text on path?

I imagine it'd be fairly easy to modify/adapt/port the example.

Long answer:

There are two things you need to do this.

  1. 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.
  2. 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.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号