PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Error compiling since updating windows
http://forum.pdfsharp.com/viewtopic.php?f=2&t=4011
Page 1 of 1

Author:  iddgroup [ Thu Aug 29, 2019 11:27 pm ]
Post subject:  Error compiling since updating windows

So this morning, I had a windows update.

Right after the update, my program is just broken.

It crashes on loading a custom font. Here is the exact code.

Code:
   Dim options As XPdfFontOptions = New XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always)
   Dim privateFonts As New System.Drawing.Text.PrivateFontCollection()
   privateFonts.AddFontFile(MyApp.fontPath & "thefont.ttf")
   Dim MyCustomFont As XFont = New XFont(privateFonts.Families(0), 12, XFontStyle.Bold, options)


it crashes with (on the 4th line) with:
System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'

the addfontfile appears to not work. it comes back empty, where on a non upgraded machine it comes up valid.

Now Microsoft says you have to modify the app.config file. but I spent the entire day today messing with this and it just wont work. I literally have tried everything. I think its something else

https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/retargeting/4.5.2-4.7.2#privatefontcollectionaddfontfile-method-releases-font-resources


Does anyone have any ideas? I am totally lost.

Ive confirmed it works on a machine that is not upgraded, and is broken on any machine that is.

The .exe's that where compiled before today all work, so at least my existing user based isn't affected

Author:  Thomas Hoevel [ Tue Sep 03, 2019 9:15 am ]
Post subject:  Re: Error compiling since updating windows

The caption is "Error compiling", but it looks like you are getting a run-time error.

You are using PrivateFontCollection, not XPrivateFontCollection. If AddFontFile no longer works this may not make a difference though.

The recommended way to use custom fonts is the WPF build of PDFsharp and the IFontResolver interface. While using XPrivateFontCollection should still work it is not the recommended way any more.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/