Closed RenderMichael closed 12 months ago
For reference, this is what error looks like for me on Windows
System.IO.EndOfStreamException: End of stream reached with 27424 byte left to read.
at SixLabors.Fonts.BigEndianBinaryReader.ReadInternal(Byte[] data, Int32 size)
at SixLabors.Fonts.BigEndianBinaryReader.ReadString(Int32 bytesToRead, Encoding encoding)
at SixLabors.Fonts.Utilities.StringLoader.LoadValue(BigEndianBinaryReader reader)
at SixLabors.Fonts.Tables.General.Name.NameTable.Load(BigEndianBinaryReader reader)
at SixLabors.Fonts.Tables.General.Name.NameTable.Load(FontReader fontReader)
at SixLabors.Fonts.Tables.TableLoader.Load[TTable](FontReader reader)
at SixLabors.Fonts.FontReader.TryGetTable[TTableType]()
at SixLabors.Fonts.FontReader.GetTable[TTableType]()
at SixLabors.Fonts.FontDescription.LoadDescription(FontReader reader)
at SixLabors.Fonts.FontDescription.LoadDescription(String path)
at PdfSharpCore.Utils.FontResolver.FontFileInfo.Load(String path)
at PdfSharpCore.Utils.FontResolver.SetupFontsFiles(String[] sSupportedFonts)
System.IO.EndOfStreamException: End of stream reached with 27424 byte left to read.
at SixLabors.Fonts.BigEndianBinaryReader.ReadInternal(Byte[] data, Int32 size)
at SixLabors.Fonts.BigEndianBinaryReader.ReadString(Int32 bytesToRead, Encoding encoding)
at SixLabors.Fonts.Utilities.StringLoader.LoadValue(BigEndianBinaryReader reader)
at SixLabors.Fonts.Tables.General.Name.NameTable.Load(BigEndianBinaryReader reader)
at SixLabors.Fonts.Tables.General.Name.NameTable.Load(FontReader fontReader)
at SixLabors.Fonts.Tables.TableLoader.Load[TTable](FontReader reader)
at SixLabors.Fonts.FontReader.TryGetTable[TTableType]()
at SixLabors.Fonts.FontReader.GetTable[TTableType]()
at SixLabors.Fonts.FontDescription.LoadDescription(FontReader reader)
at SixLabors.Fonts.FontDescription.LoadDescription(String path)
at PdfSharpCore.Utils.FontResolver.FontFileInfo.Load(String path)
at PdfSharpCore.Utils.FontResolver.SetupFontsFiles(String[] sSupportedFonts)
System.IO.EndOfStreamException: End of stream reached with 27424 byte left to read.
at SixLabors.Fonts.BigEndianBinaryReader.ReadInternal(Byte[] data, Int32 size)
at SixLabors.Fonts.BigEndianBinaryReader.ReadString(Int32 bytesToRead, Encoding encoding)
at SixLabors.Fonts.Utilities.StringLoader.LoadValue(BigEndianBinaryReader reader)
at SixLabors.Fonts.Tables.General.Name.NameTable.Load(BigEndianBinaryReader reader)
at SixLabors.Fonts.Tables.General.Name.NameTable.Load(FontReader fontReader)
at SixLabors.Fonts.Tables.TableLoader.Load[TTable](FontReader reader)
at SixLabors.Fonts.FontReader.TryGetTable[TTableType]()
at SixLabors.Fonts.FontReader.GetTable[TTableType]()
at SixLabors.Fonts.FontDescription.LoadDescription(FontReader reader)
at SixLabors.Fonts.FontDescription.LoadDescription(String path)
at PdfSharpCore.Utils.FontResolver.FontFileInfo.Load(String path)
at PdfSharpCore.Utils.FontResolver.SetupFontsFiles(String[] sSupportedFonts)
System.IO.EndOfStreamException: End of stream reached with 27424 byte left to read.
at SixLabors.Fonts.BigEndianBinaryReader.ReadInternal(Byte[] data, Int32 size)
at SixLabors.Fonts.BigEndianBinaryReader.ReadString(Int32 bytesToRead, Encoding encoding)
at SixLabors.Fonts.Utilities.StringLoader.LoadValue(BigEndianBinaryReader reader)
at SixLabors.Fonts.Tables.General.Name.NameTable.Load(BigEndianBinaryReader reader)
at SixLabors.Fonts.Tables.General.Name.NameTable.Load(FontReader fontReader)
at SixLabors.Fonts.Tables.TableLoader.Load[TTable](FontReader reader)
at SixLabors.Fonts.FontReader.TryGetTable[TTableType]()
at SixLabors.Fonts.FontReader.GetTable[TTableType]()
at SixLabors.Fonts.FontDescription.LoadDescription(FontReader reader)
at SixLabors.Fonts.FontDescription.LoadDescription(String path)
at PdfSharpCore.Utils.FontResolver.FontFileInfo.Load(String path)
at PdfSharpCore.Utils.FontResolver.SetupFontsFiles(String[] sSupportedFonts)
I can submit a PR with a fix if we come to a conclusion about one.
Whenever I try to use a font,
Console.Error
gets filled up with irrelevant error messages about fonts failing to load. This is because whenever the font resolver is accessed, all supported fonts are loaded and, when some of them fail, they log to errorhttps://github.com/ststeiger/PdfSharpCore/blob/2d31ef51b9e931dee9a4d293c59f20399f8c7705/PdfSharpCore/Utils/FontResolver.cs#L115-L130
This is unfortunate, as it clogs up Console.Error for me. I know PdfSharpCore isn't necessarily one-for-one, but PdfSharp for framework doesn't do this and this is the only thing hampering our migration. Is there anything that can be done?
Note this only happens on windows for me, not Ubuntu The following is a test to check for this behavior (note fonts should not be accessed before this test otherwise it doesn't work)