-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure we never add empty text lines
- Loading branch information
1 parent
3bf24e4
commit 83d24b7
Showing
2 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
#if OS_WINDOWS | ||
using System.Numerics; | ||
|
||
namespace SixLabors.Fonts.Tests.Issues; | ||
|
||
public class Issues_383 | ||
{ | ||
[Fact] | ||
public void CanBreakLinesWithShortWrappingLength() | ||
{ | ||
FontFamily fontFamily = SystemFonts.Get("Yu Gothic"); | ||
Font font = fontFamily.CreateFont(20.0F); | ||
|
||
TextOptions textOption = new(font) | ||
{ | ||
WrappingLength = 10.0F, | ||
WordBreaking = WordBreaking.BreakAll | ||
}; | ||
|
||
// OK | ||
TextRenderer.RenderTextTo(new DummyGlyphRenderer(), "i", textOption); | ||
|
||
// OK | ||
TextRenderer.RenderTextTo(new DummyGlyphRenderer(), "v", textOption); | ||
|
||
// raise ArgumentOutOfRangeException | ||
TextRenderer.RenderTextTo(new DummyGlyphRenderer(), "a", textOption); | ||
|
||
textOption.WrappingLength = 9.0F; | ||
|
||
// OK | ||
TextRenderer.RenderTextTo(new DummyGlyphRenderer(), "i", textOption); | ||
|
||
// raise ArgumentOutOfRangeException | ||
TextRenderer.RenderTextTo(new DummyGlyphRenderer(), "v", textOption); | ||
|
||
// OK | ||
TextRenderer.RenderTextTo(new DummyGlyphRenderer(), "i\r\nv", textOption); | ||
|
||
// raise ArgumentOutOfRangeException | ||
TextRenderer.RenderTextTo(new DummyGlyphRenderer(), "v\r\ni", textOption); | ||
} | ||
} | ||
|
||
internal class DummyGlyphRenderer : IGlyphRenderer | ||
{ | ||
public void BeginFigure() | ||
{ | ||
} | ||
|
||
public bool BeginGlyph(in FontRectangle bounds, in GlyphRendererParameters parameters) => true; | ||
|
||
public void BeginText(in FontRectangle bounds) | ||
{ | ||
} | ||
|
||
public void CubicBezierTo(Vector2 secondControlPoint, Vector2 thirdControlPoint, Vector2 point) | ||
{ | ||
} | ||
|
||
public TextDecorations EnabledDecorations() => TextDecorations.None; | ||
|
||
public void EndFigure() | ||
{ | ||
} | ||
|
||
public void EndGlyph() | ||
{ | ||
} | ||
|
||
public void EndText() | ||
{ | ||
} | ||
|
||
public void LineTo(Vector2 point) | ||
{ | ||
} | ||
|
||
public void MoveTo(Vector2 point) | ||
{ | ||
} | ||
|
||
public void QuadraticBezierTo(Vector2 secondControlPoint, Vector2 point) | ||
{ | ||
} | ||
|
||
public void SetDecoration(TextDecorations textDecorations, Vector2 start, Vector2 end, float thickness) | ||
{ | ||
} | ||
} | ||
#endif |