Embed font problem in flash/windows next


I try to use htmlText with embedded fonts and I have encountered some problem on windows next and flash target.

I just want to set a simple html text like this one : this is <b>bold</b> and it should display > this is bold.
On flash target the <b> with Textfield.embedFonts=true; doesn't work.

Windows legacy works as expected

Windows next doesn’t work as expected (<b>bold</b> and setTextFormat don’t work)

Flash doesn’t work as expected (<b>bold</b> on embed fonts doesn’t work)

Here is my code :

var normalFontName:String = Assets.getFont("fonts/LATO-REGULAR.TTF").fontName;
	var boldFontName:String = Assets.getFont("fonts/LATO-BOLD.TTF").fontName;
	trace(normalFontName, boldFontName);
	var formatNormal:TextFormat = new TextFormat(normalFontName, 15, 0);
	var formatBold:TextFormat = new TextFormat(boldFontName, 15, 0);
	var normalTF:TextField = new TextField();
	normalTF.embedFonts = true;
	normalTF.defaultTextFormat = formatNormal;
	normalTF.text = "embed normal";
	var boldTF:TextField = new TextField();
	boldTF.embedFonts = true;
	boldTF.defaultTextFormat = formatBold;
	boldTF.text = "embed bold";
	boldTF.y = 20;
	var bothTF:TextField = new TextField();
	bothTF.embedFonts = true;
	bothTF.autoSize = TextFieldAutoSize.LEFT;
	bothTF.defaultTextFormat = formatNormal;
	var text:String = "embed setTextFormat normal <B>bold</B>";
	bothTF.htmlText = text;
	if (text.indexOf('<B>') != -1) {
			var index:Int = text.indexOf('<B>');
			bothTF.setTextFormat(formatBold, index, bothTF.text.length);
	bothTF.y = 40;
	var htmlTF:TextField = new TextField();
	htmlTF.embedFonts = true;
	htmlTF.autoSize = TextFieldAutoSize.LEFT;
	htmlTF.defaultTextFormat = formatNormal;
	htmlTF.htmlText = "embed html normal <b>bold</b>";
	htmlTF.y = 60;
	var htmlNotEmbedTF:TextField = new TextField();
	htmlNotEmbedTF.embedFonts = false;
	htmlNotEmbedTF.autoSize = TextFieldAutoSize.LEFT;
	htmlNotEmbedTF.defaultTextFormat = formatNormal;
	htmlNotEmbedTF.htmlText = "notEmbed html normal <b>bold</b>";
	htmlNotEmbedTF.y = 80;

Maybe I have missed something for the flash target because windows legacy works ? But anyway I need to make it work on flash. Any idea to resolve this issue? Thanks.

EDIT: I’m using last haxelib 3.0.3 openfl

The new text code does not understand the relationship between “Arial” and “Arial Bold”, at the moment. That’s why you can embed one or the other, but not both.

The legacy is not (if I recall) using Arial Bold (or whatever font you are using) but actually emboldens the glyphs itself, or perhaps lets Freetype true to force the font to be bold. Either way, we ideally want to be able to use the real font

Thanks for your answer @singmajesty

And why this is <b>bold</b> on textfield with embed fonts doesn’t work on the flash target?

Perhaps something with how embed fonts, perhaps it is embedded as “Arial” and “Arial Bold” instead of “Arial” (type normal) and “Arial” (type bold)

Yes you are right.

In a as3/flash IDE project I have fontName=Arial and fontStyle=Bold.
But in haxe/Openfl, I have fontName=Arial Bold and fontStyle=Bold

Is this an openfl or haxe problem?

ATM, OpenFL is supporting only “Arial Bold”, and does not formally support fontName + the font style. Someone will have to spend time to work through it to see if we can get consistent results across all targets using the more proper system