How to display chinese/or other language by using nifty gui?

here is my code:

control(new ButtonBuilder(“keyEventLabelId”, “遊戲(game)”)

{

{

alignRight();

height(“5%”);

width(“15%”);

}});



I want to display 遊戲(game) as a button name but it just display “(game)” which “遊戲” is disappeared

At the very minimum you would need a bitmap font file containing those characters. I’m not sure what else might be needed.

@zarch said:
At the very minimum you would need a bitmap font file containing those characters. I'm not sure what else might be needed.


Thanks for help.
I used a bitmap tool to create a Chinese fnt file,so I can show Chinese by the following code now:
guiFont = assetManager.loadFont("Interface/Fonts/abc.fnt");
BitmapText helloText = new BitmapText(guiFont, false);
helloText.setSize(guiFont.getCharSet().getRenderedSize());
helloText.setText("我是一個大笨蛋");
helloText.setLocalTranslation(300, helloText.getLineHeight(), 0);
guiNode.attachChild(helloText);

however, I still cannot show Chinese in nifty gui's button or label and so on
Does anyone can help me ? I want to show a button or label as Chinese words.
for example:
control(new ButtonBuilder("I_am_a_button", "我是一個大笨蛋") {
{
alignRight();
height("5%");
width("15%");
}
});

I’m not sure how the nifty text stuff works behind the scenes, it may use the bitmap text stuff or it may have its own mechanism.



This may need an answers from @void256 or someone else who knows how the integration works.

@zarch said:
I'm not sure how the nifty text stuff works behind the scenes, it may use the bitmap text stuff or it may have its own mechanism.

This may need an answers from @void256 or someone else who knows how the integration works.


It uses BitmapText behind the scenes.

My first questions is if the OP is using the same font in his nifty controls as in the test that worked.

I find a way that I try to set my font in nifty-button.xml (list in nifty-default-controls.xml setting the default button style).

However, I find that my modification does not work and I don’t know why.

Does anyone know the default address of nifty-button.xml or nifty-default-controls.xml? Because the Jme seems have a invisible default address of these xml files.

They are in either the nifty-styles-black or nifty-default-controls jar.

@zarch said:
They are in either the nifty-styles-black or nifty-default-controls jar.

Thanks, but I still cannot figure out the problem.
However I found that I can use SWING to replace nifty gui.

This post can close.

Using swing is not a good idea, you have to care for threading issues on both sides (EventQueue.invokeLater / app.enqueue) and it doesn’t port to other platforms.

@harry1315 said:
I find a way that I try to set my font in nifty-button.xml (list in nifty-default-controls.xml setting the default button style).
However, I find that my modification does not work and I don't know why.
Does anyone know the default address of nifty-button.xml or nifty-default-controls.xml? Because the Jme seems have a invisible default address of these xml files.


The styles are part of the nifty-style-black.jar. To use your own custom button style I'd suggest to find the "nifty-button.xml" in this jar and make a copy of the XML-File. You'll need to change the name of all styles and substyles in this file from "nifty-button" to something else, like "my-custom-button" or so. When you later create your button you'll need to set this new style name as the style attribute, like "<button ... style="my-custom-button" />. This way Nifty will use your style instead of the default one.

Ah and make sure to include your xml file with "<useStyles filename="my-copy-of-the-button.xml" />"
1 Like

Hi, guys, I also stuck in the same problem when I want to show Chinese using nifty just as harry1315 met.
I found serveral posts in 2010, like: http://sourceforge.net/p/nifty-gui/discussion/807893/thread/a6a51b65/
But it seems no future update at all…
So do you guys have any solutions or suggestions for this issue?
Many thanks.

Did you make your own font? I doubt that chinese characters are available in the predefined fonts, Chinese characters are not available in the default fonts delivered with JME, so you’ll need to download the AngelCode software and build your own font.

Depending on the characters you need you might be able to do it using the font creator in the SDK now.