VGLite draw text example

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VGLite draw text example

2,409 Views
Flo1989
Contributor III

Hi,

i try to use the VGlite in an FreeRTOS application. I can display and prozess raster pictures without problems. But now i want to use the "vg_lite_draw_text" function to write a text. I do not find any documentation how to use it.

When i understand the code in a right Way i had to first register the font with "vg_lite_register_font". What i am missin here is how the structure of the "void *data" in vg_lite_font_params has to look like.

typedef struct vg_lite_font_params
{
    char name[MAX_FONT_NAME_LEN]; /*! font-family name */
    eFontType_t    font_type;     /*! Raster/Vector font */
    eFontWeight_t   font_weight;  /*! Font weight enum value */
    eFontStretch_t  font_stretch; /*! Font stretch enum value */
    eFontStyle_t    font_style;   /*! Font style enum value */
    int font_height;              /*! Font height in pixels */
    int data_len;                 /*! Font data buffer length */
    void *data; /*! the address where the actual font data is stored; it is the
                 * responsibility of the user/application to load it there */
} vg_lite_font_params_t;

 

Is there any documentation about this?

 

Best Regards,

Florian

0 Kudos
11 Replies

2,178 Views
howard_liu
NXP Employee
NXP Employee

@Flo1989 Hi Florian, 

To use VGLite draw text API, you must have a SVG file containing an embedded font. Please reference to the SVGTiny 1.2 for the embedded font in a SVG.

There is a vectorFontConverter tool that extracts font data from SVG files  and saves it in an intermediate data format known asVFT-VectorFont. Then it can be registered with the VGLite driver to enable applications to draw text. This tool will be released as one tool of VGLite toolkit soon.

1,624 Views
howardliu
Contributor II

I attached an example to show how to use VGLite draw text API for your reference (Only passing IAR tool). The vectorFontConverter tool can be found from NXP.

Usage: vft_create  input_svg   output_vft

After creating a VFT file, you can use the xxd tool (Linux tool, available in the msys on windows) to create a header file:

xxd -i output_vft > output.h

0 Kudos

2,173 Views
maglash64
Contributor II

Thank you for this reply, was looking for the same for some time,

Can you also shed some light on why the vg_lite_prerspective() transform function was removed from the API? using it makes the GPU stop rendering.

0 Kudos

2,165 Views
howard_liu
NXP Employee
NXP Employee

Now vg_lite_get_transform_matrix() is used to create a perspective matrix. It's easier than vg_lite_prerspective().

0 Kudos

2,131 Views
maglash64
Contributor II

Hi, can you give an example on how to use vg_lite_get_transform_matrix() API function?

I used it the following way but it did nothing.

the image is stored in the vg_lite_buffer_t image_buffer and has size 256x256 and format VG_LITE_RGBX8888,

target buffer rt is the main frame buffer.

vg_lite_point4_t src={0,0,256,256};
vg_lite_point4_t dst = {0,0,256,300};

vg_lite_identity(&matrix);

vg_lite_get_transform_matrix(src, dst, &matrix);

vg_lite_blit(&rt, &image_buffer, &matrix, VG_LITE_BLEND_MULTIPLY, 0, VG_LITE_FILTER_BI_LINEAR);

 

0 Kudos

2,120 Views
howardliu
Contributor II

@maglash64 You need to give 4-point location for src and 4-point location for dst. 

vg_lite_point4_t src={{x0, y0}, {x1, y1}, {x2, y2}, {x3, y3}};

You can reference to the code of VGLiteBlit under boards\evkmimxrt1170\vglite_appnote_samples. Below's the download link:

https://www.nxp.com/docs/en/application-note-software/AN13075SW.zip

2,392 Views
Flo1989
Contributor III

Hi,

sry but i have no access to that link.

Flo1989_0-1681895985169.png

Best Regards,

Florian

0 Kudos

2,384 Views
joanxie
NXP TechSupport
NXP TechSupport

this couldn't be shared on the public community, I will mail to you later

0 Kudos

1,137 Views
svoulaz_ik
Contributor III

Hello @joanxie ,

trying to access the link too, as we are interested in the offline tool to convert SVG to elementary structures - specifically for vector fonts. Also, a "VGLite Toolkit" is mentioned in AN13778, but I cannot find any resource. Could you help? Thanks in advance.

Stefano

0 Kudos

2,398 Views
joanxie
NXP TechSupport
NXP TechSupport
0 Kudos

2,323 Views
maglash64
Contributor II

Hi, I am also facing a similar problem, did you find the solution? What is the format of font to be placed in memory?

0 Kudos