changeset 10870:8fbac224331c

8198354: [macOS] Corrupt Thai characters displayed in word wrapped label Reviewed-by: kcr, mbilla
author dkumar
date Mon, 12 Mar 2018 13:12:56 +0530
parents 6d279ecfacd1
children 69f6ef371e61
files modules/javafx.graphics/src/main/java/com/sun/javafx/font/coretext/CTGlyphLayout.java modules/javafx.graphics/src/main/native-font/coretext.c
diffstat 2 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.graphics/src/main/java/com/sun/javafx/font/coretext/CTGlyphLayout.java	Fri Mar 09 23:11:45 2018 +0100
+++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/font/coretext/CTGlyphLayout.java	Mon Mar 12 13:12:56 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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);
--- a/modules/javafx.graphics/src/main/native-font/coretext.c	Fri Mar 09 23:11:45 2018 +0100
+++ b/modules/javafx.graphics/src/main/native-font/coretext.c	Mon Mar 12 13:12:56 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -634,11 +634,26 @@
 {
     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 +661,10 @@
             (*env)->ReleasePrimitiveArrayCritical(env, bufferRef, buffer, 0);
         }
     }
+
+    if (tempGlyphs) {
+        free(tempGlyphs);
+    }
     return i;
 }