Non ascii character support

is there a way to get non ascii characters to work with jMonkey?
And by non ascii I mean Arabic, I have been trying to convert ttf arabic fonts to fnt using the usual jMonkey SDK approach of creating a new file and choosing new font from the GUI section, but arabic characters don’t get rendered.

this is the code that I’m using

import com.jme3.font.BitmapText;
import com.jme3.light.DirectionalLight;
import com.jme3.math.Vector3f;

public class Main extends SimpleApplication {

    public static void main(String[] args) {
        Main app = new Main();

    public void simpleInitApp() {

        // Display a line of text with a default font
        guiFont = assetManager.loadFont("Interface/Fonts/ArabicTypesetting.fnt");
        BitmapText helloText = new BitmapText(guiFont, false);
        helloText.setText("öööö aaaa مرحبا");
        helloText.setLocalTranslation(300, helloText.getLineHeight(), 0);

        DirectionalLight sun = new DirectionalLight();
        sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));


And the resulting text is “öööö aaaa” with no arabic :frowning:

Hope that jMonkey acctually supports this.

Update 1:
I got the characters to show on screen by converting the ttf file to a fnt file using hiero, and not the font converter in the sdk.
My problem now is that Arabic letters change their shape according to their place in a word, and Arabic is written from left to right, but the GUI is using the same shape for every letter and the text is written from right to left, just as one would write English texts.
I’ll see what I can do.

Maybe this thread will give you some hints on how to proceed:

Seems very interesting, I’ll work on it when I have time then put an update

Yeah, that was my question a while ago. Since then I have already created a fully java-based font creator for JME3 applications. Like you can create a jme font from almost any font installed in your system, using only standard java libraries, and with any unicode characters you might desire, all inside your game, and use it straight away or cache for later use and distribution.

If you are interested, I may dig that thing up tomorrow and contribute it… maybe others will find it handy…

Update: just read you update :smiley: so yeah, you’ve made it with hiero. As for the special writing techniques for languages such as Arabic, you have to implement it yourself or find an existing java implementation. There’s a tonn of work done by the guys at Microsoft, Linux party and others to make such writing possible at all inside the OS and editors. English, Cyrillic and other simple-letter scripts are far easier than that.

1 Like

Maybe I missed it, but shouldn’t it be possible to select a specific UTF-8 character code range which would be taken from the TTF font and inserted into the FNT file?
As long as the same character codes are used in the application, it should pick up the right bitmaps from the FNT file.

Yeah, iirc this is possible with Hiero (not sure how flexible it is there, selecting a language-associated set, as per a codepage, that was iirc). As for my “font creator” - I went with a simple array of character codes to specify what to include, so any combination of symbols can be taken to form the FNT, the proper character widths, heights and other levels taken from a TTF are properly preserved. I don’t see why a similar thing cannot be acheived with Hiero if its GUI allows that.

I have an idea that using the AngleCode software to create a *.fnt file ,and in the anglecode you can make all the fonts youwant.