Skip to content

Use better (longer) lifetime as possible for `Font`

Jeremy Soller requested to merge lo48576:use-better-lifetime into master

Created by: lo48576

Lifetime of a font object given by FontCollection::font_at is same as that of SharedBytes which FontCollection contains.

This change enables Font to exist without FontCollection. example:

let font = {
    let font_data = include_bytes!("Arial Unicode.ttf");
    let collection = FontCollection::from_bytes(font_data.to_vec());
    collection.font_at(0).unwrap()
};

Merge request reports