Using Embedded fonts in Asp.Net

396 Views Asked by At

I have a dropdown list where I am getting all the listed fonts in my system.And now when I load the web page and giving some text to a label and display it and when trying to change the text with the desired font name and it throws me an exception stating that the font dosen't support bold and some dosen't support Italic and So on.

So my question is how do I change according to the fontnames?If I chose for example the fontname "Aharoni" it dosent support bold then immediately it should pickup the default font for those cases.

Any help will be appreciated!

Here is how I am displaying the list of fonts on page load event:

   For Each f As System.Drawing.FontFamily In System.Drawing.FontFamily.Families
        DropDownFontList.Items.Add(f.Name)
    Next

Button1_Click event:

Label1.Font.Name = DropDownFontList.SelectedItem.Value
1

There are 1 best solutions below

0
On BEST ANSWER

you can find Font.FontFamily for the font and then calling FontFamily.IsStyleAvailable method you can find whether italic or bold is available or not.

myFontFamily.IsStyleAvailable(FontStyle.Italic)