Bugged font after update

After update, some text in game shows weird font I never used

and I found If I revert this change in TextField.hx
everything works normal again

1 Like

Could you share what code you use to embed fonts?

They should now work either using the font name (“Arial”) or by using the getFont method (Assets.getFont ("assets/arial.ttf").fontName)

I’m using HaxeFlixel
I found that If I set font first and then set text Size
this problem will be solved, that’s really weird

so this is FlxText’s code

private function set_size(Size:Float):Float
{
	_defaultFormat.size = Size;
	_textField.defaultTextFormat = _defaultFormat;
	updateFormat(_defaultFormat);
	dirty = true;
	
	return Size;
}

private function set_font(Font:String):String
{
	_textField.embedFonts = true;
	_defaultFormat.font = Assets.getFont(Font).fontName;
	_textField.defaultTextFormat = _defaultFormat;
	updateFormat(_defaultFormat);
	dirty = true;
	return Font;
}

private inline function updateFormat(Format:TextFormat):Void
{
	#if !flash
	_textField.setTextFormat(Format, 0, _textField.text.length);
	#else
	_textField.setTextFormat(Format);
	#end
}

Strange, I guess this is a Flixel bug?

I have the same bug in my app, and I don’t use flixel (or any other game engine). It looks strange - some textfields have incorrect font, while other - correct.

Reverting back “Fix v2 embedFonts behavior” helps.

(by the way, I use lime from haxelib)

Do you know an exact scenario I could use to replicate this?

I will try to create minimal demo project in a few days.

Finally able to reproduce this bug with minimal code - http://blog.zame-dev.org/pub/textfieldbug.zip

Illustration:

Fine on flash and html5 (both canvas and dom modes), but wrong font on native and neko.

To reproduce bug:

  1. set text
  2. call setTextFormat, change anything, but font
  3. call setTextFormat, with changed font

P. S. Created as issue in openfl repo - https://github.com/openfl/openfl/issues/492

Thanks for sorting this out! I will try and look soon to see if we can get a fix :smile:

One more thing: reverting https://github.com/openfl/openfl/commit/94193db04829ce9df201f5f0727316852fb68646 has no effect since latest openfl / lime updates (previously it “fixes” fonts)

Fixed :smile:

1 Like