Skip to content

Commit

Permalink
Derive Clone for FontContext (linebender#161)
Browse files Browse the repository at this point in the history
This is useful because cloning a `FontContext` is currently the only way
to get a second `FontContext` without reloading system fonts (which is
quite expensive). Using this approach to avoid reloading system fonts in
Blitz's WPT test runner which has a Blitz `Document` (and thus a
`FontContext`) per test brings our total runtime down by about 40%.

It is possible to work around this by manually cloning the `FontContext`
(it's two public fields impl `Clone`).

We will probably want a better solution for reusing loaded system fonts
at some point.
  • Loading branch information
nicoburns authored Nov 7, 2024
1 parent 77b02ce commit 1a1be17
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion parley/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use fontique::SourceCache;
/// A font database/cache (wrapper around a Fontique [`Collection`] and [`SourceCache`]).
///
/// This type is designed to be a global resource with only one per-application (or per-thread).
#[derive(Default)]
#[derive(Default, Clone)]
pub struct FontContext {
pub collection: Collection,
#[cfg(feature = "std")]
Expand Down

0 comments on commit 1a1be17

Please sign in to comment.