GUI 2D 'ImageWithCenterTextButton' 'textBlock' part does not inherit 'fontFamily' from button anymore

Not sure this is a bug, but while updating my old project ‘Snowball demo’ for v5.5, I discovered that the ‘fontFamily’ now needs to be set on the ‘textBlock’ part of the control. Where, previously, (if not specified) it inheritated the font from the button. Might be also true for other buttons.

cc @DarraghBurke

It seems to work okay here: Simple GUI in fullscreen mode | Babylon.js Playground (babylonjs.com)

Can you provide a repro in the playground for the behavior you’re seeing?

Something weird happening here.
In the PG, your PG, pasted my button as is in my project and … it works

However, same button, linked to cdn version of my project gets this result (press Q to open settings panel).
https://media-geneva.ch/bjsdev/psa-v5-5-dev.html

The ‘keybindings button’ next to it is in the same stackpanel and uses the same font. Only this one has the addition (made for v5) of

buttonKb.textBlock.fontFamily = “Bebas Neue”;

While both where working without this in 4.2

Edit: I also confirm the panel itself has no ‘fontFamily’ instruction. FYI: the container is called ‘panel5’ and is assigned to the grid. Arial is showing but must be the default because I checked back on the script and there’s no ‘fontFamily’ for these.

Hmm, it looks like the child will take the parent’s font when it’s initially created, but if you change the child’s font after creation, it will overwrite that font. This is because of a _fontSet boolean being flipped. You can see this behavior here: Simple GUI in fullscreen mode | Babylon.js Playground (babylonjs.com)

Can you check if your “User Settings” text block has _fontSet set to true?

Nope. I’m afraid not.
According to the console, it is set to ‘false’ same as in the PG

(at least when I check the console after the GUI is entirely created).

Just loaded the demo and it looks like it’s working now:

Did you change something in the setup code? Not sure why it wasn’t rendering with the correct font before, but it seems right now

What? No, certainly didn’t change the PG and is now also working for me!!!
Let’s call it a miracle :innocent: or an automagical fix :magic_wand:
Anyways, it seems to be ok now :smiley:

1 Like