Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line wrapping issue with explicit newline #441

Open
4 tasks done
jez9999 opened this issue Jan 13, 2025 · 0 comments
Open
4 tasks done

Line wrapping issue with explicit newline #441

jez9999 opened this issue Jan 13, 2025 · 0 comments
Assignees
Labels

Comments

@jez9999
Copy link

jez9999 commented Jan 13, 2025

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

2.0.9

Other Six Labors packages and versions

SixLabors.ImageSharp 3.1.6, SixLabors.ImageSharp.Drawing 2.1.5

Environment (Operating system, version and so on)

Windows 10

.NET Framework version

.NET 9

Description

After fixes to line wrapping 2.0.8 and 2.0.9, I've noticed a regression in a particular test of mine (see steps to reproduce for the program). This works as expected with 2.0.7.

Steps to Reproduce

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

namespace TextRunTest;

internal class Program {
	static void Main(string[] args) {
		Console.WriteLine("Rendering test images...");
		test3();

		Console.WriteLine("Done.");
	}

	private static void test3() {
		var fontManager = new FontManager();

		Image imgTest1 = new Image<Rgba32>(1100, 500, Color.White);
		imgTest1.Mutate(x =>
			x.DrawText(
				new RichTextOptions(fontManager.GetFont("Arial", 80, FontStyle.Regular)) {
					Origin = new Vector2(50, 20),
					WrappingLength = 800,
				},
				"What connects the following: x",
				Color.Black
			)
		);
		imgTest1.SaveAsPng("c:/development/diff/testImg1.png");
		// ^ correct in 2.0.9

		Image imgTest2 = new Image<Rgba32>(1100, 500, Color.White);
		imgTest2.Mutate(x =>
			x.DrawText(
				new RichTextOptions(fontManager.GetFont("Arial", 80, FontStyle.Regular)) {
					Origin = new Vector2(50, 20),
					WrappingLength = 800,
				},
				"What connects the following:\nx",
				Color.Black
			)
		);
		imgTest2.SaveAsPng("c:/development/diff/testImg2.png");
		// ^ incorrect in 2.0.9; does not wrap "following:"
	}
}

Images

Correct behaviour in 2.0.7:
testImg2

Incorrect behaviour in 2.0.9:
testImg2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants