Hello,
I am encountering an issue while using PDFSharp 6.0.0-preview-2 library. Specifically, I am facing difficulties when trying to create an instance of XFont using the constructor new XFont("anyfont", anysize). The error message I receive is "No appropriate font found for family name '...'". This problem occurs consistently regardless of the font I attempt to use.
I have made sure that the fonts I'm trying to use are installed on my system. However, I'm still unable to create an XFont instance with the desired font.
I would appreciate any guidance or suggestions to resolve this issue. Has anyone else experienced a similar problem with XFont in PDFSharp 6.0.0-preview-2? Are there any known workarounds or solutions for this font-related error?
Thank you in advance for your help!
this is my test code
Code:
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
class Program
{
static void Main(string[] args)
{
PdfDocument doc = new PdfDocument();
PdfPage page = doc.AddPage();
XSize size = PageSizeConverter.ToSize(PageSize.A4);
page.Width = size.Width;
page.Height = size.Height;
using XGraphics gx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Tahoma", 15); // this line error
gx.DrawString("test", font, XBrushes.Black, 10, 10);
doc.Save("test.pdf");
doc.Close();
}
}