Hi all,
I am upgrading to PDFSharp-GDI 6.1 and would like to use custom font resolvers.
My app produces an in-app preview with the GDI functionality and then exports a PDF with the same content.
I'm using a custom font resolver, which works perfectly on the PDF export:
Code:
class Fontresolver : IFontResolver
{
public byte[] GetFont(string faceName)
{
if (faceName == "Oswald")
return File.ReadAllBytes(GlobalSettings.ResourceDirectory + "oswald-regular.ttf");
else
return null;
}
public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic)
{
if (familyName == "Oswald")
return new("Oswald");
return PlatformFontResolver.ResolveTypeface(familyName, isBold, isItalic);
}
}
However, in the preview (drawing on a bitmap) I am seeing the following behavior: When Oswald is installed, the Oswald font is used for preview. When Oswald is not installed, I'm getting the error: "This font cannot be used by GDI+".
The documentation says:
Quote:
In the GDI and WPF builds, the selection of the requested typeface is delegated directly to GDI+ (System.Drawing) or WPF (System.Windows), respectively. This is the easiest case. The underlying Windows code selects the appropriate type face.
In the Core build of PDFsharp the concept of font resolvers is used.
If I understand correctly, this means that font resolvers cannot be used when drawing to a bitmap. Is that correct?