When I look a the code , It seems that the font needs to be in the Assets or in Resource. But I don’t have a dynamic way to add my font to the Assets or Resource ( I think … ) .
The thing is I open an epub, in the epub there are fonts, that I unzip to use them.
Inspired by the code , I tried
var font = openfl.text.Font.fromBytes(fontBytes);
var fontInfo = {
data: font.fontName
}
openfl.text.Font.registerFont(font);
haxe.ui.ToolkitAssets.instance._onFontLoaded(font.name, fontInfo); // With a private acesse, but it doesn't seem to work
in fact font loaded also mentions resourceID
private function _onFontLoaded(resourceId:String, font:FontInfo) {
if (_fontCache == null) {
_fontCache = new Map<String, FontInfo>();
}
_fontCache.set(resourceId, font);
_fontCallbacks.invokeAndRemove(resourceId, font);
}
So maybe in fact the problem, how do I add a resource id dynamically ?
can you paste in your full working code? Maybe we can add a “fontFromBytes” into the AssetsBase class… could be useful in the future. But before i refactor the code, id like to see the full code of what worked for you.
Cheers,
Ian
EDIT: oh, hang on, that is the working modified code, correct?
So i think thats a good optimisation anyway… no point in loading it if its already loaded!
Ill also see about exposing some “fontFromBytes” call… ill write here when ive made the changes and tested locally… maybe you can test it in your app for me?
In fact my modification was useless . It works without it , ( you still need to register fonts with openfl though). The fonts ( and more precisely the description of the fonts) were the problem, they give a bad name.
I actually think it would.
Maybe it’s far away, but you can already have gui theme for haxeui. Maybe you could use external ui themes ( with their own fonts), and easily enable to skin a program which is made with haxe ui