Jump to content

Accented characters not showing properly on Console widget


Joshua
 Share

Recommended Posts

Maybe there's a note about this somewhere, but when gwinPrintf-ing accented characters from my custom font to a console, they don't render correctly. gwinSetText works fine for labels.

So for example,

gwinSetText(ghLabel, "é", gFalse); // works
gwinPrintf(ghConsole, "é"); // doesn't work, prints "é"

Is there a way to make this work using the console widget?

Thanks

Link to comment
Share on other sites

Hmm. Without looking at the code, it looks like a utf8 encoding problem. The reason I have this suspicion is that for the label you are getting a single character output, for the console you are getting a two character output. I suspect that while the two strings look the same they are actually encoded differently.

Both the console and the label use the same underlying font routines so the only way they would give different output for the same input is if perhaps the console is printing byte by byte instead of character by character or string print.

Try putting the string into a variable and then using that variable to print both the label and the console. If you get the same result let me know and I will go digging.

Link to comment
Share on other sites

Hi @inmarket, I get the same result as before with this code:

    characcented = "é";
    gwinSetText(ghTitleLblaccentedgTrue); // works, sets text to "é"
    gwinPrintf(ghConsoleaccented);               // doesn't work, prints "é"
Link to comment
Share on other sites

  • 3 weeks later...

Sorry, I have been away and unable to respond. I will be back this coming weekend and will have a good look as soon as I can. The most likely reason is gwinPrintf is processing byte by byte rather than character by character. 

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
  • 2 months later...
Posted (edited)

Hi Joel, attached is the font converter output. It's the DejaVuSans font. I'm pretty sure I used the one that's included in the ugfx source. I converted it with anti aliasing and a custom range to include accented characters used in French and the degree symbol.

This same font is displaying accented characters fine in label widgets, but not in our console widget.

Thanks for looking into this.

DejaVuSans20_aa_c.c

Edited by Joshua
clarification
Link to comment
Share on other sites

I have had a decent look at this. Unfortunately it is not easy to fix. The issue is that gwinPrintf is processing the string byte by byte rather than utf8 character by utf8 character. This is completely consistent with the original C standard printf but definitely not what you need.

To get around this in the short term gsprintf it into a text buffer and then string print that. Note: even with this, %c will not work for utf8 extended chars but %s will.

I am currently deep in implementing generic rotation for text drawing for ugfx v3 so it will probably be a while before I can come back to solve this properly. 

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...