Closed rmacfadyen closed 4 years ago
Why did you close this? Did you find any downsides or encountered problems?
There's several existing forks that already do this.
And even with .netstandard support via system.drawing.common you don't get cross platform support because how the library gets a hold of a font's raw byte level representation.
On Windows an XFont is essentially created by selecting a font into a device context and then getting the raw font data from the context via a GDI call.
That approach won't work on Linux, even with the System.Drawing.Common. And it doesn't work on Azure because of file system permission issues causing the initial select into a device context to fail.
However on linux (heck even Azure) it might be better to restrict fonts to be only from a private font collection and no system fonts at all. If that were so then a XFont could just use the .TTF file's bytes in the private font collection directly (instead of going the DC/GetFontData).
So... given others have done the same thing and given that this isn't as full a solution as I'd first thought... meh... might as well close it.
We use our own fork on Azure with a private font collection containing Roboto an Liberation fonts. But we only need PdfSharp.dll, no MigraDoc or other things.
I can look for the changes if someone is interessted.
I took a run at getting PdfSharp to support .NET Standard 2.0 and it appears to have worked.
The trick is that System.Drawing.Common provides enough functionality that combined with the GDI build the library works.
I had to make a few additional changes:
You can see the changes on my fork on the branch Original or look here: https://github.com/empira/PDFsharp/compare/master...rmacfadyen:Original?expand=1
My testing of this has been minimal (I can successfully produce an invoice pdf using MigraDoc that embeds fonts and uses a .PNG image).
I'm not sure what downsides there are to this other than the minimum .NET framework would be 4.6.1 (currently it supports 3.5).
Is this something you folks would be interested in?