--- old/src/java.desktop/unix/native/common/awt/awt_Font.c 2019-05-18 14:50:34.000000000 -0700 +++ new/src/java.desktop/unix/native/common/awt/awt_Font.c 2019-05-18 14:50:33.000000000 -0700 @@ -35,7 +35,6 @@ #include "awt_Font.h" #include "java_awt_Dimension.h" -#include "multi_font.h" #include "Disposer.h" #endif /* !HEADLESS */ #include @@ -436,269 +435,6 @@ return 1; } -struct FontData * -awtJNI_GetFontData(JNIEnv * env, jobject font, char **errmsg) -{ - /* We are going to create at most 4 outstanding local refs in this - * function. */ - if ((*env)->EnsureLocalCapacity(env, 4) < 0) { - return NULL; - } - - if (!JNU_IsNull(env, font) && awtJNI_IsMultiFont(env, font)) { - JNU_CHECK_EXCEPTION_RETURN(env, NULL); - - struct FontData *fdata = NULL; - int32_t i, size; - char *fontsetname = NULL; - char *nativename = NULL; - Boolean doFree = FALSE; - jobjectArray componentFonts = NULL; - jobject peer = NULL; - jobject fontDescriptor = NULL; - jstring fontDescriptorName = NULL; - jstring charsetName = NULL; - - fdata = (struct FontData *) JNU_GetLongFieldAsPtr(env,font, - fontIDs.pData); - - if (fdata != NULL && fdata->flist != NULL) { - return fdata; - } - size = (*env)->GetIntField(env, font, fontIDs.size); - fdata = (struct FontData *) malloc(sizeof(struct FontData)); - - peer = (*env)->CallObjectMethod(env, font, fontIDs.getPeer); - - componentFonts = - (*env)->GetObjectField(env, peer, platformFontIDs.componentFonts); - /* We no longer need peer */ - (*env)->DeleteLocalRef(env, peer); - - fdata->charset_num = (*env)->GetArrayLength(env, componentFonts); - - fdata->flist = (awtFontList *) malloc(sizeof(awtFontList) - * fdata->charset_num); - fdata->xfont = NULL; - for (i = 0; i < fdata->charset_num; i++) { - /* - * set xlfd name - */ - - fontDescriptor = (*env)->GetObjectArrayElement(env, componentFonts, i); - fontDescriptorName = - (*env)->GetObjectField(env, fontDescriptor, - fontDescriptorIDs.nativeName); - - if (!JNU_IsNull(env, fontDescriptorName)) { - nativename = (char *) JNU_GetStringPlatformChars(env, fontDescriptorName, NULL); - if (nativename == NULL) { - nativename = ""; - doFree = FALSE; - } else { - doFree = TRUE; - } - } else { - nativename = ""; - doFree = FALSE; - } - - fdata->flist[i].xlfd = malloc(strlen(nativename) - + strlen(defaultXLFD)); - jio_snprintf(fdata->flist[i].xlfd, strlen(nativename) + 10, - nativename, size * 10); - - if (nativename != NULL && doFree) - JNU_ReleaseStringPlatformChars(env, fontDescriptorName, (const char *) nativename); - - /* - * set charset_name - */ - - charsetName = - (*env)->GetObjectField(env, fontDescriptor, - fontDescriptorIDs.charsetName); - - fdata->flist[i].charset_name = (char *) - JNU_GetStringPlatformChars(env, charsetName, NULL); - if (fdata->flist[i].charset_name == NULL) { - (*env)->ExceptionClear(env); - JNU_ThrowOutOfMemoryError(env, "Could not create charset name"); - return NULL; - } - - /* We are done with the objects. */ - (*env)->DeleteLocalRef(env, fontDescriptor); - (*env)->DeleteLocalRef(env, fontDescriptorName); - (*env)->DeleteLocalRef(env, charsetName); - - /* - * set load & XFontStruct - */ - fdata->flist[i].load = 0; - - /* - * This appears to be a bogus check. The actual intent appears - * to be to find out whether this is the "base" font in a set, - * rather than iso8859_1 explicitly. Note that iso8859_15 will - * and must also pass this test. - */ - - if (fdata->xfont == NULL && - strstr(fdata->flist[i].charset_name, "8859_1")) { - fdata->flist[i].xfont = - loadFont(awt_display, fdata->flist[i].xlfd, size * 10); - if (fdata->flist[i].xfont != NULL) { - fdata->flist[i].load = 1; - fdata->xfont = fdata->flist[i].xfont; - fdata->flist[i].index_length = 1; - } else { - /* Free any already allocated storage and fonts */ - int j = i; - for (j = 0; j <= i; j++) { - free((void *)fdata->flist[j].xlfd); - JNU_ReleaseStringPlatformChars(env, NULL, - fdata->flist[j].charset_name); - if (fdata->flist[j].load) { - XFreeFont(awt_display, fdata->flist[j].xfont); - } - } - free((void *)fdata->flist); - free((void *)fdata); - - if (errmsg != NULL) { - *errmsg = "java/lang" "NullPointerException"; - } - (*env)->DeleteLocalRef(env, componentFonts); - return NULL; - } - } - } - (*env)->DeleteLocalRef(env, componentFonts); - /* - * XFontSet will create if the peer of TextField/TextArea - * are used. - */ - fdata->xfs = NULL; - - JNU_SetLongFieldFromPtr(env,font,fontIDs.pData,fdata); - Disposer_AddRecord(env, font, pDataDisposeMethod, ptr_to_jlong(fdata)); - return fdata; - } else { - JNU_CHECK_EXCEPTION_RETURN(env, NULL); - Display *display = NULL; - struct FontData *fdata = NULL; - char fontSpec[1024]; - int32_t height; - int32_t oheight; - int32_t above = 0; /* tries above height */ - int32_t below = 0; /* tries below height */ - char *foundry = NULL; - char *name = NULL; - char *encoding = NULL; - char *style = NULL; - XFontStruct *xfont = NULL; - jstring family = NULL; - - if (JNU_IsNull(env, font)) { - if (errmsg != NULL) { - *errmsg = "java/lang" "NullPointerException"; - } - return (struct FontData *) NULL; - } - display = XDISPLAY; - - fdata = (struct FontData *) JNU_GetLongFieldAsPtr(env,font,fontIDs.pData); - if (fdata != NULL && fdata->xfont != NULL) { - return fdata; - } - - family = (*env)->CallObjectMethod(env, font, fontIDs.getFamily); - - if (!awtJNI_FontName(env, family, &foundry, &name, &encoding)) { - if (errmsg != NULL) { - *errmsg = "java/lang" "NullPointerException"; - } - (*env)->DeleteLocalRef(env, family); - return (struct FontData *) NULL; - } - style = Style((*env)->GetIntField(env, font, fontIDs.style)); - oheight = height = (*env)->GetIntField(env, font, fontIDs.size); - - while (1) { - jio_snprintf(fontSpec, sizeof(fontSpec), "-%s-%s-%s-*-*-%d-*-*-*-*-*-%s", - foundry, - name, - style, - height, - encoding); - - /*fprintf(stderr,"LoadFont: %s\n", fontSpec); */ - xfont = XLoadQueryFont(display, fontSpec); - - /* XXX: sometimes XLoadQueryFont returns a bogus font structure */ - /* with negative ascent. */ - if (xfont == NULL || xfont->ascent < 0) { - if (xfont != NULL) { - XFreeFont(display, xfont); - } - if (foundry != anyfoundry) { /* Use ptr comparison here, not strcmp */ - /* Try any other foundry before messing with the sizes */ - foundry = anyfoundry; - continue; - } - /* We couldn't find the font. We'll try to find an */ - /* alternate by searching for heights above and below our */ - /* preferred height. We try for 4 heights above and below. */ - /* If we still can't find a font we repeat the algorithm */ - /* using misc-fixed as the font. If we then fail, then we */ - /* give up and signal an error. */ - if (above == below) { - above++; - height = oheight + above; - } else { - below++; - if (below > 4) { - if (name != defaultfontname || style != anystyle) { - name = defaultfontname; - foundry = defaultfoundry; - height = oheight; - style = anystyle; - encoding = isolatin1; - above = below = 0; - continue; - } else { - if (errmsg != NULL) { - *errmsg = "java/io/" "FileNotFoundException"; - } - (*env)->DeleteLocalRef(env, family); - return (struct FontData *) NULL; - } - } - height = oheight - below; - } - continue; - } else { - fdata = ZALLOC(FontData); - - if (fdata == NULL) { - if (errmsg != NULL) { - *errmsg = "java/lang" "OutOfMemoryError"; - } - } else { - fdata->xfont = xfont; - JNU_SetLongFieldFromPtr(env,font,fontIDs.pData,fdata); - Disposer_AddRecord(env, font, pDataDisposeMethod, - ptr_to_jlong(fdata)); - } - (*env)->DeleteLocalRef(env, family); - return fdata; - } - } - /* not reached */ - } -} - /* * Registered with the 2D disposer to be called after the Font is GC'd. */