PDFsharp & MigraDoc Foundation http://forum.pdfsharp.de/ |
|
Macos font exception http://forum.pdfsharp.de/viewtopic.php?f=2&t=4616 |
Page 1 of 1 |
Author: | gravy [ Sat Jun 29, 2024 3:56 pm ] |
Post subject: | Macos font exception |
Hi, I'm currently developing on a m1 mac and have created a console application that targets .net 8 and have added PDFsharp 6.1.0 pacakage I have added a snippet to from the sample code repo Code: var document = new PdfDocument(); document.Info.Title = "Created with PDFsharp"; document.Info.Subject = "Just a simple Hello-World program."; var page = document.AddPage(); var gfx = XGraphics.FromPdfPage(page); var width = page.Width.Point; var height = page.Height.Point; gfx.DrawLine(XPens.Red, 0, 0, width, height); gfx.DrawLine(XPens.Red, width, 0, 0, height); var r = width / 5; gfx.DrawEllipse(new XPen(XColors.Red, 1.5), XBrushes.White, new XRect(width / 2 - r, height / 2 - r, 2 * r, 2 * r)); var font = new XFont("Times New Roman", 20, XFontStyleEx.BoldItalic); gfx.DrawString("Hello, PDFsharp!", font, XBrushes.Black, new XRect(0, 0, page.Width.Point, page.Height.Point), XStringFormats.Center); var filename = PdfFileUtility.GetTempPdfFullFileName("samples/HelloWorldSample"); document.Save(filename); I am getting the following exception when the code attempts to create the font. From the docs the font should work on platforms other than windows. Quote: Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object. 2024-06-29T15:45:08.650162924Z at PdfSharp.Fonts.OpenType.OpenTypeFontFace.CetOrCreateFrom(XFontSource fontSource) 2024-06-29T15:45:08.650168799Z at PdfSharp.Drawing.XGlyphTypeface..ctor(String key, XFontFamily fontFamily, XFontSource fontSource, XStyleSimulations styleSimulations) 2024-06-29T15:45:08.650170299Z at PdfSharp.Drawing.XGlyphTypeface.GetOrCreateFrom(String familyName, FontResolvingOptions fontResolvingOptions) 2024-06-29T15:45:08.650171424Z at PdfSharp.Drawing.XFont.Initialize() 2024-06-29T15:45:08.650172466Z at PdfSharp.Drawing.XFont..ctor(String familyName, Double emSize, XFontStyleEx style, XPdfFontOptions pdfOptions) 2024-06-29T15:45:08.650173466Z at PdfSharp.Drawing.XFont..ctor(String familyName, Double emSize, XFontStyleEx style) Can someone point me in the right direction? Thanks |
Author: | TH-Soft [ Sat Jun 29, 2024 9:01 pm ] |
Post subject: | Re: Macos font exception |
gravy wrote: From the docs the font should work on platforms other than windows. From docs, this font should work under Windows and Linux, but not under MacOS. Write a FontResolver that loads the font for use on Mac. |
Author: | gravy [ Sat Jun 29, 2024 9:15 pm ] |
Post subject: | Re: Macos font exception |
Thank you for clarifying. Keep up the good work team! |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |