Closed NoodlesOfWrath closed 1 month ago
Yes this is currently doable, this is a documentation issue (and possibly the API could be improved).
There is a way to do it with https://docs.rs/fontique/0.1.0/fontique/struct.Collection.html#method.register_fonts
You load the file into a Vec<u8>
(currently) and then pass it to this method on your Collection, and that makes it available in the Collection by the name it has in the provided file. This API is likely to be improved in the future, to be more friendly to zero-copy (not possible with Vec<u8>
) and memory-mapped fonts; probably we will expose a variant of this which accepts a Path
or File
and memory maps it itself.
Feel free to let me know if you figure out what you want to do with it in your use case, and we can add an example that is similar to that in the future. :+ )
To add: fontique::Collection
is a property of parley::FontContext
Thanks! How much data does parley::FontContext
and fontique::Collection
hold? In the example, it is created new when rendering, but should it be handled differently in a larger renderer or is creating a new one everytime something is changed fine?
Loading and categorizing fonts is fairly slow so you should create one Collection per application (or thread).
When trying to create an app, it's useful to be able to use fonts directly from their files. Something like
FontFamily::Local("../MyFont.tff")
. Is there any way to do this currently? If not what will it take to implement? If you point me in the right direction I would be happy to help if this is planned. Thanks!