Spirik / GEM

Good Enough Menu for Arduino
GNU Lesser General Public License v3.0
245 stars 36 forks source link

UTF8 with u8g2 #56

Closed TimonPeng closed 9 months ago

TimonPeng commented 2 years ago

Hi Alex!

It's me again! The design and structure of GEM is truly excellent! I love it!

When I try to enable UTF8 print like the u8g2 example, but seems can't works.

https://github.com/olikraus/U8g2_Arduino/blob/dd729c5253eb85d907f0f84a1c53074bffb7a43a/examples/page_buffer/PrintUTF8/PrintUTF8.ino#L338

My codes:

GEMItem menuItemInt("数字:", number);

void setup() {
  Serial.begin(115200);

  u8g2.begin();
  u8g2.enableUTF8Print();
  // https://github.com/larryli/u8g2_wqy
  u8g2.setFont(u8g2_font_wqy12_t_gb2312);

  menu.init();
  setupMenu();
  menu.drawMenu();
}
TimonPeng commented 2 years ago

It's because GEM have default internal _fontFamilies, so do you have any plan to support external fonts setting when init? for main title, items and content. Thanks.

Spirik commented 2 years ago

Oh yeah, I am definitely considering it for the future updates.

For the time being the best way to workaround this is to enable Cyrillic support via GEM_u8g2::enableCyrillic() method - that will internally trigger .enableUTF8Print() method of U8g2, thus activating support for UTF8 fonts. Then you will need to manually set fonts you want instead of predefined Cyrillic ones through editing these two defines in a source code of GEM_u8g2.h: one for big font and second for the smaller font. That should technically work=)

Thank you for the kind words!

TimonPeng commented 2 years ago

I really love this project and you! As I said to my friend, this project is full of engineering aesthetics and design aesthetics.

Would you be willing to set up a github sponsor, or something else like paypal or cryptocurrency stuffs? I'd like to give a little support to you and your masterpiece!

Spirik commented 2 years ago

I have not really considered it, to be honest, but thanks for the tip, probably I will someday=)

Spirik commented 9 months ago

Implemented better custom fonts support in release 1.5.1.

See corresponding section on wiki for more details.