Problem with label when using font

i’ve been playing with your gui for a little project of mine, and i’vr brrn blocked by a problem with label :

i’m adding a label to the top of the screen (tittle).

  • If i don’t set any font, every thing is ok.
  • if I set a font from a fnt file, the text is flipped in both x and y. The letters are correct, but flipped.

The font file is generated using BMFont.

since the letter are correct, the image file is correctly readed. i don’t understand what i’m doing wrong here…

mohira

Hey there…

Can you post the .fnt and .png files for the font so I can have a look?

I use BMFont as well and haven’t seen this problem before.

Also, have you tried this with the GUI library to see if the problem is there as well?

The library uses BitmapFont as the backing class for all text.

Hello,

the code to add the label is the following :

[java] protected void addTitle(){
Label label = new Label(screen, new Vector2f(0, 0), new Vector2f(
screen.getWidth(),screen.getHeight() / 10 + 2));
label.setText(“Hex Mapper”);
label.setFontSize(screen.getHeight() / 10);
label.setTextAlign(Align.Center);
//label.setFont(“interface/BigFont.fnt”);
label.setIgnoreMouse(true);
guiComponents.add(label);

}

[/java]

Here is the font file :
font file

Here is the png file for the font :

without font, the result is

with the font uncommented, the result is

Just posting a note to let you know I’ll have time to play with this later today. Were you able to test loading the font not using the GUI? If so, what were the results? If not, I’ll try it while I’m testing.

I’ve tried to use the JME BitmapFont & BitmapText

[java]
BitmapFont font = application.getAssetManager().loadFont(“interface/BigFont.fnt”);
BitmapText txt = new BitmapText(font);
txt.setText(“HEX mapper”);
txt.setLocalTranslation(new Vector3f(50,50,50));
application.getGuiNode().attachChild(txt);
[/java]

this is working well : the text does appears, in the correct order…

i don’t understand what i’m doieng wrong here…

for info, the label is the second element add to the screen. it is not added to a parent, but directly to the screen (class Screen, i mean).
(currently the interface is so simple there is no need for layout or any thing fancy. just a title, and somme button…)

thanks for your help.

@mohira said: I've tried to use the JME BitmapFont & BitmapText

[java]
BitmapFont font = application.getAssetManager().loadFont(“interface/BigFont.fnt”);
BitmapText txt = new BitmapText(font);
txt.setText(“HEX mapper”);
txt.setLocalTranslation(new Vector3f(50,50,50));
application.getGuiNode().attachChild(txt);
[/java]

this is working well : the text does appears, in the correct order…

i don’t understand what i’m doieng wrong here…

for info, the label is the second element add to the screen. it is not added to a parent, but directly to the screen (class Screen, i mean).
(currently the interface is so simple there is no need for layout or any thing fancy. just a title, and somme button…)

thanks for your help.

I’m wondering is it isn’t charset=“ANSI” in the .fnt file. There was another issue revolving around the particular keypair recently. Set charset="" and see if this is the problem. If it is, I’ll have some place to start working off of to resolve the issue.

My guess is, because there is only a single font page, that the charset value is freaking out the font loader (which makes no real sense… but hey! weirder stuff has happened)… at least I am hoping this is the case.

This is it !

Exporting with the option charset “ANSI” instead or charset “Unicode” is causing the problem !

that was really beginning to bug me !
thank you very much !

regards

1 Like
@mohira said: This is it !

Exporting with the option charset “ANSI” instead or charset “Unicode” is causing the problem !

that was really beginning to bug me !
thank you very much !

regards

Thanks for testing this. Thats two separate issues I have seen due to the charset value and narrows down exactly where to start researching the issue and how to fix it. Appreciate your patience here!