U8g2 for Adafruit GFX - Polish fonts #2120
-
Fonts.. fonts... fonts... a lot of questions about fonts... Welcome! I'm new to programming on Arduino, so please, don't be raw. This is an only test code for biggest project, but I need to start from clean tests before go forward. #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels int i; String j = "Elbląg. Łódź"; // string with PL chars void setup() { display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS); void loop() { display.clearDisplay(); To clarify, I know that included libs not allow to read chars over 127, or even if can up to 256, according to ASCII table, PL chars starting at 260 position. I actually create two PL fonts based on FreeSans. First got chars in-line with "true" ASCII (over 256), second (used in this sketch) got PL fonts between 0-32 ASCII table. Second font works fine, until you call char by ASCII code, but in my project, string will be loaded from SD card - txt file, where people will use raw polish fonts. My idea was to read string and replace letters like "ąćęłńóśżź" with ASCII code form table using replace() command to display it on OLED. I'm stuck here. Replace command don't allow to use ASCII code, just simple "ą", "a". Any idea how to solve it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Things are mixed in your code. This is the issue tracker for u8g2. However your code uses Adafruit lib: So better ask the Adafruit people for support. In general, your problem could be solved without problems by using "u8g2lib.h"
The following example will use the built-in font helvR14, see https://github.com/olikraus/u8g2/wiki/fntgrpadobex11#helvr14 Again: By using u8g2 you can just use any none-ASCII chars directly in the code as shown in the example below. void setup(void) {
u8g2.begin();
u8g2.enableUTF8Print(); // enable UTF8 support for the Arduino print() function
}
void loop(void) {
u8g2.setFont(u8g2_font_helvR14_te);
u8g2.setFontDirection(0);
u8g2.firstPage();
do {
u8g2.setCursor(0, 15);
u8g2.print("Hello World!");
u8g2.setCursor(0, 40);
u8g2.print("ąćęłńóśżź");
} while ( u8g2.nextPage() );
delay(1000);
} |
Beta Was this translation helpful? Give feedback.
-
Wow! const uint8_t FreeMono12pt7bPLBitmaps[] PROGMEM = { const GFXglyph FreeMono12pt7bPLGlyphs[] PROGMEM = { const GFXfont FreeMono12pt7bPL PROGMEM = {(uint8_t *)FreeMono12pt7bPLBitmaps, // Approx. 2132 bytes |
Beta Was this translation helpful? Give feedback.
Things are mixed in your code. This is the issue tracker for u8g2. However your code uses Adafruit lib: So better ask the Adafruit people for support.
In general, your problem could be solved without problems by using "u8g2lib.h"
The following example will use the built-in font helvR14, see https://github.com/olikraus/u8g2/wiki/fntgrpadobex11#helvr14
Again: By using u8g2 you can just use any none-ASCII chars directly in the code as shown in the example below.