Adam M Posted August 29, 2018 Report Share Posted August 29, 2018 I have read up on the forum posts - and it sounds like other people have successfully gotten special characters to work, so I must be missing something. I went out and got this font (https://www.fontsquirrel.com/fonts/acme?filter[download]=local) which includes the special characters I want to use (° / ñ / é) and converted it to c using the uGFX font converted with anti-aliasing, and no filtering. When I type the ° symbol and use gwinSetText() on a label the ° symbol actually shows up without issue - but I also get a  character also appears just in front of the ° symbol. I have attempted the use of two distinct fonts that each have the special characters I need - when I used another font, named Alef - I also got the ° printed using that font, but a rogue ? showed up in front of the symbol. I was curious if anyone had any ideas as to why this is happening or suggestions on what I should try next? Example: snprintf(temp_temp, 8, "%d°F", left_target_temp); gwinSetText(ghLeftCommandedTemp, temp_temp, TRUE); Link to comment Share on other sites More sharing options...
Adam M Posted August 29, 2018 Author Report Share Posted August 29, 2018 For others who might run into this... I found that the issue had to do with how I formatting the string. When I changed the code to: snprintf(temp_temp, 8, "%d%cF", left_target_temp, '°'); gwinSetText(ghLeftCommandedTemp, temp_temp, TRUE); I was able to get only the ° character displayed. Link to comment Share on other sites More sharing options...
inmarket Posted August 29, 2018 Report Share Posted August 29, 2018 This may indicate a unicode bug in snprintf. I will look later. It could also indicate that your editor is not in utf8 character format. Perhaps it is using extended ASCII or one of the other unicode formats eg utf16le Link to comment Share on other sites More sharing options...
Adam M Posted August 29, 2018 Author Report Share Posted August 29, 2018 Yeah - to give some more information to the discussion - I later discovered that I was just lucky that I was getting a degree symbol (in that I was actually truncating the first character of the result). This 'hack' didn't work when I attempted to enter the spanish character I mentioned in my original post. When using the UTF-8 code \u00B0 I get some garbage (I'll comment back later with exact garbage) and if I use the exact ASCII code - I also get some garbage. The editor I'm using is Sublime Text - if that helps. I've tried both typing the character and using the pure unicode '\u00B0' and get the same result, so I don't think the editor is to blame. Link to comment Share on other sites More sharing options...
inmarket Posted August 30, 2018 Report Share Posted August 30, 2018 It may be asking the obvious but have you got unicode support turned on in your gfxconf.h? Link to comment Share on other sites More sharing options...
Adam M Posted August 30, 2018 Author Report Share Posted August 30, 2018 @inmarket - Yeah, I have that enabled as: #define GDISP_NEED_TEXT TRUE #define GDISP_NEED_TEXT_UTF8 TRUE #define GDISP_NEED_ANTIALIAS TRUE #define GDISP_NEED_PIXELREAD TRUE #define GDISP_NEED_TEXT_KERNING TRUE #define GDISP_INCLUDE_USER_FONTS TRUE I'll try and grab the exact result of my various attempts to get these special characters to print sometime today. Link to comment Share on other sites More sharing options...
Adam M Posted August 30, 2018 Author Report Share Posted August 30, 2018 (edited) As a entry condition I ensured that UTF-8 encoding was enabled in my SublimeText instance: "default_encoding" : "utf-8", Here comes a list of things I tried and their results: # Shows ° for the degree symbol snprintf(temp_temp, 20, "%d°F", target_temp); gwinSetText(temp_label, temp_temp, TRUE); # Shows ° for the degree symbol snprintf(temp_temp, 20, "%d\u00B0F", target_temp); gwinSetText(temp_label, temp_temp, TRUE); # Shows ° for the degree symbol gwinSetText(temp_label, "°F", TRUE); # Shows ° for the degree symbol snprintf(temp_temp, 20, "%d%sF", target_temp, "°"); gwinSetText(temp_label, temp_temp, TRUE); # Shows ° for the degree symbol gdispDrawString(10, 10, "°", font1, Yellow); # I then included the cyrillic font implementation from your cyrillic demo and tried to print the demo text. # I got some "?"'s as well as 'not the characters' in the demo string. font_t large_font = gdispOpenFont("Archangelsk Regular 12"); gdispDrawString(10, 10, "привет мир", large_font, Yellow); A thought just occurred to me, perhaps I'm compiling uGFX incorrectly? I'm using this option set in my Makefile: -c -ggdb -O0 -march=armv7 -mfpu=vfp -mfloat-abi=hard -fomit-frame-pointer \ -Wall -Wextra -Wstrict-prototypes -fverbose-asm -ffunction-sections \ -fdata-sections -fno-common -flto -MMD -MP I haven't added dependency management yet - so the -MF that is added by default during "normal" compilation through your own makefiles isn't in use. Think that has anything to do with it? Edited August 30, 2018 by Adam M Link to comment Share on other sites More sharing options...
Adam M Posted August 30, 2018 Author Report Share Posted August 30, 2018 Scratch that dependency comment - I added dependencies to our Makefile, and still got the same behavior - since I was running make clean / make each time I probably ended up with the same behavior to begin with. Still though, I could be compiling uGFX improperly (if you don't like the options I used). I copied the options used from a make run of uGFX through your own makefiles - so I assumed / assume they are right. Link to comment Share on other sites More sharing options...
inmarket Posted August 30, 2018 Report Share Posted August 30, 2018 Unlikely the compile will affect anything. Try just outputting directly a string with Unicode characters in it without using snprintf. If that doesn't work there can only be one of a few problems... 1. Utf8 support is not turned on 2. Your editor is not putting the Utf8 characters into the string correctly 3. Your compiler is stripping them out of the string or not encoding them correctly. 4. The font you are using doesn't map the particular characters used. In your case I think 1 or 2 would be the problem as you are seeing 'extra' characters. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now