cancel
Showing results for 
Search instead for 
Did you mean: 

How to write a monospace (fixed-width) string to LCD?

EPois.1
Associate

Hello, I want to write time on LCD in format 00:00:00 (hh:mm:ss). I use simple text area object and font I use is Proxima Nova Semibold. But the problem is that text is moving around because each char have different width. I would like to each char stay in the position.

I am new to Touch GFX framework.

I manage to achieve what I need using a monospace font. But I need to use Proxima Nova Semibold.

For now only though I have to write each character separately with different position, but is there some other option?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
scottSD
Lead

I recently edited a font's numerical characters using Font Forge and generated it as a new monospaced font ttf file and copied this into the assets\font TouchGFX directory.

Font Forge is a free program.

In Font Forge, find the characters you want to change. Right click on them to find the largest width (in my font, this was "0"), and set the width of the rest of the characters you want to change to that value. Then generate the font.

Hope that helps.

View solution in original post

3 REPLIES 3
Martin KJELDSEN
Chief III

You can't achieve proper mono-space functionality with a non-mono space font unless you do as you're doing now.

/Martin

scottSD
Lead

I recently edited a font's numerical characters using Font Forge and generated it as a new monospaced font ttf file and copied this into the assets\font TouchGFX directory.

Font Forge is a free program.

In Font Forge, find the characters you want to change. Right click on them to find the largest width (in my font, this was "0"), and set the width of the rest of the characters you want to change to that value. Then generate the font.

Hope that helps.

Great tip, @scottSD​.  We also use font forge here. Besides forcing "mono-space", you can also mix and match glyphs even in some of the reserved ranges and reference those, if you want to avoid using multiple TextAreas for a string with mixed regular, italic and bold glyphs. Fontforge gives you a range of options here.

/Martin