-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #419 from SixLabors/js/fix-417
Use empty anchor as fallback when parsing mark anchors
- Loading branch information
Showing
4 changed files
with
60 additions
and
2 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
Binary file not shown.
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,38 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
namespace SixLabors.Fonts.Tests.Issues; | ||
|
||
public class Issues_417 | ||
{ | ||
[Fact] | ||
public void DoesNotThrow_InvalidAnchor() | ||
{ | ||
FontFamily family = new FontCollection().Add(TestFonts.NotoSansRegular); | ||
family.TryGetMetrics(FontStyle.Regular, out FontMetrics metrics); | ||
|
||
Font font = family.CreateFont(metrics?.UnitsPerEm ?? 1000); | ||
|
||
TextOptions options = new(font); | ||
|
||
// References values generated using. | ||
// https://www.corvelsoftware.co.uk/crowbar/ | ||
TextMeasurer.TryMeasureCharacterAdvances("Text", options, out ReadOnlySpan<GlyphBounds> advances); | ||
|
||
Assert.Equal(4, advances.Length); | ||
Assert.Equal(486, advances[0].Bounds.Width); | ||
Assert.Equal(544, advances[1].Bounds.Width); | ||
Assert.Equal(529, advances[2].Bounds.Width); | ||
Assert.Equal(361, advances[3].Bounds.Width); | ||
|
||
GlyphRenderer renderer = new(); | ||
TextRenderer.RenderTextTo(renderer, "Text", new TextOptions(font)); | ||
|
||
int[] expectedGlyphIndices = { 55, 72, 91, 87 }; | ||
Assert.Equal(expectedGlyphIndices.Length, renderer.GlyphKeys.Count); | ||
for (int i = 0; i < expectedGlyphIndices.Length; i++) | ||
{ | ||
Assert.Equal(expectedGlyphIndices[i], renderer.GlyphKeys[i].GlyphId); | ||
} | ||
} | ||
} |
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