I want to use iTextSharp to write some text. I\'m using this method:
var font = BaseFont.CreateFont(BaseFont.TIMES_BOLD, BaseFont.WINANSI, BaseFont.EMBEDDED)
I ended up combining the 2 answers here into this method:
public static Font GetFont(string fontName, string filename)
{
if (!FontFactory.IsRegistered(fontName))
{
var fontPath = Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\" + filename;
FontFactory.Register(fontPath);
}
return FontFactory.GetFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
}
Which I then use in my code like so:
writer.DirectContent.SetFontAndSize(GetFont("Franklin Gothic Medium Cond", "FRAMDCN.TTF").BaseFont, 24f);
On Windows you can find out the font's file name from the font's property sheet:
I also found that you have to use the font's exact name on the Details tab: