Hi,
This is a pretty generic question that I ran into using haxeui-openfl html5 build.
If I have test.ttf in assets/fonts openfl/lime will load the file as a font resource and Haxeui can automatically use it.
Now I would like to access the actual bytes of that resource (because an external pdf library needs it). And I expect openfl.Assets.getBytes(“assets/fonts/test.ttf”) would give me that. But that fails.
Would you perhaps know why?
I can duplicate the font file, rename it test.wtf and load those bytes. And that works fine! But I’m actually using Arial Unicode MS which is 25MB, so I don’t what to add 50MB(ttf+wtf) to an HTML5 App.
I can also add to get the bytes, but that prevents the font from getting loaded automatically, which is not what I want.
Alternatively, it is possible to get bytes in a different way using a macro:
@:font(“assets/font/Arial-Unicode.ttf”)
private class ArialUnicodeMS extends openfl.text.Font {}
And then later:
var bytes:haxe.io.Bytes = haxe.Resource.getBytes(ArialUnicodeMS.resourceName);
var ba:flash.utils.ByteArray = openfl.utils.ByteArray.fromBytes(bytes);
But these are not the same bytes as those you get from Assets.getBytes. Seems to be the bytes of the instanced font object instead of the raw bytes.
So, in short, I’m looking for a way to get the raw bytes of a font object. You seem pretty knowledgeable about fonts , do you know how to get those pesky bytes while having the fonts loaded normally?
Thanks!