Woff font loading broken in latest beta - Could not read compressed data!
See original GitHub issuePrerequisites
- I have written a descriptive issue title
- I have verified that I am running the latest version of Fonts
- I have verified if the problem exist in both
DEBUG
andRELEASE
mode - I have searched open and closed issues to ensure it has not already been reported
Description
I have code that loads WOFF fonts from files on disk, then renders them to a bitmap. This worked fine in version 1. I updated to the latest Nuget betas, and now I get an error when calling TextMeasurer.Measure
with a reference to the font. The error is Could not read compressed data! Expected bytes: 35776, bytes read: 14988
which implies to me that the font loading has failed. Full stack is:
at SixLabors.Fonts.Tables.Woff.WoffTableHeader.CreateReader(Stream stream) at SixLabors.Fonts.FontReader.GetReaderAtTablePosition(String tableName) at SixLabors.Fonts.Tables.TrueType.Glyphs.GlyphTable.Load(FontReader reader) at SixLabors.Fonts.Tables.TableLoader.Load[TTable](FontReader reader) at SixLabors.Fonts.FontReader.TryGetTable[TTableType]() at SixLabors.Fonts.FontReader.GetTable[TTableType]() at SixLabors.Fonts.StreamFontMetrics.LoadTrueTypeFont(FontReader reader) at SixLabors.Fonts.StreamFontMetrics.LoadFont(String path, Int64 offset) at System.Lazy
1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy
1.CreateValue()
at SixLabors.Fonts.FileFontMetrics.TryGetGlyphId(CodePoint codePoint, Nullable1 nextCodePoint, UInt16& glyphId, Boolean& skipNextCodePoint) at SixLabors.Fonts.TextLayout.DoFontRun(ReadOnlySpan
1 text, Int32 start, IReadOnlyList1 textRuns, Int32& textRunIndex, Int32& codePointIndex, Int32& bidiRunIndex, Boolean isFallbackRun, Font font, BidiRun[] bidiRuns, Dictionary
2 bidiMap, GlyphSubstitutionCollection substitutions, GlyphPositioningCollection positionings)
at SixLabors.Fonts.TextLayout.ProcessText(ReadOnlySpan1 text, TextOptions options) at SixLabors.Fonts.TextMeasurer.Measure(String text, TextOptions options) at MultiRender.RenderGraphic.RenderSplits(List
1 items, String outputFile) in C:\src\bvcs-obs-controller\RenderText\MultiRender\RenderGraphic.cs:line 105`
Steps to Reproduce
This probably depends on a specific woff font file, I can’t upload for general access, but can supply to someone working on this. The code is quite simple so nothing special, but could supply that too if needed.
System Configuration
- Fonts version: 1.0.0-beta18
- Other Six Labors packages and versions: ImageSharp 2.1.3, ImageSharp.Drawing 1.0.0-beta15
- Environment (Operating system, version and so on): Windows 10
- .NET Framework version: .Net 6
- Additional information:
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
@brianpopow The font is in the sample project - fully self contained as the code loads it from the assembly-relative directory.
The “old” version works fine built with .Net5 and then linked into the code which runs on Windows and Linux. The new one I’ve only tried on Windows as it doesn’t work…
Closing via #297