--- old/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc 2018-06-18 09:59:00.000000000 -0700 +++ new/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc 2018-06-18 09:58:59.000000000 -0700 @@ -48,10 +48,50 @@ JDKFontInfo *jdkFontInfo = (JDKFontInfo*)font_data; JNIEnv* env = jdkFontInfo->env; jobject font2D = jdkFontInfo->font2D; - hb_codepoint_t u = (variation_selector==0) ? unicode : variation_selector; + if (variation_selector == 0) { + *glyph = (hb_codepoint_t)env->CallIntMethod( + font2D, sunFontIDs.f2dCharToGlyphMID, unicode); + if (env->ExceptionOccurred()) + { + env->ExceptionClear(); + } + } else { + jintArray unicodes = NULL; + jintArray results = NULL; + jint vsPair[] = {(jint)unicode, + (jint)variation_selector}; - *glyph = (hb_codepoint_t) - env->CallIntMethod(font2D, sunFontIDs.f2dCharToGlyphMID, u); + *glyph = 0; + unicodes = env->NewIntArray(2); + if (unicodes == NULL) { + goto cleanup; + } + results = env->NewIntArray(2); + if (results == NULL) { + goto cleanup; + } + + env->SetIntArrayRegion(unicodes, 0, 2, vsPair); + env->CallVoidMethod(font2D, sunFontIDs.f2dCharsToGlyphsMID, 2, + unicodes, results); + if (env->ExceptionOccurred()) + { + goto cleanup; + } + env->GetIntArrayRegion(results, 0, 2, vsPair); + *glyph = vsPair[0]; +cleanup: + if (env->ExceptionOccurred()) + { + env->ExceptionClear(); + } + if (unicodes != NULL) { + env->DeleteLocalRef(unicodes); + } + if (results != NULL) { + env->DeleteLocalRef(results); + } + } if ((int)*glyph < 0) { *glyph = 0; }