Search code examples
clinuxxlibfreetype

How to draw text on XImage object in Linux


I read the reference of Xft library, but it seems to draw text only on server site drawable: Pixmap or Window. The same is about the native xlib text drawing functions.

But how to draw some text on a XImage object that has an array of pixels in memory on the client site?

What library to use and where to find some reference and example sources?

There is no need for ultra-high-quality typography and probably RTL is not needed.

On the other hand it is good to have UTF-8 support and simple API.

For example FreeType seems to be not what is needed - it renders single glyphs, not directly Unicode text.

This way, what I need is the API of Xft, but for memory bitmaps. (Or as an example Win32 TextOut level function).

I prefer a plain C code examples, but any other non-OOP language is OK too.


Solution

  • most toolkits are using pango for this. If you target more than just latin scripts it is probably the only sane choice around. Otherwise plain freetype rendering might be enough for you (there are plenty of examples). If you need complex scripts but want to go low level, use freetype + harfbuzz