2024-02-13 09:35 AM - edited 2024-02-16 03:41 AM
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
2024-02-16 03:38 AM - edited 2024-02-16 03:38 AM
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
2024-02-22 04:21 AM
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.
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:
What do you think ?
Ferro
2024-02-26 11:15 PM
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
}