public void RenderArabicCharacters_WithIsolatedForm_Works(string testStr, int expectedGlyphIndex) { // arrange Font arabicFont = new FontCollection().Add(TestFonts.ArabicFontFile).CreateFont(8); var renderer = new ColorGlyphRenderer(); // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(arabicFont)); // assert GlyphRendererParameters glyphKey = Assert.Single(renderer.GlyphKeys); Assert.Equal(expectedGlyphIndex, glyphKey.GlyphIndex); }
public void SingleAdjustmentPositioning_Format1_Works() { // arrange string fontFile = TestFonts.GposLookupType1Format1; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); var renderer = new ColorGlyphRenderer(); string testStr = "\u0012\u0014"; // XPlacement should be adjusted by minus 200 for both glyphs. int[] expectedGlyphIndices = { 20, 22 }; FontRectangle[] expectedFontRectangles = { new(275, 2011, 825, 719), new(1622, 2010, 978, 704), };
public void SingleSubstitution_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubTestFontFile1).CreateFont(12); var renderer = new ColorGlyphRenderer(); string testStr = "A"; int expectedGlyphIndex = 38; // we expect A to be mapped to B. // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); // assert GlyphRendererParameters glyphKey = Assert.Single(renderer.GlyphKeys); Assert.Equal(expectedGlyphIndex, glyphKey.GlyphIndex); }
public void ContextualFractions_WithSlash_Works() { // arrange Font font = new FontCollection().Add(TestFonts.RobotoRegular).CreateFont(12); var renderer = new ColorGlyphRenderer(); string testStr = "9/2"; int[] expectedGlyphIndices = { 580, 404, 453 }; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); // assert Assert.Equal(expectedGlyphIndices.Length, renderer.GlyphKeys.Count); for (int i = 0; i < expectedGlyphIndices.Length; i++) { Assert.Equal(expectedGlyphIndices[i], renderer.GlyphKeys[i].GlyphIndex); } }
public void ReverseChainingContextualSingleSubstitution_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubTestFontFile2).CreateFont(12); var renderer = new ColorGlyphRenderer(); string testStr = "X89"; // X89 -> XYZ int[] expectedGlyphIndices = { 57, 58, 59 }; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); // assert Assert.Equal(expectedGlyphIndices.Length, renderer.GlyphKeys.Count); for (int i = 0; i < expectedGlyphIndices.Length; i++) { Assert.Equal(expectedGlyphIndices[i], renderer.GlyphKeys[i].GlyphIndex); } }
public void ChainedContextsSubstitution_Format3_WithCursiveScript_Works() { // arrange Font font = new FontCollection().Add(TestFonts.FormalScript).CreateFont(12); var renderer = new ColorGlyphRenderer(); string testStr = "ba"; // Characters following b should have a special form and should be replaced. int[] expectedGlyphIndices = { 69, 102 }; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); // assert Assert.Equal(expectedGlyphIndices.Length, renderer.GlyphKeys.Count); for (int i = 0; i < expectedGlyphIndices.Length; i++) { Assert.Equal(expectedGlyphIndices[i], renderer.GlyphKeys[i].GlyphIndex); } }
public void ChainedContextsSubstitution_Format3_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubTestFontFile2).CreateFont(12); var renderer = new ColorGlyphRenderer(); string testStr = "x=y"; // This should be replaced with "x>y". int[] expectedGlyphIndices = { 89, 31, 90 }; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); // assert Assert.Equal(expectedGlyphIndices.Length, renderer.GlyphKeys.Count); for (int i = 0; i < expectedGlyphIndices.Length; i++) { Assert.Equal(expectedGlyphIndices[i], renderer.GlyphKeys[i].GlyphIndex); } }
public void ChainedContextsSubstitution_Format2_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubLookupType6Format2).CreateFont(12); var renderer = new ColorGlyphRenderer(); string testStr = "\u0014\u0015\u0016\u0017"; // "20212223" -> "20216423" int[] expectedGlyphIndices = { 22, 23, 64, 25 }; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); // assert Assert.Equal(expectedGlyphIndices.Length, renderer.GlyphKeys.Count); for (int i = 0; i < expectedGlyphIndices.Length; i++) { Assert.Equal(expectedGlyphIndices[i], renderer.GlyphKeys[i].GlyphIndex); } }
public void ContextualSubstitution_Format3_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubLookupType5Format3).CreateFont(12); var renderer = new ColorGlyphRenderer(); string testStr = "\u0041\u0042\u0043\u0044"; // "65666768" -> "657678" int[] expectedGlyphIndices = { 67, 78, 80 }; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); // assert Assert.Equal(expectedGlyphIndices.Length, renderer.GlyphKeys.Count); for (int i = 0; i < expectedGlyphIndices.Length; i++) { Assert.Equal(expectedGlyphIndices[i], renderer.GlyphKeys[i].GlyphIndex); } }