Skip to content

Text rendering never end with some specific characters with fallback font #475

Description

@Socolin

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-alpha.0.4

Other Six Labors packages and versions

Drawing: 3.0.0-alpha.0.6 ImageSharp: 4.0.0-alpha.0.55

Environment (Operating system, version and so on)

Ubuntu 24.04

.NET Framework version

.net 9.0

Description

While doing some tests with font fallback, I got to this piece of text (see below) that is killing my computer (taking forever, using all the memory) when I try to render with ImageSharp, even if the font does not support those characters

Steps to Reproduce

Fonts available here: Fonts.zip

using SixLabors.Fonts;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

var fontCollection = new FontCollection();
fontCollection.AddSystemFonts();
fontCollection.Add("Fonts/NotoSans-Regular.ttf");
fontCollection.Add("Fonts/NotoSansSC-Regular.ttf");

using var img = new Image<Rgba32>(900, 150, Color.DimGray.ToPixel<Rgba32>());
img.Mutate(x => x
	.Fill(Color.White)
	.DrawText(new RichTextOptions(fontCollection.Get("Noto Sans").CreateFont(30, FontStyle.Regular))
		{
			FallbackFontFamilies =
			[
				fontCollection.Get("Noto Sans SC"),
			],
		},
		"වේගවත් දුඹුරු හිවලා කම්මැලි බල්ලා උඩින් පනී",
		Color.Black
	)
);
await img.SaveAsync("test.png");

Images

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions