Skip to main content
Lead II
December 19, 2025
Solved

tnum support for fonts such as Arial

  • December 19, 2025
  • 7 replies
  • 838 views

I like my digits to be monospaced so they don't dance, but I want letters to be proportional. I want to use 1 font for this. There are fonts that support this. These are called tabular fonts. They have monospaced digits and support figure space (0x2007) for alignment.
There are fonts that support this that are also available in TouchGFX Designer:

  • Segoe UI
  • calibri
  • Tahoma

This works. I wrote some code that replaces leading spaces before digits with digit spaces if the font supports it. This works really well and numbers no longer dance. Alternatively you can right-align a text field. But then you cannot have any text before it or you have to split the text in parts (so printf is not possible anymore and you might as well use two different fonts).
Another way is to modify a font (make digits same width and remove kerning for digits, and add figure space). I've done this, but this is a lot of work. And this is not allowed for many fonts (our customer allowed us to do this).

There are other fonts that also have tabular digits as an option via "tnum" (Tabular Figures) such as Arial. Example of such a font:

unsigned_char_array_0-1766157515062.png

Is there a way to enable it for Arial in TouchGFX? If not will be be supported in the future?

Best answer by ferro

You can modify with a python script. FFPython.

 

CLI>> "c:\Program Files (x86)\FontForgeBuilds\bin\fontforge.exe" -script show_glyphs.py
import fontforge

def print_width_digits ():
 # Numbers '0' - '9' ie 48-58 
 for digit in range ( 48, 58 ):
 glyph = font[digit] # Get glyph by character

 if glyph.unicode != -1: # -1 means the glyph has no Unicode mapping
 char = chr(glyph.unicode)
 print ( f"Character '{char}' width: {glyph.width}" )
 else:
 print(f"Glyph name: {glyph.glyphname}, Unicode: None")

 
# Open the font file
font = fontforge.open("font.ttf") # Replace with your font file

print_width_digits ()

 

 

ferro_0-1767899248130.png

 

7 replies

Peter BENSCH
Technical Moderator
December 22, 2025

I would like to leave the answer to your question to the TouchGFX specialists, but I would like to point out an important aspect of your question:

TouchGFX can use all fonts installed on the Windows system – but that does not imply that you are allowed to use them in your embedded system! Like other creative works, fonts are subject to copyright and must be licensed for use in embedded systems.

A conflict-free approach, on the other hand, would be to use open-source fonts, which can be found at Google Fonts, among other places, but you must then also observe the terms of the licence text.

You have to be extremely careful not to end up with a very expensive lawsuit from a solicitor.

Regards
/Peter

Lead II
January 5, 2026

I am aware of licensing of fonts. I assumed that the fonts that fonts that came with TouchGFX are licensed to work with products that run TouchGFX. Is this not true? If that's the case I think it's appropriate to have TouchGFX issue a warning when using an unlicensed font.

I looked up the following fonts:

  • Segoe UI
  • calibri
  • Tahoma
  • Arial

Segoe UI needs licensing from Monotype. https://learn.microsoft.com/en-us/typography/fonts/font-faq
Selawik is an alternative that's free for commercial use. Though that doesn't come with Windows.

Same for Calibri. Aptos is an alternative, but that one is not free for commercial use.

Tahoma is not free either. There is an open source alternative: "Wine Tahoma" which is licensed under LGPL 2.1.

Arial is not commercial either.

This is a problem.

We might already have shipped some products with non-commercial fonts that came with TouchGFX without realizing it.

 

"Kudo posts if you have the same problem and kudo replies if the solution works.Click ""Accept as Solution"" if a reply solved your problem. If no solution was posted please answer with your own."
Peter BENSCH
Technical Moderator
January 5, 2026

The fonts do not come with TouchGFX, but are part of the operating system. No application programme of any operating system known to me can check the fonts used for licence freedom; this is always the responsibility of the user.

However, an attentive programmer would also notice that the fonts are not accessed relatively (via link), but are copied to the Assets folder and then converted to different sizes (usually to bitmaps). In the case of open source fonts, the licence terms should then be placed in this folder and made available to the end user in a suitable manner.

I know that this is a nasty trap, which is why I have explicitly pointed it out here.

I would consider replacing the fonts with open source versions or purchasing licences as part of firmware updates. Legal disputes in court or injunctions can be very expensive.

Regards
/Peter

ST Employee
January 5, 2026

Hello @unsigned_char_array.

Just to clarify, TouchGFX does not come with any fonts. The fonts available in TouchGFX Designer are those installed on the Windows system plus those manually added to the fonts folder.

In regards to your question, it is not possible to enable such a feature in TouchGFX. However, you can use a tool such as e.g. FontForge to modify the width of the digits. I have not tested it myself, but I hope it will be fairly straightforward. Note that font licenses might not permit modification of the font.

Best regards,
Johan

ST Employee
January 8, 2026

Hello again.

I did a small test to verify that it works. It is quite simple to modify the digits to be monospaced with FontForge. I have attached a small simulator project demonstrating the original font at the top and the modified font at the bottom. As far as I read the license terms, you are allowed to do this modification to fonts from Google Fonts.

My procedure:

  1. Open the font in FontForge.
  2. Find the digit with the largest width (542 in my case).
  3. Set all digits to the largest width and center the digits.
  4. Export the modified font following this guide: https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/vector-fonts#using-fontforge.

Best regards,
Johan

ferro
ferroBest answer
Lead
January 8, 2026

You can modify with a python script. FFPython.

 

CLI>> "c:\Program Files (x86)\FontForgeBuilds\bin\fontforge.exe" -script show_glyphs.py
import fontforge

def print_width_digits ():
 # Numbers '0' - '9' ie 48-58 
 for digit in range ( 48, 58 ):
 glyph = font[digit] # Get glyph by character

 if glyph.unicode != -1: # -1 means the glyph has no Unicode mapping
 char = chr(glyph.unicode)
 print ( f"Character '{char}' width: {glyph.width}" )
 else:
 print(f"Glyph name: {glyph.glyphname}, Unicode: None")

 
# Open the font file
font = fontforge.open("font.ttf") # Replace with your font file

print_width_digits ()

 

 

ferro_0-1767899248130.png

 

Lead II
January 9, 2026

Thanks for these answers. I will take a look at them when I'm on that project again. 
I have to note that it's not just the width of digits that make it monospaced for digits, but also the kerning. Kerning is distance to other characters. You don't want the unit or degree sign to move depending on the value of digits for instance. So kerning for digits needs to be fixed.

"Kudo posts if you have the same problem and kudo replies if the solution works.Click ""Accept as Solution"" if a reply solved your problem. If no solution was posted please answer with your own."
ST Employee
January 9, 2026

Yes, very true. This approach is a workaround rather than a perfect solution. I do not know, if there is a simple way to fix the kerning as well.

I imagine it could be used as a special typography for specific scenarios without adapting kerning. E.g. keeping the original font for inline digits, and using the modified font specifically for digit wildcards.

Best regards,
Johan

Lead II
January 21, 2026

I decided to use the IBM Plex Sans font from google fonts. This font meets all our criteria. I used a modified script from @ferro to check if figure space is supported.

"Kudo posts if you have the same problem and kudo replies if the solution works.Click ""Accept as Solution"" if a reply solved your problem. If no solution was posted please answer with your own."