cancel
Showing results for 
Search instead for 
Did you mean: 

How to check in application whether Binary Font needs to be installed

ferro
Senior II

Hi,

When I select use Binary Font in GFX, I would like to determine this in my app so I install the font. How to do that please ?

Thank you

 

ferro_0-1699975741787.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @ferro,

There are no direct way to determine this, however, you can check if tables created for a font is empty or not. You can check this by using the getCharWidth(constUnicode::UnicodeChar cfor an arbitrary character. Just make sure that you have used this character with your font. If the character is available but BinaryFont is set, then the returned value from that function will be 0.
I hope this helps

Mohammad MORADI
ST Software Developer | TouchGFX

View solution in original post

3 REPLIES 3

Hello @ferro,

There are no direct way to determine this, however, you can check if tables created for a font is empty or not. You can check this by using the getCharWidth(constUnicode::UnicodeChar cfor an arbitrary character. Just make sure that you have used this character with your font. If the character is available but BinaryFont is set, then the returned value from that function will be 0.
I hope this helps

Mohammad MORADI
ST Software Developer | TouchGFX

Hi @Mohammad MORADI ESFAHANIASL 

Thanks. I did that but I realised asking for number of glyphs in a font is more pleasing approach (0 if font not installed/present) as we disscuss here:

https://community.st.com/t5/stm32-mcus-touch-gfx-and-gui/how-to-get-number-of-glyphs-in-a-font/m-p/610254

You can add a function to ConstFont.hpp file that returns the number of glyphs for you. For instance, add this function in the public section of the class definition:

uint16_t getNumberOfGlyphs() const { return listSize; }

then you can easily use it wherever you want. Like:

const ConstFont* fn = (const ConstFont*)(textArea1.getTypedText().getFont());
uint16_t numberOfGlyphs = fn->getNumberOfGlyphs();
touchgfx_printf("%d\n",numberOfGlyphs);

I hope this helps you, good luck

Nice to hear 

Mohammad MORADI
ST Software Developer | TouchGFX