Skip to content

OverflowException when loading font collection #534

@natehitze

Description

@natehitze

Prerequisites

  • 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 and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

Fonts version

3.0.0

Other Six Labors packages and versions

SixLabors.ImageSharp.Drawing 3.0.0

Environment (Operating system, version and so on)

Linux (PopOS 22.04)

.NET Framework version

.net 9

Description

I'm working on updating my ImageSharp dependency from 3 to 4. This font file loaded fine in 3 but throws System.OverflowException: Arithmetic operation resulted in an overflow. in 4.

Steps to Reproduce

Repro code:

using SixLabors.Fonts;

var fontFile = typeof(Program).Assembly.GetManifestResourceStream("ImageSharpRepro.HomeVideo-Regular.ttf");
if (fontFile is null) throw new Exception("Could not find font file");
var fontCollection = new FontCollection();
fontCollection.Add(fontFile); // Throws here

Here's a zip that contains the font: home_video.zip

And the stack trace:

Unhandled exception. System.OverflowException: Arithmetic operation resulted in an overflow.
   at SixLabors.Fonts.BigEndianBinaryReader.ReadBytes(Int32 count)
   at SixLabors.Fonts.Tables.General.Svg.SvgTable.Load(BigEndianBinaryReader reader)
   at SixLabors.Fonts.Tables.General.Svg.SvgTable.Load(FontReader fontReader)
   at SixLabors.Fonts.Tables.TableLoader.Load[TTable](FontReader reader)
   at SixLabors.Fonts.FontReader.TryGetTable[TTableType]()
   at SixLabors.Fonts.StreamFontMetrics.LoadTrueTypeFont(FontReader reader)
   at SixLabors.Fonts.StreamFontMetrics.LoadFont(FontReader reader)
   at SixLabors.Fonts.StreamFontMetrics.LoadFont(Stream stream)
   at SixLabors.Fonts.FontCollection.AddImpl(Stream stream, CultureInfo culture, FontDescription& description)
   at SixLabors.Fonts.FontCollection.Add(Stream stream, FontDescription& description)
   at SixLabors.Fonts.FontCollection.Add(Stream stream)

Images

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions