ImpulseAdventure / GUIslice-Builder

Cross-platform drag & drop GUI builder for GUIslice
Other
163 stars 35 forks source link

Guislice-Builder don't bring German Umlauts. #228

Closed umsmin closed 1 year ago

umsmin commented 1 year ago

Describe the bug My Guislice-Builder 0.17.b18 and also the older one show me the text with German umlaut. I use Arial Fonts with full size off 0xFF. But when he generate the code something goes wrong. I write Gerät : and he make Ger\xe4t : He also don't care of setting the flag on UTF-8 or not. After I change it manually in the _GLSC.h file all be well.

Here is one from the fonts:

arial10pt8b.zip

To Reproduce In any kind he make this.

Expected behavior He don't change the umlauts as they are.

Version

Pconti31 commented 1 year ago

@umsmin For me to help people I need a sample project not just a font. Please put together a small project with just the single text field you want to display so I can look at the .prj and .ino and *_GSLCS.h files to see what is going on or debug if necessary. and post the zip file. Thanks.

umsmin commented 1 year ago

No problem here a small example:

Umlaute.zip

Uli

Pconti31 commented 1 year ago

@umsmin Ah! I should have realized this from the start. You are using TFT_eSPI graphics library. Bodmer's library doesn't support GFX fonts with characters greater than decimal 127 and yours is decimal 228 (0xe4). For a full discussion of this you can read the closed Issue 614

Basically, The history of Adafruit GFX is that they include a font converter written in C with the Adafruit-GFX-Library inside fontconvert folder. Now its hard to use, in particular, on windows platform. It turns out this utility only supports characters with decimal values 32-127. I suspect to reduce memory requirements on Arduino UNOs. Nevertheless, the font definition file gfxfont.h has a first and last variable used as offsets into the font arrays. So, all of the online font conversion programs and my utility TTF2GFX support using 0-255 decimal.

Adafruit-gfx library works just fine this way. However, Bodmer's routine decodeUTF8 screens them out thinking they are bad unicode 16 characters and he suggests you switch over to smooth fonts instead.

As you can see this isn't a bug with GUIslice or GUIslice Builder. Given the complex nature of Bodmer's code I can understand why he doesn't support code sets greater than 127 for GFX fonts out of the box.

Rather than patching TFT_eSPI I found a simple work-around. Edit your Umlaute.ino file and inside the setup() function after InitGUIslice_gen() add these lines Inside your

  // find our display driver
  TFT_eSPI* tft = (TFT_eSPI*)gslc_GetDriverDisp(&m_gui);
  // turn off UTF8 support to use GFX fonts with TFT_eSPI
  tft->setAttribute(UTF8_SWITCH, false);

This will turn off decodeUTF8() and allow GFX characters greater than 127 to display. Paul--

umsmin commented 1 year ago

Thanks for your help. But one thing I don't understand. When I change this Ger\xe4te : to Geräte : later in the sketch it works without your patch.

// Create E_ELEM_TEXT1 text label
  pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_TEXT1,E_PG_MAIN,(gslc_tsRect){0,10,296,17},
    (char*)"Ger\xe4t H\xf6rnchen Gem\xfcse",0,E_ARIAL10PT8B);
  gslc_ElemSetFillEn(&m_gui,pElemRef,false);

I change to:

// Create E_ELEM_TEXT1 text label
  pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_TEXT1,E_PG_MAIN,(gslc_tsRect){0,10,296,17},
    (char*)"Gerät Hörnchen Gemüse",0,E_ARIAL10PT8B);
  gslc_ElemSetFillEn(&m_gui,pElemRef,false);

The screen show:

Gerät Hörnchen Gemüse

Without any problems.

My font is converted with the tool from Adafruit. I use it on one of my Linux Servers and it works well.

I've made the option 3 and patched the library from Bodmer and it works without editing later the code made from Guislice-Builder it's okay but not nice. For me normally no need for any part of Software or library to translate my words written in Guislice-Builder.

Sorry for my stupid questions but I am 60 and not one from the young generation born with a mobile in the hands.

Uli

Pconti31 commented 1 year ago

@umsmin We seem to over lapped messages. Rather than patching TFT_eSPI I found a simple work-around. Edit your Umlaute.ino file and inside the setup() function after InitGUIslice_gen() add these lines

  // find our display driver
  TFT_eSPI* tft = (TFT_eSPI*)gslc_GetDriverDisp(&m_gui);
  // turn off UTF8 support to use GFX fonts with TFT_eSPI
  tft->setAttribute(UTF8_SWITCH, false);

This will turn off decodeUTF8() and allow GFX characters greater than 127 to display. Paul--

Pconti31 commented 1 year ago

@umsmin By the way, you are much younger than me! I wish I was in my 60s again... Paul--

umsmin commented 1 year ago

@Pconti31 Yeah but you take this thing with - in Germany we say - Du hast es mit der Muttermilch getrunken

For me the the additional code

 // find our display driver
  TFT_eSPI* tft = (TFT_eSPI*)gslc_GetDriverDisp(&m_gui);
  // turn off UTF8 support to use GFX fonts with TFT_eSPI
  tft->setAttribute(UTF8_SWITCH, false);

Works without this patch. It's not good but okay.

Thanks

Uli

Pconti31 commented 1 year ago

@umsmin The reason changing your literal string by inserting "ü" directly is because you are inserting the unicode 16 bit character from your keyboard thus you get the literal string "\x00\xfc" in binary while if you use the builder I output the correct binary code for GFX fonts simply "\fc".

Bodmers decodeUTF8() routine detects the "\x00\xfc" as a 16 bit unicode thanks to the "\x00" trigger and simply outputs the next character it finds which is the "\xfc" from your font.

While this works I 'm not sure I do the same outputting "\x00\xfc" and not break Adafruit-GFX library. I plan on looking into this though for a future release. Paul--

umsmin commented 1 year ago

@Pconti31 After I changed it like you told me, only the new things I make in my project will be shown in the right way. The old ones I only changed UTF-8 from false to true don't shown in the right way. I don't want to make all new there.

Uli

Pconti31 commented 1 year ago

@umsmin sorry I have lost track of what you are doing and what is working or not? Can you create and zip a project that fails to show whatever?

Pconti31 commented 1 year ago

@umsmin by the way unless your target is raspberry pi the utf8 property is completely ignored by guislice and not passed on to any graphics library.

umsmin commented 1 year ago

I don't use raspberry pi. It works on esp32. Tomorrow I will send you the project

Pconti31 commented 1 year ago

@umsmin Release 0.17.b19 I think will solve your problem with extended character sets without needing to use

 tft->setAttribute(UTF8_SWITCH, false);

in your *.ino file. Please let me know if this works out for you. Paul--

Pconti31 commented 1 year ago

@umsmin Since I haven't heard from you since dec 14, 2022 I'll just close this issue. If you are still having problems and you suppliy additional information I'll reopen this case.