View Full Version : Text on Image

11-16-2010, 02:48 PM
Hi all,

Given I'm very new to OpenVG, and I have had no luck finding documentation or samples that give me pointers, I decided I should try his place.

My problem is divided into two issues:

1) Draw text
2) Draw that text on an Open VG Image.

For #1 I'm not finding anything that fully shows how to render text. I have seen a lot of talk of the glyphs, fonts and what not, but no code sample that show all steps required to paint a string at a certain position with a certain formatting.

For #2 I have read on the OpenVG 1.1 Specifications that you can target an image for your painting, but I'm not able to understand how this is done, and I can't find a sample where you paint on an image and then paint that "edited" image onto the screen.

What I'm trying to achieve is writing text onto an image and then display that image.


Ivo Moravec
11-17-2010, 02:01 PM
- Get Freetype. Use it to read ttf files.
- make OpenVG path data out of that with Hybrid's old font2openvg.cpp code (or write your own). This will generate the glyph data in a format you can use (it will make a .c or .h file you can include in whatever project you need it in).

- Then, in the program you're rendering in, create the font object and populate the glyphs with the path data. Then it's just a matter of calling the vg funtions to render text.

See http://www.khronos.org/message_boards/viewtopic.php?f=6&t=1385&start=0 for details and some source. The font section in the VG spec is fairly well written though - it's doesn't require cross referencing every other word.

If you're using EGL, then you can use eglCreatePbufferFromClientBuffer(). Just use eglMakeCurrent() to switch to the pbuffer, and after you switch back the image will be populated. (Caution: you might want to use eglMakeCurrent() with NULL to disconnect from the current context before making a new one current).

If eglCreatePbufferFromClientBuffer() is not available, use any off-screen surface (or, if the screen is double buffered, and trashing the contents of the frame buffer is not an issue, just use the normal window surface), and use vgGetPixels()/vgReadPixels() to transfer it into your image.

The text bit is the same as in part #1.