Hi,
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";
addChild(normalTF);
var boldTF:TextField = new TextField();
boldTF.embedFonts = true;
boldTF.defaultTextFormat = formatBold;
boldTF.text = "embed bold";
boldTF.y = 20;
addChild(boldTF);
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;
addChild(bothTF);
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;
addChild(htmlTF);
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;
addChild(htmlNotEmbedTF);
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