MigraDoc / PdfSharpCore - Requesting a fontface "New"

311 Views Asked by At
table.Rows[0].Cells[4].AddParagraph("0123456789ABCDEFGHIJKLMNOPQRSTUVWYXZ")
   .Format.Font.ApplyFont(new Font("barcode", 36));
...

var documentRenderer = new DocumentRenderer(_document);
documentRenderer.PrepareDocument(); //<--- crash here

It comes through my custom font resolver ResolveTypeface("barcode", false, false) and GetFont("barcode.ttf") as expected.

It then comes through with ResolveTypeface("New", false, false). I don't know where "New" is coming from.

If I change new Font("barcode", 36) to new Font("Arial", 36) all is well and it never askes for a fontface of "New". I've tried another font, just in case something was messed up there. I've looked through the MigraDoc / PdfSharpCore source but see no reference to a hardcoded "New" string.

1

There are 1 best solutions below

0
On

My best guess is that MigraDoc to PDF conversion looks up the FontFamily from the font that it used to resolve and then uses that font family (not the original one) when generating the PDF.

This means 2 things:

  • You better use the exact font family name that is in the font when resolving it.
  • You font needs to be correct / not corrupted. Somewhere it's grabbing "New" from the font I was using.