Skip to main content
Dfarr.1
Associate III
October 30, 2020
Question

Access unicode characters supported by a particular wildcard buffer?

  • October 30, 2020
  • 11 replies
  • 2344 views

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?

This topic has been closed for replies.

11 replies

Martin KJELDSEN
Principal III
November 2, 2020

Hi,

It's just an array of `Unicode::UnicodeChar` - You know which buffer belongs to a text area, so just iterate through it as you would any array.

/Martin

Dfarr.1
Dfarr.1Author
Associate III
November 2, 2020

Where is this array? What's its name?

I'm not after the wildcard buffer itself. I need the array that contains all possible unicode characters supported by the typography of a particular wildcard buffer's textarea.

Dfarr.1
Dfarr.1Author
Associate III
November 2, 2020

Based on naming in TouchGFX designer, I think I'm looking for "wildcard range" in code somewhere. But I haven't been able to find it yet.

Dfarr.1
Dfarr.1Author
Associate III
November 5, 2020

I still haven't been able to find the wildcard range in code anywhere. Can anyone point me in the right direction?

AJT141
Associate III
November 5, 2020

I imagine you are looking for something like files located at "yourProject\TouchGFX\generated\fonts\src".

For example when i create this font with this range :0693W000005AXTQQA4.pngI can find these files :

0693W000005AXTuQAO.pngIn the last file Font_ALGER_TTF_10_4bpp_0.cpp you can find the declaration of all Unicode characters for your font

regards,

Ajt

Dfarr.1
Dfarr.1Author
Associate III
November 6, 2020

That generated folder was exactly what I was after. I was looking in totally the wrong place.

I'm going to iterate over the Unicode column (column index 1) of the Table file to select only characters defined in the typography for my string editor.

Thanks for the reply.

AJT141
Associate III
November 6, 2020

Ok nice.

Do not hesitate to share your code after implementing it and then close the question !

AJT​

Dfarr.1
Dfarr.1Author
Associate III
November 6, 2020

I spoke too soon.

I'm unable to access the Table_FontName_##_#bpp.cpp file from my code.

The GlyphNode table in this file is what I think I need to access, but the file is a cpp file with no header guard. So I can't include it in my source to access the table directly.

I can access the ApplicationFontProvider, but this only exposes Font.getGlyph() function which requires that I already know the unicode I'm looking for. Also I'm not interested in the glyphs, I just need the "next unicode character" in the wildcard range.

My goal is to iterate through the available unicode characters defined in the Table file without my code knowing in advance what they are.

Any suggestions?

AJT141
Associate III
November 6, 2020

I found (link) that you obtain a null pointer when you call Font.getGlyph() function with an Unicode::UnicodeChar value representing a char not defined for your font ? So you can iterate through all possibilities and then find what are all characters defined for your font ?

But maybe, and I really think so, that there is a proper way to do that !

AJT

Dfarr.1
Dfarr.1Author
Associate III
November 9, 2020

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)
}

AJT141
Associate III
November 9, 2020

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