Font.hasGlyphs and line breaks not working
Hi everybody,
I have a function for checking whether the embedded font has all the glyphs available, it looks like this:
public static function hasEmbeddedAllGlyphs(string:String, fontName:String):Boolean {
var availableFonts:Array = Font.enumerateFonts();
for(var i:uint=0; i<availableFonts.length; i++) {
if(availableFonts.fontName == fontName) {
return availableFonts.hasGlyphs(string);
break;
}
}
return false;
}
Now this works flawlessy if I call it with this:
var s:String = "line 1 line 2";
trace(FontUtil.hasEmbeddedAllGlyphs(s, FontUtil.EMBEDDED_FONT_1)); // returns true
However if I add a linebreak into the string, it stops working:
var s:String = "line 1 \n line 2";
trace(FontUtil.hasEmbeddedAllGlyphs(s, FontUtil.EMBEDDED_FONT_1)); // returns false!
What the... why exactly is this so and does anybody know a workaround? I am using this call in another static method which sets the text depending on the available font and therefore I cannot split the string.
Thank you!