Skip to content

Problem with wordwrap in some texts #522

@IshmaZX82

Description

@IshmaZX82

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.1.3

Other Six Labors packages and versions

ImageSharp 3.1.12, Drawing 2.1.7

Environment (Operating system, version and so on)

Win11

.NET Framework version

.Net 8

Description

There is a problem with wordwrap after a colon: the word is broken into parts, although it should not.
If the same text doesn't contain a colon, the word isn't broken into parts.

Steps to Reproduce

var sixFont = SystemFonts.CreateFont("Times New Roman", 25f);
var textOptions = new RichTextOptions(sixFont)
{
    WrappingLength = 300,
    WordBreaking = WordBreaking.BreakWord
};
var text1 = "số khung: RRKWCH1UM7XJ00693";
var text2 = "số khung RRKWCH1UM7XJ00693";

using var image = new Image<SixLabors.ImageSharp.PixelFormats.Rgba32>(400, 100);
image.Mutate(ctx =>
{
    ctx.Fill(Color.White);
    ctx.DrawLine(Color.Red, 2f, new PointF[] { new PointF(300, 0), new PointF(300, 100) });
    ctx.DrawText(textOptions, text1, SixLabors.ImageSharp.Color.Black);
    textOptions.Origin = new PointF(0, 50);
    ctx.DrawText(textOptions, text2, SixLabors.ImageSharp.Color.Black);
});
image.SaveAsPng(@"test.png");

This code outputs two lines of text.
Red line is a WrappingLength marker.
The second line has no colon, and the entire word is wrapped:

Images

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions