public virtual void VerifyXAdvanceIsNotAppliedForUnsatisfiedContextualPositioning() { TrueTypeFont fontProgram = (TrueTypeFont)FontProgramFactory.CreateFont(RESOURCE_FOLDER + "NotoSansMyanmar-Regular.ttf" ); GlyphPositioningTableReader gposTableReader = fontProgram.GetGposTable(); GposLookupType7 lookup = (GposLookupType7)gposTableReader.GetLookupTable(28); IList <Glyph> glyphs = JavaUtil.ArraysAsList(fontProgram.GetGlyphByCode(1), fontProgram.GetGlyphByCode(174) , fontProgram.GetGlyphByCode(5), fontProgram.GetGlyphByCode(411)); GlyphLine gl = new GlyphLine(glyphs); NUnit.Framework.Assert.IsFalse(lookup.TransformLine(gl)); for (int i = 0; i < gl.Size(); i++) { NUnit.Framework.Assert.AreEqual(0, gl.Get(i).GetXAdvance()); NUnit.Framework.Assert.AreEqual(0, gl.Get(i).GetYAdvance()); } }
public virtual void VerifyDifferentXAdvanceIsAppliedSubFormat2() { TrueTypeFont fontProgram = (TrueTypeFont)FontProgramFactory.CreateFont(RESOURCE_FOLDER + "NotoSansMyanmar-Regular.ttf" ); GlyphPositioningTableReader gposTableReader = fontProgram.GetGposTable(); GposLookupType1 lookup = (GposLookupType1)gposTableReader.GetLookupTable(16); IList <Glyph> glyphs = JavaUtil.ArraysAsList(new Glyph(fontProgram.GetGlyphByCode(401)), new Glyph(fontProgram .GetGlyphByCode(5))); GlyphLine gl = new GlyphLine(glyphs); NUnit.Framework.Assert.AreEqual(0, gl.Get(0).GetXAdvance()); NUnit.Framework.Assert.IsTrue(lookup.TransformOne(gl)); NUnit.Framework.Assert.AreEqual(109, gl.Get(0).GetXAdvance()); // Subtable type 2 defines different GposValueRecords for different coverage glyphs glyphs = JavaUtil.ArraysAsList(new Glyph(fontProgram.GetGlyphByCode(508)), new Glyph(fontProgram.GetGlyphByCode (5))); gl = new GlyphLine(glyphs); NUnit.Framework.Assert.AreEqual(0, gl.Get(0).GetXAdvance()); NUnit.Framework.Assert.IsTrue(lookup.TransformOne(gl)); NUnit.Framework.Assert.AreEqual(158, gl.Get(0).GetXAdvance()); }
public virtual void VerifyPositionIsNotAppliedForIrrelevantGlyph() { TrueTypeFont fontProgram = (TrueTypeFont)FontProgramFactory.CreateFont(RESOURCE_FOLDER + "NotoSansMyanmar-Regular.ttf" ); GlyphPositioningTableReader gposTableReader = fontProgram.GetGposTable(); GposLookupType1 lookup = (GposLookupType1)gposTableReader.GetLookupTable(29); IList <Glyph> glyphs = JavaUtil.ArraysAsList(new Glyph(fontProgram.GetGlyphByCode(5)), new Glyph(fontProgram .GetGlyphByCode(174))); GlyphLine gl = new GlyphLine(glyphs); gl.idx = 0; NUnit.Framework.Assert.AreEqual(0, gl.Get(0).GetXAdvance()); NUnit.Framework.Assert.IsFalse(lookup.TransformOne(gl)); NUnit.Framework.Assert.AreEqual(0, gl.Get(0).GetXAdvance()); }
public virtual void VerifyMarkToBaseAttachment() { TrueTypeFont fontProgram = (TrueTypeFont)FontProgramFactory.CreateFont(RESOURCE_FOLDER + "KhmerOS.ttf"); GlyphPositioningTableReader gposTableReader = fontProgram.GetGposTable(); GposLookupType5 lookup = (GposLookupType5)gposTableReader.GetLookupTable(0); IList <Glyph> glyphs = JavaUtil.ArraysAsList(new Glyph(fontProgram.GetGlyphByCode(445)), new Glyph(fontProgram .GetGlyphByCode(394))); GlyphLine gl = new GlyphLine(glyphs); gl.idx = 1; lookup.TransformOne(gl); NUnit.Framework.Assert.AreEqual(2, gl.Size()); NUnit.Framework.Assert.AreEqual(445, gl.Get(0).GetCode()); NUnit.Framework.Assert.AreEqual(394, gl.Get(1).GetCode()); NUnit.Framework.Assert.AreEqual(-1, gl.Get(1).GetAnchorDelta()); NUnit.Framework.Assert.AreEqual(756, gl.Get(1).GetXPlacement()); }
public virtual void VerifyMarkToBaseAttachment() { TrueTypeFont fontProgram = (TrueTypeFont)FontProgramFactory.CreateFont(RESOURCE_FOLDER + "Padauk-Regular.ttf" ); GlyphPositioningTableReader gposTableReader = fontProgram.GetGposTable(); GposLookupType4 lookup = (GposLookupType4)gposTableReader.GetLookupTable(192); IList <Glyph> glyphs = JavaUtil.ArraysAsList(new Glyph(fontProgram.GetGlyphByCode(163)), new Glyph(fontProgram .GetGlyphByCode(207)), new Glyph(fontProgram.GetGlyphByCode(213))); GlyphLine gl = new GlyphLine(glyphs); gl.idx = 2; NUnit.Framework.Assert.AreEqual(0, gl.Get(2).GetXPlacement()); NUnit.Framework.Assert.AreEqual(0, gl.Get(2).GetAnchorDelta()); lookup.TransformOne(gl); NUnit.Framework.Assert.AreEqual(364, gl.Get(2).GetXPlacement()); NUnit.Framework.Assert.AreEqual(-2, gl.Get(2).GetAnchorDelta()); }
public virtual void TestSelectingCorrectAttachmentAlternative() { // TODO on completion of DEVSIX-3732 this test will probably have to be refactored // since we will have to emulate previous substitutions and populate the substitution info // to the glyph line so that mark is attached to the correct component of a ligature TrueTypeFont fontProgram = (TrueTypeFont)FontProgramFactory.CreateFont(RESOURCE_FOLDER + "NotoNaskhArabic-Regular.ttf" ); GlyphLine glyphLine = new GlyphLine(JavaUtil.ArraysAsList(fontProgram.GetGlyphByCode(513), fontProgram.GetGlyphByCode (75))); GlyphPositioningTableReader gposTableReader = fontProgram.GetGposTable(); GposLookupType5 lookup = (GposLookupType5)gposTableReader.GetLookupTable(3); glyphLine.idx = 1; lookup.TransformOne(glyphLine); NUnit.Framework.Assert.AreEqual(2, glyphLine.Size()); NUnit.Framework.Assert.AreEqual(513, glyphLine.Get(0).GetCode()); NUnit.Framework.Assert.AreEqual(75, glyphLine.Get(1).GetCode()); NUnit.Framework.Assert.AreEqual(-1, glyphLine.Get(1).GetAnchorDelta()); NUnit.Framework.Assert.AreEqual(-22, glyphLine.Get(1).GetXPlacement()); }
public virtual void TestThatNoTransformationsAppliedForNonRelevantGlyphs() { TrueTypeFont fontProgram = (TrueTypeFont)FontProgramFactory.CreateFont(RESOURCE_FOLDER + "NotoNaskhArabic-Regular.ttf" ); GlyphLine glyphLine = new GlyphLine(JavaUtil.ArraysAsList(fontProgram.GetGlyph('1'), fontProgram.GetGlyphByCode (75))); GlyphPositioningTableReader gposTableReader = fontProgram.GetGposTable(); GposLookupType5 lookup = (GposLookupType5)gposTableReader.GetLookupTable(3); glyphLine.idx = 1; lookup.TransformOne(glyphLine); NUnit.Framework.Assert.AreEqual(2, glyphLine.Size()); NUnit.Framework.Assert.AreEqual(1490, glyphLine.Get(0).GetCode()); NUnit.Framework.Assert.AreEqual(75, glyphLine.Get(1).GetCode()); NUnit.Framework.Assert.AreEqual(0, glyphLine.Get(1).GetAnchorDelta()); NUnit.Framework.Assert.AreEqual(0, glyphLine.Get(1).GetXPlacement()); }