Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tocsoft opened this issue Jun 22, 2018 · 0 comments

Comments

@tocsoft
Copy link
Member

tocsoft commented Jun 22, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant