Downloadable fonts - Reference error.

Here we can discuss about the problem found
Post Reply
AndyGadget
Posts: 62
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 24 times
Been thanked: 54 times

Downloadable fonts - Reference error.

Post by AndyGadget »

Annex32 WiFi CAN 1.43.4

There appears to be an error in the reference point for tft.text.pos for downloaded fonts.
In the example below the X and Y print positions are the same for each pair so the text should be overlaid.
It looks like the reference point for tft.text.pos is top left for the inbuilt fonts, and bottom left for the downloaded fonts.

And a suggestion; It would be more logical if the downloaded fonts in tft.loadfont were 0 and 1 rather than 1 and 2.
This would then correspond to tft.text.font 10 and 11.

Code: [Local Link Removed for Guests]

TFT.INIT 1

tft.loadfont "/FreeMono12pt7b.bin",1
tft.loadfont "/FreeMono24pt7b.bin",2

tft.text.font 4
tft.text.pos 30,50
tft.print "X Inbuilt"

tft.text.font 10
tft.text.pos 30,50
tft.print "X Dload"

tft.text.font 4
tft.text.pos 30,150
tft.print "X Inbuilt"

tft.text.font 11
tft.text.pos 30,150
tft.print "X Dload"
cicciocb
Site Admin
Posts: 309
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 85 times
Been thanked: 197 times
Contact:

Re: Downloadable fonts - Reference error.

Post by cicciocb »

Hi Andy,
this is inside the library, I think that it works well for the GUI, maybe you could confirm if it is the case.

About the numbering of the loaded fonts, during the development I changed my advice a lot of time (0 or 1, 10 or 11) :D

Probably the best is to leave as it is, in the case someone already developed some program.
AndyGadget
Posts: 62
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 24 times
Been thanked: 54 times

Re: Downloadable fonts - Reference error.

Post by AndyGadget »

Thanks Francesco, I'd forgotten all about TFT.TEXT.DRAW.
Specifying the alignment works fine.
I'll start using it instead of TFT.PRINT.

Code: [Local Link Removed for Guests]

TFT.INIT 1

tft.loadfont "/FreeMono12pt7b.bin",1
tft.loadfont "/FreeMono24pt7b.bin",2

tft.text.align 0

'tft.text.font 4
'tft.text.pos 30,50
tft.text.draw "X Inbuilt", 30,50,4

'tft.text.font 10
'tft.text.pos 30,50
tft.text.draw "X Dload", 30,50,10

'tft.text.font 4
'tft.text.pos 30,150
tft.text.draw "X Inbuilt" , 30,150,4

'tft.text.font 11
'tft.text.pos 30,150
tft.text.draw "X Dload", 30,150,11
Post Reply