Get web server installed font names
GetInstalledFontList.aspx
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Text" %>
<!DOCTYPE html>
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
if(!this.IsPostBack)
{
InstalledFontCollection fontList = new InstalledFontCollection();
foreach(FontFamily family in fontList.Families)
{
ListBox1.Items.Add(family.Name);
}
}
}
protected void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Label1.Font.Name = ListBox1.SelectedItem.Text;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>How to get web server installed font collection in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">Get Installed Font List</h2>
<asp:Label
ID="Label1"
runat="server"
Font-Bold="true"
Font-Size="Larger"
Text="Hi Jones!"
ForeColor="Crimson"
>
</asp:Label>
<br /><br />
<asp:ListBox
ID="ListBox1"
runat="server"
BackColor="SeaGreen"
ForeColor="FloralWhite"
AutoPostBack="true"
OnSelectedIndexChanged="ListBox1_SelectedIndexChanged"
>
</asp:ListBox>
</div>
</form>
</body>
</html>


