GlyphLine implements Serializable { public void substituteOneToMany(OpenTypeFontTableReader tableReader, int[] substGlyphIds) { int substCode = substGlyphIds[0]; Glyph oldGlyph = glyphs.get(idx); Glyph glyph = tableReader.getGlyph(substCode); glyphs.set(idx, glyph); if (substGlyphIds.length > 1) { List<Glyph> additionalGlyphs = new ArrayList<>(substGlyphIds.length - 1); for (int i = 1; i < substGlyphIds.length; ++i) { substCode = substGlyphIds[i]; glyph = tableReader.getGlyph(substCode); additionalGlyphs.add(glyph); } addAllGlyphs(idx + 1, additionalGlyphs); if (null != actualText) { if (null == actualText.get(idx)) { actualText.set(idx, new ActualText(oldGlyph.getUnicodeString())); } for (int i = 0; i < additionalGlyphs.size(); i++) { this.actualText.set(idx + 1 + i, actualText.get(idx)); } } idx += substGlyphIds.length - 1; end += substGlyphIds.length - 1; } } GlyphLine();  GlyphLine(List<Glyph> glyphs);  GlyphLine(List<Glyph> glyphs, int start, int end); protected  GlyphLine(List<Glyph> glyphs, List<ActualText> actualText, int start, int end);  GlyphLine(GlyphLine other);  GlyphLine(GlyphLine other, int start, int end); String toUnicodeString(int start, int end); @Override String toString(); GlyphLine copy(int left, int right); Glyph get(int index); Glyph set(int index, Glyph glyph); void add(Glyph glyph); void add(int index, Glyph glyph); void setGlyphs(List<Glyph> replacementGlyphs); void add(GlyphLine other); void replaceContent(GlyphLine other); int size(); void substituteManyToOne(OpenTypeFontTableReader tableReader, int lookupFlag, int rightPartLen, int substitutionGlyphIndex); void substituteOneToOne(OpenTypeFontTableReader tableReader, int substitutionGlyphIndex); void substituteOneToMany(OpenTypeFontTableReader tableReader, int[] substGlyphIds); GlyphLine filter(IGlyphLineFilter filter); void setActualText(int left, int right, String text); Iterator<GlyphLinePart> iterator(); @Override boolean equals(Object obj); @Override int hashCode(); public int start; public int end; public int idx; }
@Test public void testActualTextForSubstitutedGlyphProcessingInSubstituteOneToMany03() throws IOException { byte[] ttf = StreamUtil.inputStreamToArray(new FileInputStream("./src/test/resources/com/itextpdf/io/font/otf/FreeSans.ttf")); TrueTypeFont font = new TrueTypeFont(ttf); GlyphLine line = new GlyphLine(constructGlyphListFromString("A", font)); line.substituteOneToMany(font.getGsubTable(), new int[] {39, 40}); Assert.assertNull(line.actualText); }