Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Wide Font Support

Question

> My team is trying the nuttx graphics with chinese fonts, but nx seems not
> support fonts quantity more than 256 chars, right?

Answer

NuttX currently only uses fonts with 7-bit and 8-bit character sets. But I believe that that limitation is mostly arbitrary. It should be a simple extension to the font subsystem to use 16-bit fonts.

Adding 16-Bit Font support

Current 7/8-bit Font Implementation

All of critical font interfaces allow for 16-bit character sets:

...

  • It creates the C file (like nxfonts_bitmaps_sans17x22.c) by compiling nxfonts_bitmaps.c and including nxfonts_sans17x22.h to create the font dataset at build time.

The function{{ function nxf_getglyphset()}} in the file nxfonts_getfont.c selects the 7-bit font range (codes < 128) or the 8-bit range (code >= 128 > 256). The fonts are kept in simple arrays splitting the data up into ranges of values lets you above the non-printable codes at the beginning and end of each range. There is even a comment in the code there "Someday, perhaps 16-bit fonts will go here".

Adding Wide Fonts

To add a single wide font, the easiest way would be to simply add the final .C file without going through the C auto-generation step. That should be VERY easy. (But since it has never been used with larger character sets, I am sure that there are bugs and things that need to be fixed).

...

I am willing to help and advise. Having good wide character support in the NuttX graphics would be an important improvement to NuttX. This is not a lot of code nor is it very difficult code so you should not let it be an obstacle for you.

Font Storage Issues

One potential problem may be the amount of memory required by fonts with thousands of characters. If you have a lot of flash, it may not be a problem, but on many microcontrollers it will be quite limiting.

...