How to apply custom font to Label (I mean class not window or button label)

Hi, so I’ve been trying to use the Label class for text but I cannot apply custom font which is arial.
When I use label.style.fontName = ‘C:\Windows\Fonts\arial.ttf’; and load the game it says “Critical Error: Uncatchable Throw: Null Object Reference”

Also I would like response in haxe code thanks. :smiley:

Hi,

So i think you’ll need to include it as resource, i dont believe the it will work from files (although you can try file://C:/Windows/Fonts/arial.ttf - but i suspect that wont work either)

So you’ll either need to include it as part of your frameworks asset system, or use a module.xml to include it as a haxe resource (which haxeui will then find and load)

Cheers,
Ian

Oh, also, you shouldnt use .style, you should use .customStyle (the naming is bad, and will change at some point fyi).

Better to just use css directly anyway imo :slight_smile:

Sorry for the late response but thank you so so much it worked. Also I could just use text.customStyle.fontName = ‘Arial’; to get it working.

1 Like