I want to install font, but my code is not working.How can I install a new font on user's PC programmatically using C# Windows Form Application so that I can use this font in the report included in this application ?
This my code :
namespace Font
{
public partial class Form1 : Form
{
[DllImport("gdi32.dll", EntryPoint = "AddFontResourceW", SetLastError = true)]
public static extern int AddFontResource([In][MarshalAs(UnmanagedType.LPWStr)]
string lpFileName);
public void InstallFont()
{
var result = AddFontResource(@"D:\Temp\BAseman.TTF");
var error = Marshal.GetLastWin32Error();
}
public Form1()
{
InitializeComponent();
}
private void btnInstall_Click(object sender, EventArgs e)
{
InstallFont();
}
}
}