How set ° symbol in drawString #815
Unanswered
brightproject
asked this question in
Q&A
Replies: 2 comments 1 reply
-
|
hi, TomThumb has the degree symbol at 0xB0 if you enable the extended ascii set. char degree_sym = { 0xB0, 0x00 }; // extended ascii
tft.setFont(&fonts::TomThumb);
tft.printf("The temp is 20 %s\n", degree_sym);However if you paste the degree symbol in your code, it'll probably be its utf8 representation (0xC2B0) and won't be matched in the TomThumb font set, it will only work a unicode font. Fortunately u8g2 has plenty of those. tft.drawChar( 0xC2B0, x, y, &MyUnicodeFont ) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Unfortunately, I couldn't do it using char.
It complains that the function requires 7 elements, but I only provided 4. draw.setTextDatum (MC_DATUM);
draw.setFont(&fonts::FreeSansBold12pt7b);
draw.setTextColor(TFT_LIGHTGRAY);
draw.drawString("HDG", 150, 105); // LEFT-RIGHT, UP-DOWN
draw.setTextColor(TFT_ORANGE);
draw.drawString("HDG", 152, 106); // LEFT-RIGHT, UP-DOWN
draw.setFont(&fonts::DejaVu72); // The biggest font I found
draw.setTextColor (TFT_LIGHTGRAY);
draw.drawString(String(heading), px0, py0);
String degreeSymbol = String((char)0xC2) + String((char)0xB0); // Degree symbol
draw.drawString(degreeSymbol, px0 + 70, py0 - 11, &fonts::lgfxJapanMinchoP_40); // LEFT-RIGHT, UP-DOWN
draw.setTextColor (TFT_YELLOW);
draw.drawString(String(heading), px0 + 2, py0 + 2);
draw.drawString(degreeSymbol, px0 + 71, py0 - 10, &fonts::lgfxJapanMinchoP_40); // LEFT-RIGHT, UP-DOWNIt turned out pretty well🙂 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
I'm using sprites
The degree symbol isn't displayed; the library doesn't accept the encoding.
I found the only clue in
font 16.But I don't use this font.
How do I display
UTF-8orASCIIcharacters correctly?Beta Was this translation helpful? Give feedback.
All reactions