@font-face fonts not being loaded when converting to pdf

So i have a html file which contains custom fonts declared inside a <style></style> tag

<!DOCTYPE html>
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>Something</title>

    <style >
        @font-face {
            font-family: 'myfont';
            src: url('myfont.eot') format('embedded-opentype'), url('myfont.woff') format('woff'), url('myfont.ttf') format('truetype');
        }

  
       .. other styles
    </style>
</head>
<body style="font-family: myfont,Calibri, 'Trebuchet MS', sans-serif;">

   
   
  Content ...




</body>
</html>

The fonts myfont (.ttf and so on) are located in an another directory. When i try to read the html and convert it to a pdf the fonts are not loaded and embedded in the pdf.

  string fontPath = "C:\\path\\to\\fonts\\"; // In the fonts folder the file are located ( myfont.eot ..)
  var document = new DocumentModel();
  var paragraph = new Paragraph(document);
  var section = new Section(document);
  var htmlLoadOptions = new HtmlLoadOptions
  {
      HtmlType = HtmlType.Html,
      Encoding = Encoding.UTF8,
      InheritCharacterFormat = true,
      BaseAddress = fontPath
  };
  section.Content.LoadText(_htmlString, htmlLoadOptions);

  document.Sections.Add(section);
  String outputPath = "Output.pdf";
  document.Save(outputPath);

What am I doing wrong? Do I need to still use FontSettings.FontsBaseDirectory, which I tried but it didn’t work.

Hi,

Unfortunately, GemBox.Document currently doesn’t support @font-face.
We have an internal support ticket for this feature request and I’ve added your report as well to increase its priority. But at the moment I cannot say exactly when it will be available.

For now, you will need to use FontSettings.FontsBaseDirectory.
However, you mentioned that using it didn’t work for you. Can you confirm that the “myfont.ttf” file is placed inside this folder?
If it is, please create a small Visual Studio project that reproduces your issue so we can investigate it.

Regards,
Mario

Suppose i have (myfont.oet/ttf/woff) located in a font folder. Is this the correct configuration?

FontSettings.FontsBaseDirectory = 'font'; // Or the path to the directory
var document = new DocumentModel();
document.DefaultCharacterFormat.FontName = "myfont";
....

Or am I missing something?

Nevermind. The HTML file was still using the font face font and thus not being overriden by Gembox.