Skip to content

DynamicFontTableProvider is not Send + Sync #126

@PanieriLorenzo

Description

@PanieriLorenzo

DynamicFontTableProvider is not Send + Sync despite all current implementations of FontTableProvider being Send + Sync. This limits the user of the crate as Font<DynamicFontTableProvider> is also not Send + Sync so it can't easily be used in multi-threaded applications, without an unsafe impl. Because it is not Send, it cannot be made Sync with a Mutex either.

Suggested Fix

This is the current implementation:

pub struct DynamicFontTableProvider<'a> {
    sfnt_version: u32,
    provider: Box<dyn FontTableProvider + 'a>,
}

And this is my suggested fix:

pub struct DynamicFontTableProvider<'a> {
    sfnt_version: u32,
    provider: Box<dyn FontTableProvider + Send + Sync + 'a>,
}

Potential Downsides

Perhaps in the future there could be a FontTableProvider that isn't Send + Sync, in which case the DynamicFontTableProvider can't be used. Perhaps functions returning DynamicFontTableProvider, like FontData::table_provider could instead return a Send + Sync wrapper.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions