Index Out Of Range error from recent update

Posted by: brian on 10 July 2024, 7:57 pm EST

    • Post Options:
    • Link

    Posted 10 July 2024, 7:57 pm EST

    What was once working, now throws a “Index was outside the bounds of the array” for certain fonts.

    I’m sure these fonts aren’t perfect, because users upload the fonts. But it was working, and now it throws an error.

    If I change the font, it appears to work properly, but this is the stack trace when the error is thrown:

       at GrapeCity.Documents.Q.amp.y()
       at GrapeCity.Documents.Q.amp.i(Int32 a)
       at GrapeCity.Documents.Q.amp.e(b a, Int32 b, Boolean c, Boolean d)
       at GrapeCity.Documents.Imaging.BitmapRenderer.aw(FontTables a, Int32 b, amp c)
       at GrapeCity.Documents.Imaging.BitmapRenderer.an(GlyphRun a, amp b, FontTables c, Single d, Single e, Single f, Int32 g)
       at GrapeCity.Documents.Imaging.BitmapRenderer.ai(TextLayout a, Single b, TextLine c, Single d, Single e, RectangleF f, List`1 g, List`1 h)
       at GrapeCity.Documents.Imaging.BitmapRenderer.DrawTextLayout(TextLayout layout, Single x, Single y)
       at GrapeCity.Documents.Imaging.GcBitmapGraphics.InternalDrawTextLayout(TextLayout layout, PointF location)
       at GrapeCity.Documents.Drawing.GcGraphics.DrawTextLayout(TextLayout layout, PointF location)

  • Posted 11 July 2024, 5:06 am EST

    Hi,

    We are unable to replicate this issue at our end. Could you please provide more information?

    1. Version of DsImaging library.
    2. In which operation you are getting this error? While opening Image, saving image, etc.
    3. Provide the Fonts which causing this error.
    4. Provide a stripped .Net sample replicating this issue. So we can investigate this issue and assist you better.

    Regards,

    Nitin

  • Posted 13 August 2024, 8:20 pm EST

    1. I’m using DS.Documents.Imaging (7.1.4)
    2. The exception happens at g.DrawTextLayout();
    3. Attached the font
    var grapeText = new TextFormat {
        FontSize = 120,
        ForeColor = Color.White,
        FontStyle = GrapeCity.Documents.Text.FontStyle.Regular,
        FontBold = false,
        FontItalic = false,
        Underline = false,
        UseTypoMetrics = true,
        FontSizeInGraphicUnits = true,
        Font = GrapeCity.Documents.Text.Font.FromArray(request.FontBytes)
    };
    
    var size = getFontSize(request.Text, grapeText);
    
    using var bmp = new GcBitmap((int)size.Width, (int)size.Height, false);
    bmp.SetDpi(96);
    
    using var g = bmp.CreateGraphics(Color.Black);
    
    var tl = g.CreateTextLayout();
    tl.TrimmingGranularity = TrimmingGranularity.Character;
    tl.WrapMode = WrapMode.WordWrap;
    
    tl.Append(request.Text, grapeText);
    
    g.DrawTextLayout(tl, new PointF(0, 0))

    This worked in an older version of your library, when it was GrapeCity, but we’re updating our project to .NET Core and now are forced to use the latest versions.

    Gentona.zip

  • Posted 13 August 2024, 10:29 pm EST

    Hi,

    Thanks for the information. We have replicated this issue at our end. This seems like a bug in the latest versions.

    We have escalated this to the development team. Will get back to you once we have any updates from them.[Internal Tracking Id - DOC-6470]

    Regards,

    Nitin

  • Posted 20 August 2024, 4:54 pm EST

    I saw that an update came out today (DS.Documents.Imaging 7.2).

    I’m not sure if that was intended to fix the bug because the documentation only says “New Features and Improvements”…but it did not.

    Looking forward to the fix, and if I can make another request. I’d love to see a list of the new features and improvements for each update. Depending on the feature or update, there’s an opportunity for us to offer new functionality to our clients, making your component more valuable to us (just a thought).

    https://developer.mescius.com/document-solutions/dot-net-imaging-api/docs/online/Version7.2.0.html

  • Posted 21 August 2024, 1:21 am EST

    Hi,

    As per the development team, this issue will be addressed in the upcoming build 7.2.1 version. However, there is a workaround to fix this issue. You can set Font.EnableHinting = false for the TextFormat.

    Please refer the attached working sample: ImageDemo.zip

    Regards,

    Nitin

  • Posted 3 September 2024, 8:23 pm EST

    It appears to be working with the latest update.

    THANK YOU!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels