[solved] support for degree symbol in a new added font

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
jbarea
Normal user
Posts: 17
Joined: 24 Jun 2021, 00:21

[solved] support for degree symbol in a new added font

#1 Post by jbarea » 02 May 2023, 04:30

Hi,

I added a new 20pt font (robotomono) to use with the TFT plugins succesfully. First I download the corresponding ttf file from internet and then I used fontconvert to obtain the .h file to be moved to the src/static/Fonts folder. Then I added some lines in AdafruitGFX_helper.h and AdafruitGFX_helper.cpp following the lines for the whiterabbit 20pt font. However, even when the robotomono supports the degree symbol originally and other characters, like ntilde, the version obtained with this process doesn't contain these special characters in the compiled firmware. I would like to know what I have to do to get these characters working. In addittion I would like to know how the values for the arguments of the function "calculateTextMetrics" are obtained.

Cheers,

Jose.

jbarea
Normal user
Posts: 17
Joined: 24 Jun 2021, 00:21

Re: [solved] support for degree symbol in a new added font

#2 Post by jbarea » 04 May 2023, 03:08

I solved this issue using some kind of font hacking. I resort to the utility mentioned in https://www.foobarflies.io/adafruit-gfx ... ustomiser/ and finally I replaced the character ^ by the degree symbol. To do this first I realized that the fontconvert utility has 2 addtional arguments to specify the first and the last character to include in the font .h file, corresponding to their numerical ascii code. Then my first attempt was to include the font with extended characters beyond those whose ascii code has only 7 bits (7b) , including the degree symbol which correspond to 0xb0 (it needs 8 bits to be specifed, 8b). Since this it doesn't work, finally I used the font without extension but with the ^ character replaced by °. In this process, when including different fonts in the compilation I realized a small bug in the firmware which it makes troubles when using the command to select a font in the TFT plugins. The lines 806 and 807 of src/src/Helpers/AdafruitGFX_helper.cpp should be exchanged to avoid this issue.

Cheers,

Jose.

User avatar
Ath
Normal user
Posts: 3518
Joined: 10 Jun 2018, 12:06
Location: NL

Re: [solved] support for degree symbol in a new added font

#3 Post by Ath » 04 May 2023, 08:48

jbarea wrote: 04 May 2023, 03:08 In this process, when including different fonts in the compilation I realized a small bug in the firmware which it makes troubles when using the command to select a font in the TFT plugins. The lines 806 and 807 of src/src/Helpers/AdafruitGFX_helper.cpp should be exchanged to avoid this issue.
Thanks for the report, I'll fix that.
/Ton (PayPal.me)

jbarea
Normal user
Posts: 17
Joined: 24 Jun 2021, 00:21

Re: [solved] support for degree symbol in a new added font

#4 Post by jbarea » 04 May 2023, 18:20

Ok, no problem, but, I am still wondering how the special characters like the degree symbol can be shown using the default font, but it is not possible with any of the adafruit extra fonts which can be incorporated in custom builds, even when the utility fontconvert can produce .h files including these characters beyond the character ~, 0x7E ascii code. If this functionality was present, then the replacement of characters would be unnecessary.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 125 guests