Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# how to Defining a Font Fallback Sequence in Code

Tags:

c#

winforms

fonts

I try Defining a Font Fallback Sequence in Code , i refer at here

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        FontFamily f = new FontFamily("Comic Sans MS, Verdana");
    }
}

but i have i error: "Additional information: Font 'Comic Sans MS, Verdana' cannot be found."

how to Defining a Font Fallback Sequence in Code.

like image 894
user3435791 Avatar asked Sep 16 '25 05:09

user3435791


1 Answers

Because "Comic Sans MS, Verdana" is no font name. You can define a font name array.And you can add names to this array.

string[] fontName = new string[] { "Comic Sans MS", "Verdana" };
FontFamily f = new FontFamily(fontName[0]);
like image 116
Tuba Avatar answered Sep 17 '25 19:09

Tuba