cancel
Showing results for 
Search instead for 
Did you mean: 

Access unicode characters supported by a particular wildcard buffer?

Dfarr.1
Senior

I'm building a (non-touch) simple hardware UI which needs to implement a primitive string editor. I'll be taking the "select a cursor position, enter, then select a character" approach.

I have everything in place now, with the exception of character selection. I want to increment and decrement my way through the complete list of unicode characters supported by a given wildcard buffer.

How would you recommend I access and iterate through the generated list of available unicode characters that a particular wildcard buffer supports?

11 REPLIES 11
Dfarr.1
Senior

Yes I had a look at Font.getGlyph(). Yes it returns null when no character is found. But Unicode is BIG and I wanted to avoid iterating through all possible unicode values since most likely the wildcard range of supported characters for a given field will be very small.

What I've done is extend the GeneratedFont class (FontTableAccessor : public GeneratedFont), and create two public accessors for ConstFont.glyphList and ConstFont.listSize.

Then I used the ApplicationFontProvider (fontProvider) to get the Generated font for the typography I'm interested in, then down-cast it to my new class extension.

Class heirarchy looks like this:

FONT -> CONSTFONT -> GENERATEDFONT -> FONTTABLEACCESSOR

  • ConstFont is the home of glyphList and listSize (the information we're after).
  • GeneratedFont is created for each typography when Designer generates code.
  • FONT gets returned by the ApplicationFontProvider we can access from user code in the model.
  • FontTableAccessor is my small addition to get at the protected members I needed.
FontTableAccessor* fontTableAccessor = (static_cast<FontTableAccessor*> fontProvider.getFont(Typography::XLARGE)));
const touchgfx::GlyphNode * glyphList = fontTableAccessor->getGlyphList();
int glyphTableSize = fontTableAccessor->getListSize();
 
for (int i = 0; i < glyphTableSize; i++)
{
// compare current character to glyphList[i].unicode
// then return glyphList[i+1].unicode (with some additional logic to make it circular)
}

Ok thanks for your anwser. Looks like it is a proper way to do that !