Can I set a font for Lemur in the Groovy file?

I would like to set another font for my Lemur interface.

I found a solution that leans on code and the style selector class. That one does not work if you are also using the Selector component. I could not get it to work and It is also a very old solution.

Setting the font in Groovy would be far more elegant anyway.

I’m sure there is a way but I cannot find a reference at the moment… and for some reason font seems to not be a stylable attribute. But I’m positive that I’ve done it before.

Ah, I found an example of changing the font for the whole style:

selector( "scifi" ) {
    font = font("Fonts/anita30.fnt")
    fontSize = 15

…which may be close enough for what you need.

Too bad, it does not work…

It definitely does.

And again you are right… there were a few different problems:
first of all I had commented out the defaultStyle, so most components did not get styled by the script.

Then the default stylename is ‘ungaMunga’, but for stuff like titles or rows I use ungaTitle and ungaRow.

Turning on the default styles broke my gui, not only visualy but - more worrying - it complains a lot about dimensions that should not be negative.

To me, these should be element IDs within the main style. Else you will have endless pain like this.

Then some parts of your style are bigger than the space you give the GUI elements. Like somewhere you forced a label to be 10 units high but it has more than 10 units of border/margin and so the part inside wants a negative size.

Usually you can spot these by removing forced setPreferredSize calls and let the UI layout naturally.

Edit: though one very common thing that users do that causes this is squashing the ‘z’ size thinking that it doesn’t matter. Nearly all of the GUI elements have a thickness and if you give them a 0 preferred size ‘z’ then they will have issues.

I anticipate over fourty dialog- and menu titles and a multitude of rows. Could I give these items the same ID?

That might be an issue in my code as well…

The ElementId is for styling only. By default, Button has an ElementId of “button”… so already every button you see probably has the “same ID”.

Since I was wanted to change my interface anyway, I decided to redo it one more time.

I just found an older post you wrote, that is very helpful. It is strange that I did not find it earlier since I did do a lot of searching on Lemur and Style. Everyone working with Lemur should read it, or even, you might want to add it to the Lemur Wiki:

1 Like

Some of that was also put into the Lemur wiki… for folks who may not have read the docs there, here’s a direct link:

Edit: also at the beginning of September, I did a live stream where Is started restyling the Mythruna UI. I’ve just gone back and added chapter markers to it to make it easier to skip around and/or find specific things again after you’ve already watched it.

1 Like

The new insights help a lot.

I wrote a little tool to help me find out the ElementID hierarchy of Lemur controls. That too helps a lot:

    private final static String indentString = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
    static void showLemurChildren(Spatial s,int indent){
        if (s instanceof Panel ){
            Panel p=(Panel) s;
            utils.LOG(indentString.substring(0, indent)+"Element ID:"+p.getElementId().toString());
        if (s instanceof Node) {
            Node n = (Node) s;
            for (Spatial spatial : n.getChildren()) {
                utils.showLemurChildren(spatial, indent + 1);

Just feed any Lemur control to it, or even guiNode if you need to figure out something like the list of a selector item that is added later on.