TFT Font Creation during runtime

Thread Starter

aamirali

Joined Feb 2, 2012
412
Hi

While interfacing TFT, to print any font it correspond to large no of bytes for each font.

Is there any method that byte data corresponding to font can be made at run time, instead of storing huge bytes of data in flash
 

THE_RB

Joined Feb 11, 2008
5,438
A 5x7 font can be stored with about 96 characters at 5 bytes each, so that is only 480 bytes.

Then you can display it scaled up 1:2 so it becomes a 10x14 sized font. Scaling can be done real time in your function that draws each font character to screen.
 

takao21203

Joined Apr 28, 2012
3,702
any example how to scale up during run-time
You simply need to modify the pixel blitter inside the font drawing code.
If you have ANDed with the mask and get a "1", you draw two pixels, and advance two raster positions.

If you wish to do so, you would even draw 4 pixels.

2. You only need to store the characters you really use.
You can shorten the font table.
Use another reloctation table. Which is 128 bytes, if you only cover 128 characters.
But the font data can be 26 bytes only.
You use an 1-byte entry from the relocatation table, to point to an individual character!

this way you can also maintain proportional fonts. They look much better for letters like "I"
 

THE_RB

Joined Feb 11, 2008
5,438
I'm not sure about Takao's explanation (maybe I misunderstood?) but if you are working at a drawpixel level you draw a "pixel" as a square of 2x2 pixels (which is a double-scale pixel) and after each "pixel" is drawn you advance X coord by 2, and after a row is done advance Y coord by 2.

Likewise you can draw a "pixel" as a square of 3x3 pixels, and advance X and Y coords by 3 accordingly. The whole thing can be wrapped in a function, as the same size of the square (2 or 3) is the same as the coord advance (2 or 3) so can be expressed as a single "scale" variable. That lets you scale fonts up any amount you like, but after scale 3 or 4 they start to look very square and clunky.

You could add a corner smoothing algorithm (I've thought about it) but it's annoying as you have to analyse all 8 pixels around the pixel you are processing, so requires some messy and slow code.
 
Top