changeset 10686:b90fb54db303 jdk-10+30

8176319: Mac: problems with Character Viewer Reviewed-by: prr, azvegint
author mhalder
date Tue, 31 Oct 2017 15:59:26 +0530
parents be53781b0299
children f5ad904ab819
files modules/javafx.graphics/src/main/java/com/sun/javafx/font/PrismFontFactory.java modules/javafx.graphics/src/main/native-glass/mac/GlassViewDelegate.m
diffstat 2 files changed, 35 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.graphics/src/main/java/com/sun/javafx/font/PrismFontFactory.java	Tue Oct 31 14:17:12 2017 +0530
+++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/font/PrismFontFactory.java	Tue Oct 31 15:59:26 2017 +0530
@@ -987,6 +987,10 @@
             fontRegInfo[0].add("/System/Library/Fonts/Apple Symbols.ttf");
             fontRegInfo[1].add("Apple Symbols");
 
+            // Add Apple Emoji Symbols to Mac OS X fallback list
+            fontRegInfo[0].add("/System/Library/Fonts/Apple Color Emoji.ttc");
+            fontRegInfo[1].add("Apple Color Emoji");
+
             // Add CJK Ext B supplementary characters.
             fontRegInfo[0].add("/System/Library/Fonts/STHeiti Light.ttf");
             fontRegInfo[1].add("Heiti SC Light");
--- a/modules/javafx.graphics/src/main/native-glass/mac/GlassViewDelegate.m	Tue Oct 31 14:17:12 2017 +0530
+++ b/modules/javafx.graphics/src/main/native-glass/mac/GlassViewDelegate.m	Tue Oct 31 15:59:26 2017 +0530
@@ -985,13 +985,41 @@
     return YES;
 }
 
-- (void)notifyInputMethod:(id) aString attr:(int)attr length:(int)length cursor:(int)cursor  selectedRange:(NSRange)selectionRange
+static jstring convertNSStringToJString(id aString, int length)
+{
+    GET_MAIN_JENV;
+    
+    jstring jStr;
+    if ([aString isKindOfClass:[NSAttributedString class]]) {
+        NSData *data = [[aString string] dataUsingEncoding:NSUTF16LittleEndianStringEncoding];
+        jchar *dataBytes = (jchar *)malloc(sizeof(jchar) * length);
+        if (dataBytes != NULL) {
+            [data getBytes:dataBytes length:length * 2];
+            jStr = (*env)->NewString(env, dataBytes, length);
+            free(dataBytes);
+        }
+    } else {
+        jStr = (*env)->NewStringUTF(env, [aString UTF8String]);
+    }
+    
+    GLASS_CHECK_EXCEPTION(env);
+
+    return jStr;
+}
+
+- (void)notifyInputMethod:(id) aString attr:(int)attr length:(int)length cursor:(int)cursor
+            selectedRange:(NSRange)selectionRange
 {
     if ([NSThread isMainThread] == YES)
     {
         GET_MAIN_JENV;
-        jstring jStr = (*env)->NewStringUTF(env, [aString UTF8String]);
-        (*env)->CallVoidMethod(env, self->jView, jViewNotifyInputMethodMac, jStr, attr, length, cursor, selectionRange.location, selectionRange.length);
+        
+        jstring jStr = convertNSStringToJString(aString, length);
+        if (jStr != NULL) {
+            (*env)->CallVoidMethod(env, self->jView, jViewNotifyInputMethodMac, jStr, attr,
+                                   length, cursor, selectionRange.location,
+                                   selectionRange.length);
+        }
         GLASS_CHECK_EXCEPTION(env);
     }
 }