2025-03-15 6:03 AM
Hi all, i search properties for manage showed multinumber counters without not cool moving.
For example num 123 121 111 . Align not help here .
My idea is mark textarea as number aligned and render calculate widths from font for 0-9 and use it to convert showing as monospaced .
Ofcourse font editor can change this , but better is switchable choice. Exist or is this doable in an TGFX version?
2025-03-17 4:57 AM
Hello @MM..1 ,
You could directly use a monospaced font, this way you don't even have to mana the spacing of your characters.
This is also the preferred way of doing it because if you make a trip to add space when needed on a non monospaced font, it will look weird as a "i" will have a lot of space around it.
However, if you still want to do a trick, I see 2 ways of doing it:
Overall I would recommend to simply use a monospaced font in a regular textArea.
If you share the design you want to achieve, maybe we can find a simple work around.
Regards,
2025-03-17 9:12 AM
Sorry , but you maybe never create GUI and use fonts. Normal way is graphics designer choice font and programmer apply it. But in real world most good design is proportional !
Maybe you missunderstand i ask about number characters only . 0 1 2 3 4 5 6 7 8 9
But for universal use i dont see trouble create func as textArea2.setMonoWidth(20);...
Now API have for example textArea2.setIndentation(20);
2025-03-20 2:34 AM
Hello.
There is no API to control the spacing of characters. TouchGFX will use the spacing in the font.
And you are right, the font is often selected by a designer person.
One option is to modify the font to use same spacing for all characters.
Second option is to use multiple TextAreas. Maybe also not pratical, but would work
A third option is to modify the output of the font converter. For the numbers, this is not difficult.
Here is an example:
I used the font Comic Sans MS in size 150.
We can easily see that the '1' are narrower than the '0'.
This can also be seen in the generated output. Take a look in the file generated/fonts/src/Table_comic_150_4bpp.cpp:
This table describes the width, height and other properties of the letters in the bitmap font.
The second number is the unicode. The 7'th number is the advance. This is the number of pixels that the "cursor-position" in moved after drawing the letter. We see that unicode 0x0031 = '1' is has an advance of 68 pixels, whereas the other number have advance=92.
If I modify 68 -> 92 I get this screen in the simulator (Designer still uses the TrueType file):
I you go this way, I suggest to create a patch file to do this modification, as the font converter will overwrite this file if you use new letters in this font.
I advice against modifying the generated files in general!
But so far best hack this week.
2025-03-20 6:01 AM
Thanks Flemm, i ask this as requested feature in next versions , create workarounds is next dev time.
I know many ways to handle this ugly ... Your solution isnt design ok , because not only advance is required , but divide advance diff on left and right side to center char in monospace place.
2025-03-20 6:12 AM
The number before the advance is the left indent.
Adding 12 here moves the '1' to the center of the letter box:
Changes this:
to
I hope it is useful.
Thanks!
2026-05-06 7:12 AM
Hi after year. I ask some idea. In LVGL is simple create "cloned font" with callback info as this
bool fix_w_get_glyph_dsc(const lv_font_t * f, lv_font_glyph_dsc_t * g, uint32_t letter, uint32_t letter_next)
{
/*Get the original glyph_dsc*/
bool ret = lv_font_get_glyph_dsc_fmt_txt(f, g, letter, letter_next);
if(ret == false) return ret;
g->adv_w = 90-8; // 1463/16 based on width of zero
g->ofs_x = (g->adv_w - g->box_w) / 2;
if(letter==45)g->ofs_x+=20;
return true;
}This works ok and manage font as monospace. Now to your table generated as const. Simply i can in code memcpy it to ram and create font alias , but search all connections in TouchGFX is hard without source. Try create this code example on your side @Flemming Gram CHRISTENSEN
2026-05-06 7:27 AM - edited 2026-05-06 7:36 AM
Figure space:
https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/digit-alignment-not-optimal-because-quot-figure-space-quot-not/td-p/687672
Tnum support:
https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/tnum-support-for-fonts-such-as-arial/td-p/865991
2026-05-06 8:52 AM
Maybe you missunderstand detail, i use font as proportional and require only one textarea without = your ide 2 fonts = extreme waste of memory asume my font is size 240 and is absurd store same characters twice.
Then ofcourse i know how change font spaces python or any other way , but as i wrote all this is waste dev time and energy. Only real for me is A/ area properties and render AI ( TGFX release time maybe after next 10 years)
B/ simple font function to clone font tables from flash to ram except chars, with use same char data plus corect pairs or width tables.
I preffer A variant , but i ask it year ago and nothing here change.
2026-05-06 9:53 AM - edited 2026-05-06 9:54 AM
@MM..1 wrote:Maybe you missunderstand detail, i use font as proportional and require only one textarea without = your ide 2 fonts = extreme waste of memory
No I only use 1 font.
So if I understand correctly you want to render the font differently depending on the context? So you can have both monospaced and proportional digits in the same application without storing additional glyths in FLASH?
@MM..1 wrote:is absurd store same characters twice.
Indeed. And nowhere did I propose this.
@MM..1 wrote:A/ area properties and render AI ( TGFX release time maybe after next 10 years)
? How is AI going to fix it? AI in TouchGFX Designer or edge AI deployed on target? The latter certainly won't happen.
@MM..1 wrote:B/ simple font function to clone font tables from flash to ram except chars, with use same char data plus corect pairs or width tables.
This could add more features to fonts. Such as changing spacing (compact or wide) and enabling tnum seperately for each text field and for each language. I would support this feature.