I enter font symbols into the u8g.setFont() and I get a string of sympols. How do I grab just one of those symbols, for example an arrow?
setFont just tell how display the next
drawStr (or similar text output function).
To draw an arbitrary UTF8 char, just use
u8g2_uint_t U8g2::drawUTF8(u8g2_uint_t x, u8g2_uint_t y, const char *s)
u8g2_uint_t u8g2_DrawUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *s);
Draw a string which is encoded as UTF-8. There are two preconditions for the use of this function:
- The C/C++/Arduino compiler must support UTF-8 encoding (this is default for the gnu compiler, which is also used for most Arduino boards), and
- The code editor/IDE must support and store the C/C++/Arduino code as UTF-8 (true for the Arduino IDE).
If these conditions are met, you can use the character with code value greater than 127 directly in the string (of course the character must exist in the font file, see also setFont).
Advantage: No escape codes are required and the source code is more readable. The glyph can be copied and paste into the editor from a "char set" tool.
Disadvantage: The code is less portable and the strlen function will not return the number of visible characters. Use getUTF8Len instead of strlen.
Arguments: u8g2: A pointer to the u8g2 structure. x, y: Position of the first character on the display. s: UTF-8 encoded text.
Returns: Width of the string.
Note 1: This drawing function depends on the current font mode and drawing color. Note 2: Use the print function to print the value of a numeric variable.
See also: setFont drawStr print
u8g2.setFont(u8g2_font_unifont_t_symbols); u8g2.drawUTF8(5, 20, "Snowman: ☃");