~~~~~ Not showing custom font when built to HTML5

for fonts

Unlike the windows build, when I build it in HTML5, my code set to use MyCostumFont.TFF does not use that font and instead is some regular font. Font Size is correct though,

So where I put text on the buttons I use

		var textField:TextField = new TextField();
		var textFormat:TextFormat = new TextFormat();

		textFormat.font = "fonts/SpecialThin.ttf";
		textFormat.size = 30;
		textFormat.color = TextColorConverter(ButtonTextColor.Normal);
		//textField.embedFonts = true; - i tried enabling it doesnt work on HTML5 and not needed on Widows build
		textField.x = this.width * 0.35;
		textField.y = this.height * 0.1;
		textField.autoSize = TextFieldAutoSize.CENTER;
		textField.text = buttonText;
		textField.mouseEnabled = false;


Can you try the name of the font, not the path? For example, “Arial Regular” instead of “fonts/arial.ttf”

(when you openfl test html5 -verbose, it should show you what font names are detected when processing them)

This is exactly the solution, in some other builds path can be used but the name as it appears makes it show for html5. Thanks

1 Like