I'm trying to use a custom font with HtmlFragment in Aspose.pdf for .NET, but I'm not able to get it to work. I'm using the FontRepository.OpenFont function to load the font from a file, but it doesn't seem to be applied to the text in the HtmlFragment.
Here's my code in C#:
var _dataDir = @"C:\Users\akash.choubey\";
Document doc = new Document();
Page page = doc.Pages.Add();
var fontPath = _dataDir + "astmensh.otf";
HtmlFragment hf = new HtmlFragment("<p>this is text</p>");
hf.TextState = new TextState();
hf.TextState.Font = FontRepository.OpenFont(fontPath);
page.Paragraphs.Add(hf);
doc.Save(_dataDir + "output.pdf");
I've verified that the font file exists at the specified path, and I've also tried using a built-in font such as Times New Roman instead of a custom font using FontRepository.FindFont and that works fine.
Is there something I'm missing in order to use a custom font with HtmlFragment in Aspose.pdf?