GposLookupType1 extends OpenTableLookup { @Override public boolean transformOne(GlyphLine line) { if (line.idx >= line.end) { return false; } if (openReader.isSkip(line.get(line.idx).getCode(), lookupFlag)) { line.idx++; return false; } int glyphCode = line.get(line.idx).getCode(); boolean positionApplied = false; GposValueRecord valueRecord = valueRecordMap.get(glyphCode); if (valueRecord != null) { Glyph newGlyph = new Glyph(line.get(line.idx)); newGlyph.xAdvance += (short)valueRecord.XAdvance; newGlyph.yAdvance += (short)valueRecord.YAdvance; line.set(line.idx, newGlyph); positionApplied = true; } line.idx++; return positionApplied; } GposLookupType1(OpenTypeFontTableReader openReader, int lookupFlag, int[] subTableLocations); @Override boolean transformOne(GlyphLine line);  }
@Test public void verifyXAdvanceIsApplied() throws IOException { TrueTypeFont fontProgram = (TrueTypeFont) FontProgramFactory.createFont(RESOURCE_FOLDER + "NotoSansMyanmar-Regular.ttf"); GlyphPositioningTableReader gposTableReader = fontProgram.getGposTable(); GposLookupType1 lookup = (GposLookupType1) gposTableReader.getLookupTable(29); List<Glyph> glyphs = Arrays.asList(new Glyph(fontProgram.getGlyphByCode(174)), new Glyph(fontProgram.getGlyphByCode(5))); GlyphLine gl = new GlyphLine(glyphs); gl.idx = 0; Assert.assertEquals(0, gl.get(0).getXAdvance()); Assert.assertTrue(lookup.transformOne(gl)); Assert.assertEquals(219, gl.get(0).getXAdvance()); }
@Test public void verifyPositionIsNotAppliedForIrrelevantGlyph() throws IOException { TrueTypeFont fontProgram = (TrueTypeFont) FontProgramFactory.createFont(RESOURCE_FOLDER + "NotoSansMyanmar-Regular.ttf"); GlyphPositioningTableReader gposTableReader = fontProgram.getGposTable(); GposLookupType1 lookup = (GposLookupType1) gposTableReader.getLookupTable(29); List<Glyph> glyphs = Arrays.asList(new Glyph(fontProgram.getGlyphByCode(5)), new Glyph(fontProgram.getGlyphByCode(174))); GlyphLine gl = new GlyphLine(glyphs); gl.idx = 0; Assert.assertEquals(0, gl.get(0).getXAdvance()); Assert.assertFalse(lookup.transformOne(gl)); Assert.assertEquals(0, gl.get(0).getXAdvance()); }