Okay - so not gone with Starling to solve this, but others may wish to know how I resolved it.
The embedAsCFF="true" gave me a clue. When using TLFTextFields you can use the TextLayoutFormat and TextFlow classes.
There is a property of TextLayoutFormat called fontLookup, where you can specify to lookup embedded CFF fonts.
So.. on Mac, to get those embedded fonts (and font loaded from an external swf) working properly that's what we need to do...
As I'm doing this with fonts embeded in another swf, I'll include two classes here to help folk out trying to do the same thing.
package {
import flash.display.MovieClip;
public class FontExample extends MovieClip {
[Embed(source="../assets/fonts/NotoSans-Regular.ttf",
fontName = "Noto Sans",
mimeType = "application/x-font",
embedAsCFF="true")]
private var NotoSansRegular:Class;
[Embed(source="../assets/fonts/NotoSans-Bold.ttf",
fontName = "Noto Sans Bold",
mimeType = "application/x-font",
embedAsCFF="true")]
private var NotoSansBold:Class;
[Embed(source="../assets/fonts/NotoSans-Italic.ttf",
fontName = "Noto Sans Italic",
mimeType = "application/x-font",
embedAsCFF="true")]
private var NotoSansItalic:Class;
[Embed(source="../assets/fonts/NotoSans-BoldItalic.ttf",
fontName = "Noto Sans Bold Italic",
mimeType = "application/x-font",
embedAsCFF="true")]
private var NotoSansBoldItalic:Class;
}
}
`
And then the code that demonstrates loading it in - accessing the class names and creating a TLF textfield that works on Macs...
'
package {
import fl.text.TLFTextField;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.text.Font;
import flash.text.engine.FontLookup;
import flash.text.engine.FontPosture;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.formats.TextLayoutFormat;
public class LoadFontSpike extends MovieClip {
public var ldr:Loader = new Loader();
public function LoadFontSpike() {
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
loadFontSwf("FontExample.swf");
}
private function loadFontSwf(url:String):void {
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onFontSwfLoaded);
var context:LoaderContext = new LoaderContext();
context.applicationDomain=ApplicationDomain.currentDomain;
loader.load(new URLRequest(url),context);
}
private function onFontSwfLoaded(e:Event):void {
var names:Array = ["FontExample_NotoSansRegular","FontExample_NotoSansBold","FontExample_NotoSansItalic","FontExample_NotoSansBoldItalic"];
for(var i:int =0; i< names.length; i++)
{
var FontLibrary:Class = e.target.applicationDomain.getDefinition(names[i]) as Class;
Font.registerFont(FontLibrary);
}
drawText();
}
public function drawText():void {
var myTLFTextField:TLFTextField = new TLFTextField();
addChild(myTLFTextField);
myTLFTextField.border = true;
myTLFTextField.y = 110;
myTLFTextField.width = 400
myTLFTextField.height = 100;
myTLFTextField.text = "This is my مؤتمر الدولي العاشر ليونيكود text";
myTLFTextField.embedFonts = true;
this.addChild( myTLFTextField );
var myFormat:TextLayoutFormat = new TextLayoutFormat();
myFormat.textIndent = 8;
myFormat.color = 0x336633;
myFormat.fontFamily = "Noto Sans Bold Italic";
myFormat.fontStyle = FontPosture.NORMAL;
myFormat.fontLookup = FontLookup.EMBEDDED_CFF;
myFormat.fontSize = 24;
var myTextFlow:TextFlow = myTLFTextField.textFlow;
myTextFlow.hostFormat = myFormat;
myTextFlow.flowComposer.updateAllControllers();
}
}
}
'
Actually - this example is a bit duff because Noto Sans doesn't support those arabic characters (it's just what I was using to test multiple weights). I've tried it with something like Lalezar though, and it renders just dandy. 🙂
Addendum: Once your fontLookup is set you can use normal TextFormats to change the font at particular parts of the string (prob. because it conforms to ITextLayoutFormat)