Japanese Characters in BitmapText

How can I use japanese characters in my BitmapText element?

BitmapFont guiFont = assetManager().loadFont("fonts/MSPGothic.fnt");
BitmapText hudText = new BitmapText(guiFont, false);

I know the MS PGothic contains japanese characters, but if I try to create fnt & png file with JMonkey SDK and load the asset in my application I get a java heap space exception.

Hmm, probably we should really stream them. Can you file a bug to https://github.com/jMonkeyEngine/sdk/issues? Also there was an option to create multiple pages, it might fix it.

Meanwhile you can use alternative tools. Any angel font tool will do. Such as Hiero etc.

If I use Hiero to export from MS PGothic to a fnt file then it works but the japanese characters are not shown. I’ve installed the japanese language pack.
I tried Hiero but without any success. How can I just export the japanese characters?

Well, we can focus on the SDK’s font tool. So it was successful on creating the font files? And only crashed when you tried to load these up? And was it your application that crashed or the SDK really? You can ramp up the memory limits on both.

What is also important is that you really use paging. To be on the safe side, you probably want to keep individual page 2048x2048 max. And was it that the SDK’s tool allows you to specify the character index from - to - range…

I made it to create a japanese font. But the background is black. How can I set the transparency.

The font png file looks like:

grafik

And the result is almost correct, but the background must be tranparency.

grafik

		BitmapFont guiFont = Java3D.getInstance().getAssetManager().loadFont("fonts/japan/font.fnt");
		BitmapText hudText = new BitmapText(guiFont, false);
		// hudText.setQueueBucket(Bucket.Transparent);
		hudText.setSize(20);
//		hudText.setAlpha(-1);
		hudText.setColor(color);

What tool did you use to create the font?

Did you add it to the guiNode or is it in the 3D scene?

Edit: also, what is it in front of? What is its position relative to what it’s in front of?

Does a regular font like the default font work or does it also have a black background?

There can be lots of reasons to get the effect you have but they are all related to code we can’t see.

I use bmfont1.14a with the following setting:


The implementation looks like this:

class Point extends Node {
	void init(SimpleApplication app) {
		BitmapFont guiFont = assetManager().loadFont("fonts/japan/font.fnt");
		BitmapText hudText = new BitmapText(guiFont, false);
		hudText.setSize(20);
		attachChild(hudText);
		app.getGuiNode().attachChild(this);
	}
}

It’s working with a regular font like Arial and the background is transparency.

Maybe I made a misstake with the creation of font.

Yeah, if regular fonts work then it might be a problem with a setting during creation.

And If you could not make it through the export settings, alternatively, you may use Gimp or an online image editor to make the black area transparent.

BMFont is what I always use to make fonts locally. There are a lot of settings and it’s not always clear the effect they have but I’ve never had to load the images into another tool to fix them.

…I have loaded them into a tool to diagnose issues, though. So if you have a working font and a bad font, try loading them both into an image editor to see what’s wrong. And if both of them have similar transparency/coloring/etc. then maybe it’s something else wrong.

@pspeed good hint:
I think I’ve found a suitable setting:

But I don’t have any idea why it’s working.

1 Like

Here is a complete menu setup with east asian languages. I also used bmfont afair.