about quickgui show Chinese

qhlkj.cn

21-12-2007 10:05:48

hi!
i want to show Chinese in quickgui ,for example"显示中文", but run only

show "显 文"! hoho could you help me ?

ogre1.4.4 + quickgui 0.9.7
code
................
usernameTB = mSheet->createTextBox();
usernameTB->setPosition(100,360);
usernameTB->setWidth(600);
usernameTB->setFont("simhei",true);
usernameTB->setText(" 显示中文");
...................


the simhei file :

simhei
{
type truetype
source simhei.ttf
size 10
resolution 96
code_points 33-166 19868-40868

}

kungfoomasta

21-12-2007 19:28:08

I can't even see what those characters are. :lol:

Try this function:


void setSupportedCodePoints(const std::set<Ogre::UTFString::code_point>& list);

The code points you specify in the .fontdef file are used to create the texture of all the glyphs you want, but in order for QuickGUI to display them, you have to let QuickGUI know which characters are valid for display.

qhlkj.cn

04-01-2008 10:01:19

"显示中文" it utf-8 code is " &#x663E;&#x793A;&#x4E2D;&#x6587; "

"显示中文" it unicode is 显示中文

kungfoomasta

04-01-2008 17:46:13

I'm unable to see those symbols at work, and I'm not sure if I will be able to view them at home. Can you be more specific on what the problem is?

akem321

17-01-2008 16:07:55

Here it does show "显示中" but not the last one "文", using simhei too.
i dunno about code_point.
I noticed anyway there are few symbols i can't display on my system, but no pblm with this one.
btw how do you find out the utf-8 code?

zolt4n

21-01-2008 14:41:02

Hi I have same problem but in french I would like to display

ééààù

but QuickGui bug in function UTFString!!!
I thinks it's normal because UTF doesn't support accent
any Ideea ?

akem321

21-01-2008 15:24:23

Hey,

UTF8 does support accents of course.
But to show éàèç etc, the font must have thoses characters defined(in your ttf),
thing is that sometimes the characters are defined but not rendered.
It is apparently due to code_point:

The code points you specify in the .fontdef file are used to create the texture of all the glyphs you want, but in order for QuickGUI to display them, you have to let QuickGUI know which characters are valid for display.

magistr

22-01-2008 22:17:31

I have some problem.
I try to display russian text, and have broblem with some font.

If I use font with russian chars, which have position 224-255
and this function:

Ogre::UTFString ConvertToUTF(Ogre::String String)
{
Ogre::UTFString UTFString;
int i;
Ogre::UTFString::code_point cp;
for (i=0; i<(int)String.size(); ++i)
{
cp = String[i];
cp &= 0xFF;
UTFString.append(1, cp);
}
return UTFString;
}


this function need for convert big char codes to ANSI
for examle:
65473 ('Б') = 197

after I set text:
logoLabel->setText(ConvertToUTF("abcde абвгд"));

I have nice russian text.


But many files does not have in positions 204-255 russian encoding.

I view many ttf files and I think that russian positions in ttf files is 1040-1103

This is arial, verdana and all windows fonts!

How to use charset in russian ttf unicode block?

magistr

23-01-2008 21:01:06

Bigthanks for nice QuickGUI coding!

I am resolve this problem. My cpp file and external resource was not saved in UTF-8.
But after saving I have problem with isspace function.
It generate error message (I am not save it).
After debug I am found line where call this function.

It is line 197 in QuickGUIText.cpp file

// We need to have quads that represent spaces for text indexing. We don't need
// to render them, however.
if(!isspace(cp))
{
// set texture
q->setMaterial(mTextHelper->getFontMaterialName());


In this code using isspace function from ctype.h
and it does not support unicode.

I am edit code, and replace isspace by Your mTextHelper->isSpace

and this code is work nice:

// We need to have quads that represent spaces for text indexing. We don't need
// to render them, however.

if(!mTextHelper->isSpace(cp))
{
// set texture
q->setMaterial(mTextHelper->getFontMaterialName());

kungfoomasta

23-01-2008 21:29:10

Ok I'll make that change, thanks for pointing it out. :)