C#C
C#3y ago
Petr

❔ Unable to change font in VS 2019

Hello, i have persisting problem in my c# project made in VS 2019. I made a custom class that is supposed to change font to any font available to my console:(FontChangerClass file added as an attachment). But it doesn't work. I use additional code to check for errors that is based on the FontManager class (attachment) and that looks like this:

static void Main(string[] args)
        {


            bool success = FontManager.SetFont("MS Gothic", 16, 12);

            if (success)
            {
                Console.WriteLine("Font successfully set.");
            }
            else
            {
                Console.WriteLine("Failed to set font.");
            }
            Thread.Sleep(2500);
            FontManager.PrintStdHandles();
            Thread.Sleep(3000);

My handles are standard -> Input = 8, Output = 12, Error = 16. But even if i enter all the information correctly, it still doesn't change the font and returns an Error: 87.

My default console font is Consolas, 16 and i'm trying to change it to MS Gothic, 16. Only temporarily, otherwise i would do it through console properties setting.

And i am aware that font changing is resolved much better in VS 2022, but i am unable install 2022 because it throws an installation error about NET 4.8 package while downloading. Thanks for taking the time to check out my code,
Petr
Was this page helpful?