Skip to content

Fire an event during font discovery to allow for wiring in font redirects and lazy loading  #75

Open
@tocsoft

Description

@tocsoft

add an event to IFontCollection that will be called before a font instance is returned that can be used to switch the font instance in the collection with an alternative one.

Additionally should be able to register a new font file during this callback and allow the newly installed file to be returned in place of discovered instance.

public class FontDiscoveryEventArgs : EventArgs
{
    public string FontName { get; }
    public FontStyle FontStyle { get; }
    public bool FontFamilyInstalled { get; }
    public bool FontInstalled { get; }

    public bool UseFont(string path){
       //  .. calls font collection install and then sets the font name and style to the installed font returned
    }

    public bool UseFont(Stream stream){
       //  .. calls font collection install and then sets the font name and style to the installed font returned
    }

    public bool UseFont(string fontName, FontStyle style){
        // tries to find the font in the collection if exists then it replaces the final 
        // returned font with the newly named one and returns true.
        //if doesn't exist then no change and returns false
    }
}

if after the event is called we still don't have a matching font then we will follow the same logic we have now and ultimately throw as required.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions