--- old/src/java.desktop/share/classes/sun/font/FontRunIterator.java 2018-05-31 15:12:55.000000000 -0700 +++ new/src/java.desktop/share/classes/sun/font/FontRunIterator.java 2018-05-31 15:12:55.000000000 -0700 @@ -119,8 +119,40 @@ int ch = nextCodePoint(lim); int sl = mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK; + int secondPosition = pos; + int preChar = ch; + boolean consumed = false; slot = sl >>> 24; - while ((ch = nextCodePoint(lim)) != DONE && (mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK) == sl); + while ((ch = nextCodePoint(lim)) != DONE ) { + if (CharToGlyphMapper.isVariationSelector(ch) + && CharToGlyphMapper.isBaseChar(preChar) + && consumed == false) { + consumed = true; + int[] chars = {preChar, ch}; + int[] glyphs = {0, 0}; + mapper.charsToGlyphs(2, chars, glyphs); + int vsSize = 1; + if (ch >= 0x10000) { + vsSize = 2; + } + if (secondPosition + vsSize == pos) { // Real slot + sl = glyphs[0] & CompositeGlyphMapper.SLOTMASK; + slot = sl >>> 24; + } + if ((glyphs[0] & CompositeGlyphMapper.SLOTMASK) != sl) { + pushback(ch); + pushback(preChar); + return true; + } + } else { + consumed = false; + if ((mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK) + != sl) { + break; + } + } + preChar = ch; + } pushback(ch); return true;