Page 1 of 1

Downloadable fonts - Reference error.

Posted: Fri Jul 23, 2021 8:04 pm
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"

Re: Downloadable fonts - Reference error.

Posted: Sat Jul 24, 2021 7:47 am
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.

Re: Downloadable fonts - Reference error.

Posted: Sat Jul 24, 2021 9:23 pm
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