AGS.Editor.Utilities.FindExistingFont C# (CSharp) Метод

FindExistingFont() публичный статический Метод

Iterates given array of font family names and return the first FontFamily object that is installed in the system. If none was found, returns generic Sans-Serif system font.
public static FindExistingFont ( string fontNames ) : FontFamily
fontNames string
Результат System.Drawing.FontFamily
        public static FontFamily FindExistingFont(string[] fontNames)
        {
            FontFamily fontfam = null;
            foreach (string name in fontNames)
            {
                try
                {
                    fontfam = new FontFamily(name);
                }
                catch (System.ArgumentException)
                {
                    continue;
                }
                if (fontfam.Name == name)
                    return fontfam;
            }
            return new FontFamily(GenericFontFamilies.SansSerif);
        }

Usage Example

Пример #1
0
            static Design()
            {
                FontFamily fontfam = Utilities.FindExistingFont(Design.FontNames);

                FontName = fontfam.Name;
            }