changeset 11025:15770e65250e 11+23

8209191: [macOS] Distorted complex text rendering Reviewed-by: kcr, prr
author arajkumar
date Tue, 14 Aug 2018 12:38:53 +0530
parents e174f0b0fb51
children f93715d69784 5305622797c5
files modules/javafx.graphics/src/main/native-font/coretext.c
diffstat 1 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.graphics/src/main/native-font/coretext.c	Fri Aug 10 15:02:36 2018 -0700
+++ b/modules/javafx.graphics/src/main/native-font/coretext.c	Tue Aug 14 12:38:53 2018 +0530
@@ -673,11 +673,26 @@
 {
     CTRunRef run = (CTRunRef)runRef;
     const CGPoint* positions = CTRunGetPositionsPtr(run);
+    CFIndex count = CTRunGetGlyphCount(run);
+    if (count == 0) {
+        return 0;
+    }
+
+    CGPoint* tempPositions = NULL;
+    if (!positions) {
+        tempPositions = (CGPoint*) malloc(count * sizeof(CGPoint));
+        if (!tempPositions) {
+            return 0;
+        }
+
+        CTRunGetPositions(run, CFRangeMake(0, 0), tempPositions);
+        positions = tempPositions;
+    }
+
     int j = 0;
     if (positions) {
         jfloat* buffer = (*env)->GetPrimitiveArrayCritical(env, bufferRef, NULL);
         if (buffer) {
-            CFIndex count = CTRunGetGlyphCount(run);
             int i = 0;
             while (i < count) {
                 CGPoint pos = positions[i++];
@@ -687,6 +702,10 @@
             (*env)->ReleasePrimitiveArrayCritical(env, bufferRef, buffer, 0);
         }
     }
+
+    if (tempPositions) {
+        free(tempPositions);
+    }
     return j;
 }