Specified font file was not found

I downloaded a google font(Allura-Regular.ttf) and im trying to fetch the file using Font Repository OpenFont() but it is throwing an error “Specified font file was not found”. Please help me to resolve this issue as early as possible.

Language: C#
Technology: .Net Framework

@Suhabavan

Can you please make sure that you are using 22.3 version of the API? We used below code snippet to test the scenario and could not reproduce the issue that you have mentioned. For your kind reference, an output PDF is also attached:

string fontFile = dataDir + "Allura-Regular.ttf";
// Load input PDF file
Document doc = new Document();
// Create text fragment with sample string
TextFragment textFragment = new TextFragment("Hello world");

if (fontFile != "")
{
 // Load the TrueType font into stream object
 using (FileStream fontStream = System.IO.File.OpenRead(fontFile))
 {
  // Set the font name for text string
  textFragment.TextState.Font = FontRepository.OpenFont(fontStream, FontTypes.TTF);
  // Specify the position for Text Fragment
  textFragment.Position = new Position(100, 600);
  var page = doc.Pages.Add();
  page.Paragraphs.Add(textFragment);
}

 dataDir = dataDir + "LoadingFontFromStream_out.pdf";
 // Save resulting PDF document
 doc.Save(dataDir);
}

LoadingFontFromStream_out.pdf (23.9 KB)

how to check the version of the API?

@Suhabavan

You can check the API version simply in Visual Studio by going into the properties of the referenced DLL. Also, you can check it in code like below:

Type.GetType("Aspose.Pdf.Document").Assembly.FullName

Thank you for the response. I have one more doubt please clarify, please check the below image, it is a screenshot of the pdf, on the first-page signature fields are coming as Allura font but on the second-page signature fields are coming as normal font, but in the code, I’m using Allura font style for the signature fields. The values in the Signature field are coming correctly on both the pages only the font style is different. Not sure why on the 2 pages alone Allura font is not working. Please help me to resolve this ASAP. If you need any further information please let me know.
image.png (46.0 KB)

@Suhabavan

We need to reproduce the same behavior in our environment in order to determine the cause of this issue. Could you please share the sample PDF along with the sample code snippet that can be used to reproduce this case? We will test the scenario in our environment and address it accordingly.