ofxFontStash icon indicating copy to clipboard operation
ofxFontStash copied to clipboard

Unicode characters dissapearing

Open zzart opened this issue 8 years ago • 6 comments

Hey, thanks for the addon! It's great. I've discovered on issue though. I have a sketch when every time I hit a key on the keyboard some predefined text (one character at the time) gets printed on the screen using ie. font.drawMultiLineColumn funtion. It works great for US character set , but when it has to print some non US characters ie. "ężćńą" the first stroke clears the entire line and nothing gets displayed , then the second stroke prints line + the unicode character. It's a bit weird so I've attached the screen.

Typing away ... step1 Next key stroke - this should type 'ź' but it clears the line instead step2 Finally after 2nd keystroke the character gets printed step3

zzart avatar Nov 01 '16 20:11 zzart

hm are you sure the character input you are getting is right? Can u try loading the non-ascii chars from a file, or hardcoding them in your source code? Otherwise post some of your code and I can have a look

armadillu avatar Nov 07 '16 21:11 armadillu

Sorry, same problem here. of0.9.7 + vs2015 + windows 10. I just used the example code and unicode characters won't show up.

agalloch21 avatar Jan 04 '17 17:01 agalloch21

Now it works after I change LocaleToUtf8() to a previous version:

string LocaleToUtf8(const string & locale){

int size = MultiByteToWideChar(CP_THREAD_ACP, // code page
							   MB_ERR_INVALID_CHARS, // character-type options
							   locale.c_str(), // address of string to map
							   -1, // NULL terminated
							   NULL, // address of wide-character buffer
							   0) + 1;               // size of buffer


WCHAR * pWideChar = new WCHAR[size];

MultiByteToWideChar(CP_THREAD_ACP, // code page
					MB_ERR_INVALID_CHARS, // character-type options
					locale.c_str(), // address of string to map
					-1, // NULL terminated
					pWideChar, // address of wide-character buffer
					size);                // size of buffer


size = WideCharToMultiByte(CP_UTF8, // code page
						   0, // performance and mapping flags
						   pWideChar, // address of wide-character string
						   -1, // NULL terminated
						   NULL, // address of buffer for new string
						   0, // size of buffer
						   NULL, // address of default for unmappable characters
						   NULL) + 1; // address of flag set when default char used


char * pUtf8 = new char[size];

WideCharToMultiByte(CP_UTF8, // code page
					0, // address of wide-character string
					pWideChar, // address of wide-character string
					-1, // NULL terminated
					pUtf8, // address of buffer for new string
					size, // size of buffer
					NULL, // address of default for unmappable characters
					NULL);     // address of flag set when default char used


string Utf8 = pUtf8;

delete[] pWideChar;
delete[] pUtf8;
return Utf8;

}

agalloch21 avatar Jan 09 '17 03:01 agalloch21

Hi, I encountered the same problem. The example works fine. But when I created a new project, and copied and pasted the code in the example, it did not show the unicode characters. 1499422880 1 Do I need to do some settings? I did not see any suggested steps in your "readme".

gongzai1219 avatar Jul 07 '17 10:07 gongzai1219

Hi, I encountered the same problem. The example works fine. But when I created a new project, and copied and pasted the code in the example, it did not show the unicode characters. 1499422880 1 Do I need to do some settings? I did not see any suggested steps in your "readme".

have you solved the problem yet?

ghjingrui0564 avatar Mar 05 '19 03:03 ghjingrui0564

Hi, I encountered the same problem. The example works fine. But when I created a new project, and copied and pasted the code in the example, it did not show the unicode characters. 1499422880 1 Do I need to do some settings? I did not see any suggested steps in your "readme".

have you solved the problem yet?

Hi, sorry for lllllllate reply. Can you try another Chinese TTF font? I used a '.ttf' font and it worked perfect. And you have to save the file as Unicode (UTF-8 without signature)-Codepage 65001. Hope this can help you.

gongzai1219 avatar Apr 10 '19 03:04 gongzai1219