Skip to content

Conversation

expenses
Copy link
Contributor

Turns out that fontique Collections have interior mutability and can be cloned, so no more FONTDB.with_borrow_mut(...) stuff. I commented out where fontdb was used, inserted a bunch of todo!()s and got to implementing it in fontique instead. Should be mostly good to merge though with the possible exception of error handling.

When registering a font, fontique doesn't give you an error on failure but does return a list of all the fonts added. We could potentially change the registration code to error when no fonts were added: https://docs.rs/fontique/latest/fontique/struct.Collection.html#method.register_fonts.

Copy link
Member

@tronical tronical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. Took me a while to trace, but I agree with your choice of shared: true for the Fontique Collection. That makes our code a lot simpler.

Thanks for taking these incremental steps :)

pub static COLLECTION: once_cell::sync::OnceCell<Collection> = once_cell::sync::OnceCell::new();

pub fn get_collection() -> Collection {
COLLECTION.get_or_init(Default::default).clone()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this clone() not copies the cache?
I think you may want to return a reference, maybe to a Mutex.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@expenses expenses requested a review from ogoffart September 12, 2025 14:23
@expenses expenses merged commit aee9609 into slint-ui:feature/fontique Sep 15, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants