[SOLVED] Issues with font embed for adobe air mobile target


#1

Hi,

during may port from as3 to haxe, found issue with custom fonts (just Arbutus Slab font from 4 fonts in game have this issue ), I am using starling/featherui in flash target but pure openFl textfield have the same issue.

Firstly I register a font like this:

@:font("../../../fonts/Arbutus_Slab/ArbutusSlab-Regular.ttf")
private class Arbutus extends Font {}
class Fonts {
public static function init() {
        Font.registerFont(Arbutus);
        trace((new Arbutus()).fontName);
    }
}

then inited textfield :

Fonts.init();
var format:openfl.text.TextFormat = new openfl.text.TextFormat("Arbutus Slab Regular", 30,0);
var txt:openfl.text.TextField = new openfl.text.TextField();
txt.embedFonts = true;
txt.defaultTextFormat = format;
txt.text = "value of the card (please look into \"Deck\").";
txt.width = 1000;
addChild(txt);

this gives following text in xcode simmulator for adobe air:
19
brackets have different position and in place of brakcets is extra space.

could that be an embedding issue? works well on the pure as3 project, in flash embedding was done like this:

[Embed(source = '../../../fonts/Arbutus_Slab/ArbutusSlab-Regular.ttf', fontName = 'Arbutus Slab', embedAsCFF = 'false')]
public static const FONT_ARBUTUS: Class;

thanks for any idea :slight_smile:


#2

This appears to work:

1.) Run openfl create project FontEmbedTest
2.) Add “ArbutusSlab-Regular.ttf” to the generated “Assets” folder
3.) Update the “Main.hx” class

package;


import openfl.display.Sprite;
import openfl.text.TextField;
import openfl.text.TextFormat;


class Main extends Sprite {
	
	
	public function new () {
		
		super ();
		
		var textField = new TextField ();
		textField.defaultTextFormat = new TextFormat ("Arbutus Slab Regular", 40);
		textField.width = 1000;
		textField.text = "value of the card (please look into \"Deck\").";
		textField.embedFonts = true;
		addChild (textField);
		
	}
	
	
}

When using Lime to target Flash, we automatically embed fonts that are included with your assets, based on the name of the font found in the file.

I’m not sure if maybe there’s a difference in how we embed ourselves, compared to the Haxe @:font embed?


#3

@singmajesty hey thanks :slight_smile: looks like work now, really strange, but thought that @:font is official way to embed fonts :D, now did it through project.xml like this <assets path="fonts" include="*.ttf" embed="true" /> and work fine.


#4

On the Flash target, @:font is embedding using the Haxe compiler. Using the our command-line tools, we embed on Flash ourselves, and perhaps we’ve fixed a big with certain types of font advances that isn’t handled quite right in the compiler.