Changing font variable

Can anyone suggest how to change the content of a font in script?

I have a text field called word which I need to change on a button press (const word = symbol.nodes.word;)

Thank you

1 Like

Hello @stephen.bedser
What you can do about it is have a text node on your hierarchy and do a code like this:

symbol.nodes.btn.on("pointerup", ()=>{
    symbol.nodes.fontRoboto.font(symbol.mediaFiles.Blackout_ttf)
});

In this way your text’s font will change as expected. You can do some kinda of array for this if you want so with all your mediaFiles fonts.

att, HigĂŁo.

1 Like

Thanks higor :slight_smile:

1 Like

@higor …looking at that, I actually want to change the text contained… so if the word displayed was say “one” I want the same text container to be changed to say “two”…can I use variables? Apologies if I’m not explaining myself right ! :slight_smile:

1 Like

No worries, maybe I understand it wrong. All you have to do then is change a little part of your code, like this:

symbol.nodes.btn.on("pointerup", ()=>{
    symbol.nodes.fontRoboto.text("text what you want to change");
});

Try this one and tell me.

Att, HigĂŁo;

4 Likes

Wonderful, thanks for your help @higor!

2 Likes

Nice one @higor - super helpful as always.

2 Likes

Thank you @james.wright :smiley:

I try…

att, HigĂŁo.

2 Likes