--- old/modules/javafx.graphics/src/main/java/com/sun/javafx/font/coretext/CTGlyphLayout.java 2018-03-06 10:47:28.000000000 +0530 +++ new/modules/javafx.graphics/src/main/java/com/sun/javafx/font/coretext/CTGlyphLayout.java 2018-03-06 10:47:28.000000000 +0530 @@ -118,7 +118,7 @@ if (slot != -1) { glyphStart += OS.CTRunGetGlyphs(runRef, slot << 24, glyphStart, glyphs); } else { - glyphStart += OS.CTRunGetGlyphCount(runRef); + glyphStart += OS.CTRunGetGlyphs(runRef, 0, glyphStart, glyphs); } if (size > 0) { posStart += OS.CTRunGetPositions(runRef, posStart, positions); --- old/modules/javafx.graphics/src/main/native-font/coretext.c 2018-03-06 10:47:29.000000000 +0530 +++ new/modules/javafx.graphics/src/main/native-font/coretext.c 2018-03-06 10:47:29.000000000 +0530 @@ -634,11 +634,27 @@ { CTRunRef run = (CTRunRef)runRef; const CGGlyph * glyphs = CTRunGetGlyphsPtr(run); + CFIndex count = CTRunGetGlyphCount(run); + if(count == 0) { + return 0; + } + + CGGlyph* tempGlyphs = NULL; + if(!glyphs) + { + tempGlyphs = (CGGlyph*) malloc(count * sizeof(CGGlyph)); + if(!tempGlyphs) { + return 0; + } + + CTRunGetGlyphs(run, CFRangeMake(0 ,0), tempGlyphs); + glyphs = tempGlyphs; + } + int i = 0; if (glyphs) { jint* buffer = (*env)->GetPrimitiveArrayCritical(env, bufferRef, NULL); if (buffer) { - CFIndex count = CTRunGetGlyphCount(run); while(i < count) { buffer[start + i] = slotMask | (glyphs[i] & 0xFFFF); i++; @@ -646,6 +662,10 @@ (*env)->ReleasePrimitiveArrayCritical(env, bufferRef, buffer, 0); } } + + if(tempGlyphs) { + free(tempGlyphs); + } return i; }