About Store Forum Documentation Contact



Post Reply 
Chinese character problem
Author Message
MrPi Offline
Member

Post: #1
Chinese character problem
I have added a Chinese unicode font and tested it with these characters:
"我是世界上最帅的骑士。" (just for testing, I don't know what these mean smile)

I made a textstyle out of it and tried to render it in my application as a test:

Str chinesetext = "我是世界上最帅的骑士。";
D.text(TS_Chinese, 0, 0, chinesetext);

But in the code editor the characters are displayed as "?" (which I can understand), but in-game too.
However, when I copy the question marks to the font preview window again, they work there.

How can I make it work in-game?
(This post was last modified: 11-28-2013 04:10 PM by MrPi.)
11-28-2013 04:09 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Chinese character problem
Hi,

Your TextStyle must point to Font which had all the requested characters created.

I've just tested this code and it works fine:
TextStyle ts; ts.font=Fonts(UID(1786675055, 1222931284, 1624792466, 1565410302));
Str text="我是世界上最帅的";
D.text(ts, 0, D.h()-0.8, text);

Make sure that the Font has the desired characters listed in "custom chars" or just tick the whole "Chinese" checkbox, but that will take a while to create the font (several seconds)
11-30-2013 07:43 AM
Find all posts by this user Quote this message in a reply
MrPi Offline
Member

Post: #3
RE: Chinese character problem
But the font worked in the font preview, because it has all those characters in it. I was under the impression that if it worked there, it should also work when rendering in your application.
11-30-2013 08:33 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Chinese character problem
the preview is just for the preview smile
you may want to to check the "custom chars" instead
11-30-2013 08:38 AM
Find all posts by this user Quote this message in a reply
zhanglidong Offline
Member

Post: #5
RE: Chinese character problem
"我是世界上最帅的骑士" means "I'am the most handsome knight in the world"
(This post was last modified: 11-30-2013 12:22 PM by zhanglidong.)
11-30-2013 12:21 PM
Find all posts by this user Quote this message in a reply
MrPi Offline
Member

Post: #6
RE: Chinese character problem
That sounds about right, zhang smile

Hi Greg,
Ok, so I clicked the Chinese option and it now shows like this in-game.
   
As you can see, the last character is not displayed, even though it's shown in the Font Editor preview. I added the last character under Custom Chars and then it showed.
   
(This post was last modified: 11-30-2013 07:54 PM by MrPi.)
11-30-2013 06:45 PM
Find all posts by this user Quote this message in a reply
MrPi Offline
Member

Post: #7
RE: Chinese character problem
Greg, can you provide a list of which chinese characters you add in the font editor when we select the "Chinese" checkbox.
Maybe we can add characters to that standard list for you?
(This post was last modified: 11-30-2013 07:57 PM by MrPi.)
11-30-2013 07:54 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
RE: Chinese character problem
(11-30-2013 12:21 PM)zhanglidong Wrote:  "我是世界上最帅的骑士" means "I'am the most handsome knight in the world"
Hahahaha grin

I'll include the "。" for next release.

Code:
Str LangSpecific(LANG_TYPE lang)
{
   switch(lang)
   {
      case PL        : return L"ĄĆĘŁŃÓŚŻŹąćęłńóśżź";
      case DE        : return L"äÄëËöÖüÜßẞ";
      case FR        : return L"àÀáÁâÂãÃäÄåÅæÆçÇèÈéÉêÊëËìÌíÍîÎïÏðÐñÑòÒóÓôÔõÕöÖøØùÙúÚûÛüÜýÝ";
      case RU        : return L"аАбБвВгГдДеЕжЖзЗиИйЙкКлЛмМнНоОпПрРсСтТуУфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяЯ";
      case PO        : return L"áÁàÀâÂãÃăĂçÇęĘéÉêÊíÍóÓőŐõÕôÔŕŔúÚ";
      case LANG_GREEK: return L"αΑβΒγΓδΔεΕζΖηΗθΘιΙκΚλΛμΜνΝξΞοΟπΠρΡσΣτΤυΥφΦχΧψΨωΩ";

      case CN:
      {
         Str s; s.reserve(0xFFFF);
         for(Int i=0x3400; i<=0x4DB5; i++)s+=Char(i);
         for(Int i=0x4E00; i<=0x9FCB; i++)s+=Char(i);
         for(Int i=0xF900; i<=0xFAD9; i++)s+=Char(i);
         s+=L'。';
         return s;
      }
   }
   return S;
}
The list of chinese characters was provided by a chinese company making a game on EE.
12-01-2013 02:01 AM
Find all posts by this user Quote this message in a reply
MrPi Offline
Member

Post: #9
RE: Chinese character problem
Excellent. When we come across other characters, I'll forward them to you.
Also, could you implement displaying the memory size of a font in the editor? I assume the memory increases when we select a bigger size?
12-01-2013 12:05 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
RE: Chinese character problem
Please right click the font element, and select properties, it will display the file size.
12-01-2013 10:54 PM
Find all posts by this user Quote this message in a reply
MrPi Offline
Member

Post: #11
RE: Chinese character problem
Alright, so I compiled the app and ran it on the iphone. It stopped due to memory stress.

I stepped through the code and found that the text style with the chinese font in it increased the memory consumption from 25MB to 300MB where it then stopped.
I was wondering how that could be? The completely loaded app had only a total of 175MB on windows. Somehow the chinese font alone used almost double that.

Do you know what this could be, Greg?

Some stats:
iPhone 4 with iOS 7.0.4
built with XCode 5.0.2
(This post was last modified: 12-04-2013 01:43 AM by MrPi.)
12-04-2013 01:41 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #12
RE: Chinese character problem
Hi, Fonts are created with DXT5 (1 byte per pixel) texture format.
This format is not supported in iOS.
Therefore it will be converted to L8A8 (2 bytes per pixel) or to B8G8R8A8 (4 bytes per pixel) if you have sub-pixel precision chosen in the font settings.
12-06-2013 12:25 AM
Find all posts by this user Quote this message in a reply
MrPi Offline
Member

Post: #13
RE: Chinese character problem
And what do I have to change to fix it?
I don't see any related settings in the font editor on Windows. Also, is it known that the Esenthel Editor 2.0 on Mac crashes when you try to add a font or double click on an existing one?
12-06-2013 12:35 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #14
RE: Chinese character problem
Hi,

I've checked, in the Font Editor this option is currently always disabled (always set to sub pixel precision=false) so the L8A8 format will be used.

Please attach the crash report that you're experiencing, I've just tested but I don't have a crash on Mac with this.
12-08-2013 10:08 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #15
RE: Chinese character problem
Also you may want to enable APP_AUTO_FREE_OPEN_GL_ES_DATA for better memory usage.
12-08-2013 09:21 PM
Find all posts by this user Quote this message in a reply
Post Reply