-
-
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.
Merge pull request #141 from SixLabors/js/fix-140
Use bit masking to limit the glyph id to prevent an off by on error
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
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,29 @@ | ||
using SixLabors.Fonts.Tables.General.CMap; | ||
using Xunit; | ||
using static SixLabors.Fonts.Tables.General.CMap.Format4SubTable; | ||
|
||
namespace SixLabors.Fonts.Tests.Issues | ||
{ | ||
public class Issues_104 | ||
{ | ||
[Fact] | ||
public void Format4SubTableWithSegmentsHasOffByOneWhenOverflowing() | ||
{ | ||
var tbl = new Format4SubTable(0, WellKnownIds.PlatformIDs.Windows, 0, new[] { | ||
new Segment(0, | ||
ushort.MaxValue, // end | ||
ushort.MinValue, // start of range | ||
(short)(short.MaxValue), //delta | ||
0 // zero to force correctly tested codepath | ||
) | ||
}, null); | ||
|
||
const int delta = short.MaxValue + 2; // extra 2 to handle the difference between ushort and short when offsettings | ||
|
||
const int codePoint = delta + 5; | ||
Assert.True(tbl.TryGetGlyphId(codePoint, out ushort gid)); | ||
|
||
Assert.Equal(5, gid); | ||
} | ||
} | ||
} |