Results 1 to 5 of 5

Thread: Need some input regarding drawing glyphs using vgdrawglyph

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    3

    Need some input regarding drawing glyphs using vgdrawglyph

    Hi,
    I am new to openvg and currently writing some test cases for openvg1.1.
    I need some help using fonts and text rendering in openvg1.1.

    openvg1.1 spec says glyphs can be represented using VGPath objects or VGImage objects.
    Now let us see
    void vgSetGlyphToImage(VGFont font,VGuint glyphIndex,VGImage image,const VGfloat glyphOrigin[2],const VGfloat escapement[2]);
    here
    1. what shall be shall be contained in "glyphIndex" ?
    2. Is image is obtained by calling image = vgCreateImage(VGImageFormat format,VGint width, VGint height,VGbitfield allowedQuality) ?
    If so, should the image be filled using
    vgImageSubData(VGImage image,const void * data, VGint dataStride,VGImageFormat dataFormat,
    VGint x, VGint y, VGint width, VGint height)?

    I transformed *png, *jpg .. to openvg1.1 format.(different image formats like VG_sRGBX_8888, VG_sRGBA_8888 and so on ..) using PvrTextool
    but such converted data when used in vgdrawglyph() gives an image data instead of a Font or glyph!
    Can some one help me as where did I go wrong?
    Thank you
    Deepak

  2. #2
    Senior Member
    Join Date
    Feb 2006
    Posts
    115

    Re: Need some input regarding drawing glyphs using vgdrawglyph

    There's a thread here about how to render fonts already.

    To recap.
    A VGFont object is a container for "a font" and all that encompasses.
    A Glyph is a single character.
    so when you do vgSetGlyphToImage(), you are assigning a character to a certain glyph index.
    For example - a picture of the letter 'A' (in a VGImage) to that character 'A' (ascii 0x41) - the glyphindex.
    Displaying text is then a matter of telling VG to print glyph 'A' then print glyph 'B'... all for some VGFont.

    So, yes, make sure your VGImage is created normally, and filled with the data for the character you want it to represent. So, yes, use vgImageSubData to upload the glyph to the VGImage you will be using for that glyph. After setting the glyph, you can free the VGImage.

  3. #3
    Junior Member
    Join Date
    Dec 2009
    Posts
    3

    Re: Need some input regarding drawing glyphs using vgdrawglyph

    Hi Ivo,

    Thank you for your post.
    But I need some more clarification regarding glyph rendering.

    1. I used vgSetGlyphToImage() to define a glyph. Imgae data is bitmap picture of character "G".
    I observe that vgDrawImage (vgimage); and vgDrawGlyph(h_vgfont, ...); would result in similar display. I mean vgDrawGlyph() is also rendering a rectangular bitmap image of the character just like vgDrawImage().

    Is there a way to draw just the character out line instead of the rectangular image of the selected character? I need just the letter "G" It shall not be enclosed in a Box. But here it looks like a photcopy of the image that I used.

    2. I tried changing the color of the glyph using VGPaint. This did not work ( My bit map image of character was black and white).

  4. #4
    Senior Member
    Join Date
    Feb 2006
    Posts
    115

    Re: Need some input regarding drawing glyphs using vgdrawglyph

    A VGImage used as a glyph, is still an image, and works exactly the same way as a vgDrawImage(). [A VGFont just takes care of the placement details for you - the rendering is done internally basically just the same as if calling vgDrawPath() and vgDrawImage() with a different transformation matrix].

    If you want transparency, I suggest you edit the image and set the alpha channel to 0 for the bits of image you do not wish to display (make sure to save as RGBA - not just plain RGB). Alternatively, pre-process the VGImage image with vgLookupSingle() to change the alpha value [if your image is grayscale, then the table you could generate with "for (int i=0; i<256; i++) table[i] = (i<<24) || (i<<16) || (i<< || (255-i);" {I think that should do the trick...}]. The default blend mode (VG_BLEND_SRC_OVR) will handle the composition when you render it.

    Alternatively, you could create a path representation of the desired letters, and set the glyph to a VGPath (which, upon rendering, would then behave like a vgDrawPath() call).

  5. #5
    Junior Member
    Join Date
    Dec 2009
    Posts
    3

    Re: Need some input regarding drawing glyphs using vgdrawglyph

    Hi Ivo,

    Thank you for your post.
    Regards
    Deepak

Similar Threads

  1. No API for rendering glyphs to a mask?
    By HabeusCorpse in forum OpenVG and VGU
    Replies: 1
    Last Post: 10-05-2011, 11:11 AM
  2. Rendering glyphs along a curved line
    By dineshks in forum OpenVG and VGU
    Replies: 3
    Last Post: 09-02-2010, 06:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •