-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes for better caching and sharing parsed fonts #76
Conversation
Thanks for tackling this. I'm aware it is a source of frustration for some allsorts users and I am keen to come up with a solution. I pulled these changes into the Prince code base (where allsorts originated) and attempted to update things to get it building.
The removal of the type parameter poses an issue for us. In our code we have other methods on the concrete type that is passed into One workaround would be to add an Considering the two commits you made, are both actually required to achieve the goal of making caching of fonts easier? It seems like it might be enough just to take the second commit as it stops |
Thanks, I think that for my usecase the second commit should be enough as I do not combine font types. I will try. Anyway, if the second commit is fine, it could be merged alone and it would definitely help as it is. |
Ok, great. Let me know how you go and if it works I'll pull in the second commit. |
Hello, I confirm that for the caching purposes the second commit is enough, it works for me. |
Thanks so much for checking that @martin-kolarik. I've done some experimenting to see if the same thing can be achieved as your second commit without changing the existing API. I think I've managed to do that in fee74f2. If you have time, would you be able to try that version? |
Hello @wezm, nice work, I checked your branch, and it works. I appreciate your help, I could not add |
Fantastic, appreciate you checking that for me. I've published Allsorts 0.11.0 with that change. Are you happy for me to close this PR now? |
Sure, thanks! |
In principle I made two changes:
Font<T: FontTableProvider>
) with&dyn FontTableProvider
, what allows caching Font instances of different types (OTF, WOFF...).ReadScope
font source from Font itself. Font then can be cached only with keeping single self-referenced data (ReadScope
).I removed generic
T
fromFont
without breaking API compatibility, with the help ofimpl Into<Box<dyn FontTableProvider + 'a>>
, which is rather complex. Definitely this could be arranged better if API was changed (what I did not want).It should also help with #52 and with some discussed points in #72.