cancel
Showing results for 
Search instead for 
Did you mean: 

What tool can show font properties that class touchgfx::Font provides

ferro
Senior III

Hi,

Gfx::Font class returns many font properties e.g. Font::getBaseline (), Font::getPixelsAboveTop () etc.
https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_font

Is there a tool that can show all these properties ? With FontForge somehow ?

Thanks
Ferro

3 REPLIES 3
LouisB
ST Employee

Hello @ferro ,

There's no tool since the font is compiled into a ".cpp" file, but you can see what values has been pass in "touchgfx/generated/fonts/src/Table_<typography>.cpp" for each properties : 

 

 

And the "GeneratedFont" constructor is :

 

I hope that answers your question,
Regards

Louis BOUDO
ST Software Developer | TouchGFX

Hi @LouisB ,

Thanks for the GeneratedFont reference.

Do you think, that some of these font properties (or at least font height based on user selected size) could be shown in Gfx Designer dynamically, before running font code generator ?

Reason I am asking is realisation that, even though I set the same 'Text:Typography:font size' for 2 fonts (which sets font's baseline), the font heights differ - font_1.getHeight () is 25px and font_2.getHeight () is 26px.

ferro_0-1708602470803.png

font_1;  size(or baseline) 20px, height 25px

 

touchgfx::GeneratedFont& getFont_verdana_20_4bpp()
{
    static touchgfx::GeneratedFont verdana_20_4bpp
	(
		glyphs_verdana_20_4bpp,        * @param  glyphs        
		512,                           * @param  numGlyphs     
		25,                            * @param  height        
		20,                            * @param  baseline      
		0,                             * @param  pixAboveTop   
		...
	);
    return verdana_20_4bpp;
}

 

 

font_2;  size(or baseline) 20px, height 26px

 

touchgfx::GeneratedFont& getFont_NotoSC_20_4bpp()
{
    static touchgfx::GeneratedFont NotoSC_20_4bpp
	(
		glyphs_NotoSC_20_4bpp,          * @param  glyphs        
		375,                            * @param  numGlyphs     
		26,                             * @param  height        
		20,                             * @param  baseline      
		2,                              * @param  pixAboveTop   
		...
	);
    return NotoSC_20_4bpp;
}

 

 

Therefore, the font's height would be a valuable information while setting font size/baseline. Before running font code generator and having to check laboriously resulting "touchgfx/generated/fonts/src/Table_<typography>.cpp". Something like this:

ferro_1-1708603411289.png

What do you think ?

Ferro

LouisB
ST Employee

Hi @ferro ,
I'm reposting one of the answer that solves your issue but was delete since it was mark as a spam

#include "touchgfx/Font.hpp"

void fontProperties()
{
// Using the Font class to get font properties
// For example:
// Baseline of the font
int baseline = Font::getBaseline();

// Pixels above the top of the font
int pixelsAboveTop = Font::getPixelsAboveTop();

// You can explore more font properties using the Font class

// For detailed information on the Font class and its properties,
// refer to the TouchGFX documentation:
// https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_font

}

 

Louis BOUDO
ST Software Developer | TouchGFX