I have a few questions about Lemur's BitmapFont

  • When I zoom in on the font I can see the black block behind it,Was that expected?

  • Lemur fonts use bitmap images and when I zoom in the fonts get fuzzy what’s the best way to fix it?

/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package GUI;

import CameraAndMouse.CamAndMouseCur;
import com.jme3.app.Application;
import com.jme3.app.SimpleApplication;
import static com.jme3.app.SimpleApplication.INPUT_MAPPING_EXIT;
import com.jme3.app.state.BaseAppState;
import com.jme3.asset.AssetManager;
import com.jme3.font.BitmapFont;
import com.jme3.input.InputManager;
import com.jme3.math.ColorRGBA;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Command;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.TextField;
import com.simsilica.lemur.style.BaseStyles;
import com.simsilica.lemur.style.Styles;
import java.util.logging.Logger;

/**
 *
 * @author Icyboxs
 */
public class UI extends BaseAppState{
   private static Logger log =Logger.getLogger(UI.class.toString());
    private InputManager inputManager;
    private AssetManager assetManager;
    private SimpleApplication simpleApp;
    private BitmapFont font;
    @Override
    protected void initialize(Application aplctn) {
       simpleApp = (SimpleApplication) aplctn;
        assetManager = aplctn.getAssetManager();
        inputManager = aplctn.getInputManager();
        inputManager.deleteMapping(INPUT_MAPPING_EXIT);
        GuiGlobals.initialize(simpleApp);
        BaseStyles.loadGlassStyle();
        GuiGlobals.getInstance().getStyles().setDefaultStyle("glass");
    
    font = assetManager.loadFont("Textures/font/yahei/test.fnt");
    System.err.println(font.toString());
    GuiGlobals.getInstance().getStyles().setDefault(font);
    
    }

    @Override
    protected void cleanup(Application app) {
   
    }

    @Override
    protected void onEnable() {
        // Create a simple container for our elements
        Container myWindow = new Container();
        simpleApp.getGuiNode().attachChild(myWindow);

// Put it somewhere that we will see it.
// Note: Lemur GUI elements grow down from the upper left corner.
        myWindow.setLocalTranslation(0, 1070, 0);
TextField textField = new TextField("这是一段测试文本");
	textField.setFontSize(50f);
// Add some elements
Label label=new Label("Hello, World.");
label.setFont(font);
label.setFontSize(500f);
label.setColor(ColorRGBA.Blue);
        myWindow.addChild(label);
        myWindow.addChild(textField);
        Button clickMe = myWindow.addChild(new Button("中文"));
        clickMe.addClickCommands(new Command<Button>() {
            @Override
            public void execute(Button source) {
                System.out.println("中文");
                //simpleApp.stop();
            }
        });
    }

    @Override
    protected void onDisable() {
   
    }
    
}

BitMapFont is not a Lemur class, it is a JME class that is used by JME’s stock BitMapText and also gets re-used by most of JME’s gui libraries (like lemur)

I do not think that should be happening if you are using lemur’s Label.
It looks like your blue “Hello, World” text is actually being rendered using JME’s stock BitMapText class, but that’s just a guess based on the issue your having and the fact it doesn’t look like a lemur label. If so, then you need to set the blend mode to alpha and give the BitMapText an alphaDiscardThreshold value.

This is related to the image size of the BitMap font’s png file. Just like with texturing 3d objects, a higher resolution texture will produce less aliasing, and a lower resolution texture will cause more aliasing especially when viewed at very close distances.

1 Like

Fonts shouldn’t do this in Lemur (though they will do this in JME). Lemur automatically gives fonts an alphaDiscardThreshold as I recall.

Is this in the 3D scene or in the guiNode? …because it especially shouldn’t happen in the guiNode. In the 3D scene there can be some additional things to do to fix these z-sorting issues.

For a deeper explanation: Alpha/Transparency Sorting, Your Z-buffer, and You

Use higher resolution fonts.

1 Like

This is in GuiNode

simpleApp.getGuiNode().attachChild(myWindow);

I don’t know what the issue is. Something is messed up with JME, though.

…even regular JME BItmapText would do this.

I remember sometimes on some platforms, JME users used to be able to get the guiNode to sort backwards. I don’t remember how that bug was triggered or if it still exists.

1 Like

Thank you for your reply.