I recently had to make a dropdownlist populated with fonts. Luckily, .NET allows you to use the installed fonts very easy.

First, add a drowdownlist to your ASP.NET page like this:

<asp:DropDownList runat="Server" id="ddlFonts" />

Then call this method to do the actual databinding of the fonts:

private void BindFonts()
{
   System.Drawing.Text.InstalledFontCollection col = new System.Drawing.Text.InstalledFontCollection();
   foreach (System.Drawing.FontFamily family in col.Families)
   {
      ddlFonts.Items.Add(family.Name);
   }
}

That's all there is to it. Be aware that the fonts are the ones installed on the server hosting your web page.

Comments

What did you think?

Used only for your avatar and replies; never published.