[SOLVED] How to debug Lemur theming?

While switching to the latest snapshot, I noticed a weird change: my theme was using the default font for Buttons (Labels are instead unaffected), despite using the same font:

selector( "big", "label", "amethyst" ) {
    color = blackColor
    background = defPinkBackground
    font = fontBig //this works for Labels
    fontSize = 39
    textVAlignment = VAlignment.Center
    textHAlignment = HAlignment.Center
}

selector( "button", "amethyst" ) {
    background = defBackground
    color = pinkColor
    highlightColor = blackColor
    focusColor = blackColor
    disabledColor = grayColor
    font = fontBig //this does nothing for Buttons
    fontSize = 39
    textVAlignment = VAlignment.Center
    textHAlignment = HAlignment.Center
    //insets = new Insets3f( 2, 2, 2, 2 );

    buttonCommands = stdButtonCommands;
}

ActionButton b = new ActionButton(mains[i], new ElementId("big.button"));
Label cam = new Label(CAMPAIGN_MODE_TEXT, new ElementId("big.label"));

Every settings works except for the font… any advice is welcome, thanks!

I noticed that while your button’s elementId is ‘big.button’, your selector is ‘selector(“button”, “amethyst”)’. Doesn’t the selector miss a ‘big’ keyword from it?

It should still work, though. A selector for “button” on its own is more general than “big.button” and so on.

Is this your whole style file?

I think in the past when I’ve gotten really confused by styling, sometimes turning on trace-level logging for the style package gives me additional hints.

Otherwise, I cannot easily spot the issue.

With the debug, I noticed this:

applyStyles elementId:ElementId[big.button] style:null(amethyst)
style attributes:Attributes[{highlightColor=Color[0.0, 0.0, 0.0, 1.0], fontName=Interface/Fonts/Default.fnt, buttonCommands={HighlightOn=[Script2$2@293851f4], HighlightOff=[Script2$3@273357a2], FocusGained=[Script2$4@25086c1c], FocusLost=[Script2$5@7ec1b5ab], Enabled=[Script2$6@151dec76], Disabled=[Script2$7@282e3730], Down=[Script2$1@4e20d6a5], Up=[Script2$1@4e20d6a5]}, color=Color[1.0, 0.5, 1.0, 1.0], focusColor=Color[0.0, 0.0, 0.0, 1.0], background=com.simsilica.lemur.component.TbtQuadBackgroundComponent[texture=Texture2D[name=Interface/ui-menu-button-black.png, image=Image[size=250x68, format=ABGR8]], color=null, alpha=1.0, margin=(40.0, 0.0), zOffset=0.0], textHAlignment=Center, fontSize=39, disabledColor=Color[0.5, 0.5, 0.5, 1.0], shadowColor=Color[0.0, 0.0, 0.0, 0.5], font=com.jme3.font.BitmapFont@3dbf5e27, textVAlignment=Center}]
applyStyles elementId:ElementId[big.label] style:null(amethyst)
style attributes:Attributes[{fontName=Interface/Fonts/Default.fnt, color=Color[0.0, 0.0, 0.0, 1.0], background=com.simsilica.lemur.component.TbtQuadBackgroundComponent[texture=Texture2D[name=Interface/ui-menu-button-pink.png, image=Image[size=250x68, format=ABGR8]], color=null, alpha=1.0, margin=(40.0, 0.0), zOffset=1.0], textHAlignment=Center, fontSize=39, font=com.jme3.font.BitmapFont@3dbf5e27, textVAlignment=Center}]

It looks fine to me…
This is the style

And this is the log

Yeah, and it seems to be using the same font for both the label and the button:

I can’t really explain it unless something else is changing the font.

Mmm… I wonder if this is related to the pluggable text changes.

Might be you can switch out the font to be fontName instead. Somehow fontName is getting the default font and might be overriding your actual BitmapFont instance.

Edit: to be clear, all of that stuff is supposed to be backwards compatible so I still want to fix the issue… but it might get you past your problem today to switch to the “new way”.

You mean like this?

    fontName = fontBig

Because if that is the case, I get:

lug 03, 2025 5:30:35 PM com.jme3.app.LegacyApplication handleError
GRAVE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.ClassCastException: class com.jme3.font.BitmapFont cannot be cast to class java.lang.String (com.jme3.font.BitmapFont is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
	at com.simsilica.lemur.Label.createText2d(Label.java:146)
	at com.simsilica.lemur.Label.<init>(Label.java:109)
	at com.simsilica.lemur.Button.<init>(Button.java:121)
	at com.simsilica.lemur.Button.<init>(Button.java:117)
	at com.simsilica.lemur.ActionButton.<init>(ActionButton.java:71)
	at com.simsilica.lemur.ActionButton.<init>(ActionButton.java:67)
	at com.pesegato.p8s.appstates.MainMenuAppState2.initialize(MainMenuAppState2.java:114)
	at com.jme3.app.state.BaseAppState.initialize(BaseAppState.java:129)
	at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:332)
	at com.jme3.app.state.AppStateManager.update(AppStateManager.java:362)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:260)
	at com.jme3.system.lwjgl.LwjglWindow.runLoop(LwjglWindow.java:629)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:719)
	at java.base/java.lang.Thread.run(Thread.java:829)

No. The font name should be the font name. Not the font.

So in your case:

fontName = 'Interface/Fonts/FrizQuadrataTT_39.fnt'

Edit: the font name support was added so that implementations other than BitmapFont could be used and styled, etc… just need other Text2d implementations to take advantage of them.

1 Like

That worked, thanks!

1 Like

Also I’ve replaced all instances of font with fontName. I’m going to assume this is the “better” way, which also makes the style more tidy.

1 Like

Yes. I think it’s the “new better way”… in the “wish I’d thought of it originally” kind of way.

I still wish backwards compatibility had worked but I’m also not going to lose a lot of sleep over it at the moment. :slight_smile:

Glad the new way worked for you.

1 Like