hironishihara / ofxTrueTypeFontUC

An extension of ofTrueTypeFont class for using UNICODE characters. Tested on OSX, iOS, and Windows.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Visual Studio 2015 - OF0.9 problem

selcukartut opened this issue · comments

Dear Hironishihara,
Thanks for your kind contribution to the community. I would like to remark an issue I have been experiencing. I am trying to implement your addon for Windows Visual Studio 2015 using of0.9. There seems to be a problem with the addon, because non-Latin characters are printed as ? (question marks) instead. I'd appreciate if you can help us solve this matter.
Kind regards

Hey Selcuk, which font do you use to test the ofxTrueTypeFontUC?

You can try Free-Sans. I use it successfully with Turkish letters:
http://www.fonts2u.com/free-sans.font

Dear Noyan,
Thanks for the advice. no luck with Free-Sans
Are you using of0.9 on a Visual Studio? Can you specify your platform a bit?
best regards

I tried with of0.8.0, of0.8.4 and of0.9.2. Both works with Turkish characters here.
Development machine Ubuntu 12.04 and target Android, though.

Could you confirm the character code of std::string?
The character code in your Visual Studio settings might be already utf-8.
If so, convToUTF32() function must be edited as below.

static const basic_string<unsigned int> convToUTF32(const string &src) {
  if (src.size() == 0) {
    return basic_string<unsigned int> ();
  }

  /*
  // convert XXX -> UTF-16
  const int n_size = ::MultiByteToWideChar(CP_ACP, 0, src.c_str(), -1, NULL, 0);
  vector<wchar_t> buffUTF16(n_size);
  ::MultiByteToWideChar(CP_ACP, 0, src.c_str(), -1, &buffUTF16[0], n_size);

  // convert UTF-16 -> UTF-8
  const int utf8str_size = ::WideCharToMultiByte(CP_UTF8, 0, &buffUTF16[0], -1, NULL, 0, NULL, 0);
  vector<char> buffUTF8(utf8str_size);
  ::WideCharToMultiByte(CP_UTF8, 0, &buffUTF16[0], -1, &buffUTF8[0], utf8str_size, NULL, 0);
  */

  // convert UTF-8 -> UTF-32 (UCS-4)
  std::wstring_convert<std::codecvt_utf8<unsigned int>, unsigned int> convert32;
  // return convert32.from_bytes(&buffUTF8[0]);
  return convert32.from_bytes(src);
}

Hi there,

I've editted the source code. But, it throws errors on some specific Turkish letters. Then, I've changed the encoding type to Unicode (UTF-8 without signature) as follows. Now, it works and draws all of the Turkish letters without any issue. Thanks.

unicode_with_tr_chars

I'm using;

  • Visual Studio 2015
  • OF v-0.9
  • Windows 10