While we appreciate comments from our users, please follow our posting guidelines. Have you tried the Cyotek Forums for support from Cyotek and the community?

Styling with Markdown is supported

Original Comment

Gravatar

Jason

# Reply

Okay... so is the following "wrong"?...

///

/// Performs a case-insensitive lookup against the installed Window's fonts /// /// /// public static bool IsFontInstalled(string fontName) { if (string.IsNullOrWhiteSpace(fontName)) return false;

        bool isFontInstalled = false;

        using (InstalledFontCollection installedFontCollection = new InstalledFontCollection())
        {
            foreach (FontFamily fontFamily in installedFontCollection.Families)
            {
                if (0 == string.Compare(fontFamily.Name, fontName, ignoreCase: true))
                {
                    isFontInstalled = true;
                    break;
                }
            }
        }

        return isFontInstalled;
    }
}
Gravatar

Richard Moss

# Reply

Hello,

No, there's nothing wrong with your approach. The only real difference is you are just checking that any style in a given font exists whereas I am checking that a specific style exists. But either way, your code is fine.

Regards; Richard Moss