GposLookupType4 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; } boolean changed = false; GlyphIndexer gi = null; for (MarkToBase mb : marksbases) { OtfMarkRecord omr = mb.marks.get(line.get(line.idx).getCode()); if (omr == null) continue; if (gi == null) { gi = new GlyphIndexer(); gi.idx = line.idx; gi.line = line; while (true) { gi.previousGlyph(openReader, lookupFlag); if (gi.glyph == null) break; if (openReader.getGlyphClass(gi.glyph.getCode()) != OtfClass.GLYPH_MARK) { break; } } if (gi.glyph == null) break; } GposAnchor[] gpas = mb.bases.get(gi.glyph.getCode()); if (gpas == null) continue; int markClass = omr.markClass; int xPlacement = 0; int yPlacement = 0; GposAnchor baseAnchor = gpas[markClass]; if (baseAnchor != null) { xPlacement = baseAnchor.XCoordinate; yPlacement = baseAnchor.YCoordinate; } GposAnchor markAnchor = omr.anchor; if (markAnchor != null) { xPlacement -= markAnchor.XCoordinate; yPlacement -= markAnchor.YCoordinate; } line.set(line.idx, new Glyph(line.get(line.idx), xPlacement, yPlacement, 0, 0, gi.idx - line.idx)); changed = true; break; } line.idx++; return changed; } GposLookupType4(OpenTypeFontTableReader openReader, int lookupFlag, int[] subTableLocations); @Override boolean transformOne(GlyphLine line);  }
@Test public void verifyMarkToBaseAttachment() throws IOException { TrueTypeFont fontProgram = (TrueTypeFont)FontProgramFactory.createFont(RESOURCE_FOLDER + "Padauk-Regular.ttf"); GlyphPositioningTableReader gposTableReader = fontProgram.getGposTable(); GposLookupType4 lookup = (GposLookupType4) gposTableReader.getLookupTable(192); List<Glyph> glyphs = Arrays.asList(new Glyph(fontProgram.getGlyphByCode(163)), new Glyph(fontProgram.getGlyphByCode(207)), new Glyph(fontProgram.getGlyphByCode(213))); GlyphLine gl = new GlyphLine(glyphs); gl.idx = 2; Assert.assertEquals(0, gl.get(2).getXPlacement()); Assert.assertEquals(0, gl.get(2).getAnchorDelta()); lookup.transformOne(gl); Assert.assertEquals(364, gl.get(2).getXPlacement()); Assert.assertEquals(-2, gl.get(2).getAnchorDelta()); }