using System;
using System.Drawing;

namespace Elfisa.UI.Helpers
{
    /// <summary>
    /// Segoe Fluent Icons with MDL2 fallback (WinUI design guidance).
    /// </summary>
    public static class FluentFonts
    {
        private static readonly Lazy<FontFamily> IconFamily = new Lazy<FontFamily>(ResolveIconFamily);

        public static Font CreateIconFont(float size, FontStyle style = FontStyle.Regular)
        {
            return new Font(IconFamily.Value, size, style, GraphicsUnit.Point);
        }

        private static FontFamily ResolveIconFamily()
        {
            if (FontFamilyExists("Segoe Fluent Icons"))
            {
                return new FontFamily("Segoe Fluent Icons");
            }

            return new FontFamily("Segoe MDL2 Assets");
        }

        private static bool FontFamilyExists(string familyName)
        {
            using (var font = new Font(familyName, 10f))
            {
                return string.Equals(font.FontFamily.Name, familyName, StringComparison.OrdinalIgnoreCase);
            }
        }
    }
}
