2020-10-30 09:44 AM
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?
2020-11-09 11:53 AM
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
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)
}
2020-11-09 12:03 PM
Ok thanks for your anwser. Looks like it is a proper way to do that !