paeryn / openvg

Tools for exploring OpenVG
Other
11 stars 2 forks source link

[help with other project] firmwares font.c #12

Closed nagualcode closed 6 years ago

nagualcode commented 6 years ago

Dear friend, could you help make https://github.com/raspberrypi/firmware/blob/master/opt/vc/src/hello_pi/libs/vgfont/font.c compatible with utf-8, so the hello_font example be able to render latin characters too?

paeryn commented 6 years ago

I don't use the broadcom example code but changing the character reading from simple 8-bit to utf-8 is fairly trivial, the original libshapes.c has a routine that converts a character at a time from a utf-8 string into the individual 32-bit integers needed (next_utf8_char()).

For the branches from newfonts upwards I changed it to use the standard mbsrtowcs() function (multi-byte string to wide-char string) so whatever format the current C_locale is set to is used (utf-8, utf-16, etc.).