Closed mj2015 closed 2 years ago
I've put together a simple sample - will remove once sorted. Open the VS project, Start it, and it will stop at a breakpoint where it is about to call TextMeasurer.Measure
- everything looks fine to me. Then F10 and it will fail.
Thanks for the info and sample.
Do you happen to know what Fonts version you had that worked previously and were you running it with .NET 6? There were changes with stream reading in .NET 6 that might have affected our ability to read zlib streams so it would help to narrow things down.
I still have the old project, which was in .Net 5. SixLabors.Fonts 1.0.0-beta15 SixLabors.ImageSharp 1.0.3 SixLabors.ImageSHarp.Drawing 1.0.0-beta13
I should say though that the library with my code that was .Net5 is used in a .Net 6 container without issue.
That's very likely the same issue as #1707 we had with ImageSharp. It's strange though that it does not happen in the container. Are you sure the container version of .Net matches exactly the host version.
I would like to double check with the font file. ~@mj2015 can you send me the file to~ (edit: removed email)
@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...
@mj2015 I see, thanks. I can reproduce it.
Ok there is now a PR to fix this #297.
@mj2015 I just wanted to double check: I cannot use the font file provided in a unit test, correct?
Sorry, the font is not mine to give out. There may be an internet version out there - not sure if this was one supplied by a client or from the internet!
Closing via #297
Prerequisites
DEBUG
andRELEASE
modeDescription
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 isCould 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