using Avalonia;
using Avalonia.Media;

namespace DodoSSH.Client.App;

internal static class Program
{
    /// <summary>
    /// Entry point.
    /// </summary>
    /// <remarks>
    /// <c>STAThread</c> is required, not decorative: WebView2 checks the apartment state and refuses
    /// to initialise on an MTA thread. Without it the terminal is simply blank on Windows.
    /// </remarks>
    [STAThread]
    public static void Main(string[] args) =>
        BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);

    /// <summary>Used by the designer as well as by <see cref="Main"/>.</summary>
    /// <remarks>
    /// <c>WithInterFont</c> registers Inter; it does not make it the default, and until this line the
    /// application shipped a font it then declined to use — falling back to Segoe UI on Windows and to
    /// whatever fontconfig offered on Linux. Almost nothing visible moves, because App.axaml sets
    /// <c>MonoFont</c> on essentially every control that draws text, but the fallback behind those is now
    /// a font that travels with the build rather than one the machine is assumed to have. The layout
    /// suite pins the same family, and has to: see HeadlessApp.
    /// </remarks>
    public static AppBuilder BuildAvaloniaApp() =>
        AppBuilder.Configure<DodoSshApp>()
            .UsePlatformDetect()
            .WithInterFont()
            .With(new FontManagerOptions { DefaultFamilyName = "avares://Avalonia.Fonts.Inter/Assets#Inter" })
            .LogToTrace();
}
