datacute / Tiny4kOLED

Library for an ATTiny85 to use an SSD1306 powered, double buffered, 128x32 pixel OLED, over I2C
MIT License
247 stars 36 forks source link

how to draw cyrillic? #35

Closed lancer-1 closed 3 years ago

datacute commented 3 years ago

Tiny4kOLED only supports single byte 8 bit encodings, not unicode.

Do you want KOI8-R or windows 1251 or codepage 866?

Here's a useful page for converting strings: http://string-functions.com/encodedecode.aspx

datacute commented 3 years ago

I'm also in the middle of adding support for proportional width fonts, and thinking that I might be able to easily add support for multiple unicode blocks. While I'm familiar with unicode, I've not worked with it in c nor arduino before. Do you know whether utf-8 or utf-16 is more common for cyrillic?

lancer-1 commented 3 years ago

I'm also in the middle of adding support for proportional width fonts, and thinking that I might be able to easily add support for multiple unicode blocks. While I'm familiar with unicode, I've not worked with it in c nor arduino before. Do you know whether utf-8 or utf-16 is more common for cyrillic? Yes, of course, it's will be useful!

lancer-1 commented 3 years ago

Do you know whether utf-8 or utf-16 is more common for cyrillic?

Windows 1251, but I think there are even better.

datacute commented 3 years ago

Here's an image of my first working version.

20210516_232946

datacute commented 3 years ago

Some background...

The image in my previous comment was from code I've written that understands utf-8. The user API (at the moment) is just one new font setting method.

oled.setUnicodeFont(FONTSEGOEUIREGULAR13);
oled.println(F("Кириллические"));
oled.println(F("шрифты."));
oled.println(F("«Приветствую мир»"));
oled.println(F("    16 мая 2021 г."));

The unicode font references four smaller font portions, each storing glyphs for a range of characters in a unicode plane and block, U+0021 to U+003F, U+00A1 to U+00BF, U+0400 to U+045F, and U+2010 to U+2027. It's showing the Segoe UI font, so not distributable. I'll have to build up my font conversion code into a UI to allow conversion of fonts that people have the rights to convert and use for their own purposes. My conversion application is windows specific, and not yet available.