[HELP]Problem with Unicode support in CEGUI.NET

liiir1985

16-05-2006 10:13:56

I'm working on a project, which needs to display Chinese characters. And I've tried the methode, which the guys on the CEGUI forum do:
First,I've defined a Chinese font. The font file is copied directly from windows font.
then I've used the defineFontGlyphs methode to create a glyphs of the character that I want to display.
I've applied this font to a object which should display chinese.
All source files are also saved with UTF-8 encoding

But the result is, it just won't display anything. :(

I've also tried to define glyphs in the .font file by using <GlyphSet Glyphs="浣犲ソ涓栫晫閫€鍑烘紨"/>

but the result is the same.
Has this something to do with CEGUI.Net or I've done something wrong?
pls help

rastaman

16-05-2006 15:22:27

I took a look at the demo code.
Just a quick note, it looks like it was made for Ogre v1.0.x maybe. On the line it creates the OgreCEGUIRenderer make sure you pass the SceneManager. I beleve that in Ogre v1.2 if you don't pass the SceneManager it will not show any GUI but still run, (the problem you are seeing).

liiir1985

16-05-2006 16:45:54

mCEGUIRenderer = New Cegui.OgreCEGUIRenderer(mRenderWindow)
mCEGUIRenderer.Initialise()
mCEGUIRenderer.setTargetSceneManager(mSceneManager)
mCEGUISystem = GuiSystem.CreateGuiSystemSpecial(mCEGUIRenderer)
Logger.Instance.setLoggingLevel(LoggingLevel.Informative)

Dim sheet As Window
SchemeManager.getSingleton.LoadScheme("TaharezLookSkin.scheme")
mCEGUISystem.SetDefaultMouseCursor("TaharezLook", "MouseArrow")
CeguiDotNet.MouseCursor.getSingleton.setImage(mCEGUISystem.getDefaultMouseCursor)
mCEGUISystem.setDefaultFont("simfang")
sheet = WindowManager.getSingleton.LoadWindowLayout("unnamed1.xml")

mCEGUISystem.setGUISheet(sheet)
Dim bb As PushButton = CeguiDotNet.WindowManager.getSingleton.CreatePushButton("TaharezLook/Button", "Quit")
sheet.AddChildWindow(bb)
Dim ff As CeguiDotNet.Font = mCEGUISystem.getDefaultFont
ff.defineFontGlyphs("你")
bb.SetPosition(0.5F, 0.5F)
bb.setFont(ff)
bb.SetSize(0.3F, 0.1F)
bb.Text = "你"
als you see, I've passed the scenemanager. And I've done exactly what has been done in the demo.
But the result is, that all other GUI Elements display normally, text except special characters,too.

ps:unnamed1.xml contains also a GUI element with chinese. Chinese characters don't display,either,but windows, bottons and so on.
I've used Simfang.ttf, which comes with Chinese windows.

So, i don't think that is the point.

rastaman

17-05-2006 04:22:57

The problem is that unicode strings are not getting across from .Net code to unmanaged code. I've corrected it and will update CVS and binary release in the next couple of days.

If you want to rebuild you self basically the changes are, in project CeguiBindings:
file CLSCompliancy.i change the utf8* typemapes (starting at line 144) to this:

%typemap(ctype) utf8 * "void *"
%typemap(imtype, out="string") utf8 * "[MarshalAs(UnmanagedType.LPTStr)] string"
%typemap(cstype) utf8 * "string"
%typemap(in) utf8 * %{ $1 = (CEGUI::utf8 *)$input; %}
%typemap(csin) utf8 * "$csinput"
%typemap(csout, excode=SWIGEXCODE) utf8 *
{
return ($imcall);
}
%typemap(out) utf8 * %{ $result = (void *)$1; %}



Also in CeguiBindings.i, changes the String class (starting line 91) to this:

class String
{
public:
String( const utf8 * s );
utf8 * c_str();
};


Then run swig on CeguiBindings.i and rebuild the projects.

rastaman

18-05-2006 19:31:13

Well I had it working in linux with mono because mono uses UTF-8 al the time. But it seem that MS .Net is using UTF-16 and CEGUI does not support that. So I will have to make a function to to convert utf16 to utf8 :?

liiir1985

19-05-2006 10:51:54

Thanks a lot.
I'm looking forward to your new patchs :wink:

pepote

19-05-2006 15:24:04

.Net 2.0 supports UTF32 no UTF16. The class for each encoding has a "convert" method that allow you pass UTF32 to UTF8.

I don't now if Mono framework has UTF32 enconding in Text class. I think no.

liiir1985

19-05-2006 22:01:09

I've also tried the Convert method of System.Text.UTF-8 Class. But it dont seem to word,either. :(
Bei the way, I'm using .net 1.1

pepote

19-05-2006 22:10:58

You think about the method convert works with bytes no with string or chars. Yo need pass a string as bytes to method.

rastaman

20-05-2006 18:27:11

pepote: .Net 2.0 supports UTF16 too http://msdn2.microsoft.com/en-us/library/system.text.unicodeencoding(d=ide).aspx

I've got it to work with 2003, and in 2005 I can set text but it does not like the UTF-16 formate for returning text using Marshal.PtrToStringUni.

liiir1985

20-05-2006 18:57:38

I can't rebuild it.
It throws an error while I run swig on CeguiBindings.i
So. can you pls upload the new recomplied dll files, so that I can try it out?

rastaman

23-05-2006 04:07:03

precompiled binaries updated now

liiir1985

23-05-2006 11:31:30

Thank you very much