cart: empty [ Login ]

Exception when bounds-checking DxfAttribute with trailing slash

1 
provegard
5/13/2022 9:50 AM
Hi! After upgrading to CadLib 6.0.0-rc6, we get an error when bounds-checking a DxfAttribute with a text with a trailing slash:
C# Code:
using WW.Cad.Drawing; using WW.Cad.Model; using WW.Cad.Model.Entities; const string license = "..."; WW.WWLicense.SetLicense(license); var model = new DxfModel(); var attr = new DxfAttribute(); attr.Style = model.DefaultTextStyle; attr.Text = "foobar/"; var bc = new BoundsCalculator(); bc.GetBounds(model, new[] { attr });
The error is: Unhandled exception. System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index') at System.Collections.Generic.List`1.get_Item(Int32 index) at SixLabors.Fonts.GlyphSubstitutionCollection.GetGlyphShapingData(Int32 index) at SixLabors.Fonts.Tables.AdvancedTypographic.Shapers.DefaultShaper.AssignFeatures(IGlyphShapingCollection collection, Int32 index, Int32 count) at SixLabors.Fonts.Tables.AdvancedTypographic.GSubTable.ApplySubstitution(FontMetrics fontMetrics, GlyphSubstitutionCollection collection, KerningMode kerningMode) at SixLabors.Fonts.StreamFontMetrics.ApplySubstitution(GlyphSubstitutionCollection collection, KerningMode kerningMode) at SixLabors.Fonts.TextLayout.DoFontRun(ReadOnlySpan`1 text, TextOptions options, FontMetrics fontMetrics, BidiRun[] bidiRuns, Dictionary`2 bidiMap, GlyphSubstitutionCollection substitutions, GlyphPositioningCollection positionings) at SixLabors.Fonts.TextLayout.ProcessText(ReadOnlySpan`1 text, TextOptions options) at SixLabors.Fonts.TextLayout.GenerateLayout(ReadOnlySpan`1 text, TextOptions options) at WW.Cad.Model.Text.?.?(String ?, IList`1 ?) at WW.Cad.Model.Text.?.?(String ?, IList`1 ?) at WW.Cad.Model.Text.?.?(String ?, IList`1 ?) at WW.Cad.Model.Text.?.get_?() at WW.Cad.Model.Text.?.?(Vector2D& ?, Double ?, Double ?, ? ?) at WW.Cad.Model.Text.?.?(Vector2D& ?, Double ?, Double ?, ? ?) at WW.Cad.Model.Text.?.?(DxfText ?, Color ?, Int16 ?, Matrix4D ?, Bounds2D ?, Vector2D& ?, Vector2D& ?, ? ?) at WW.Cad.Model.Entities.DxfText.?(IPathDrawer ?, Color ?, Int16 ?) at WW.Cad.Model.Entities.DxfText.DrawInternal(Wireframe context, IWireframeGraphicsFactory graphicsFactory) at WW.Cad.Model.Entities.DxfAttributeBase.DrawInternal(Wireframe context, IWireframeGraphicsFactory graphicsFactory) at WW.Cad.Drawing.BoundsCalculator.GetBounds(DxfModel model, IEnumerable`1 entities, Matrix4D modelTransform) at WW.Cad.Drawing.BoundsCalculator.GetBounds(DxfModel model, IEnumerable`1 entities) at Program.<Main>$(String[] args) in C:\kod\projects\cadlib-test\Program.cs:line 16 Best regards, Per
Wout
5/13/2022 10:07 AM
Hi, Yes, it's a known problem in the sixlabors.fonts library. I've requested a nuget release a week ago, and the response was there to be a release within a few days, but it hasn't happened yet. I'll ping them on Monday if it still hasn't been released yet. - Wout
provegard
5/13/2022 11:36 AM
Ok, thanks for the quick reply! I'll surround the text with \x200B (zero-width space) until the fix has been released. Per
Wout
5/18/2022 12:17 PM
There's a new CadLib 6.0 release available with a fix for this. - Wout
provegard
5/18/2022 2:10 PM
Thank you, it works like a charm! Per
1