src/solaris/native/sun/awt/awt_Font.c
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Sdiff src/solaris/native/sun/awt

src/solaris/native/sun/awt/awt_Font.c

Print this page




 435     if (cname != NULL)
 436         JNU_ReleaseStringPlatformChars(env, name, (const char *) cname);
 437 
 438     return 1;
 439 }
 440 
 441 struct FontData *
 442 awtJNI_GetFontData(JNIEnv * env, jobject font, char **errmsg)
 443 {
 444     /* We are going to create at most 4 outstanding local refs in this
 445      * function. */
 446     if ((*env)->EnsureLocalCapacity(env, 4) < 0) {
 447         return NULL;
 448     }
 449 
 450     if (!JNU_IsNull(env, font) && awtJNI_IsMultiFont(env, font)) {
 451         struct FontData *fdata = NULL;
 452         int32_t i, size;
 453         char *fontsetname = NULL;
 454         char *nativename = NULL;

 455         jobjectArray componentFonts = NULL;
 456         jobject peer = NULL;
 457         jobject fontDescriptor = NULL;
 458         jstring fontDescriptorName = NULL;
 459         jstring charsetName = NULL;
 460 
 461         fdata = (struct FontData *) JNU_GetLongFieldAsPtr(env,font,
 462                                                          fontIDs.pData);
 463 
 464         if (fdata != NULL && fdata->flist != NULL) {
 465             return fdata;
 466         }
 467         size = (*env)->GetIntField(env, font, fontIDs.size);
 468         fdata = (struct FontData *) malloc(sizeof(struct FontData));
 469 
 470         peer = (*env)->CallObjectMethod(env, font, fontIDs.getPeer);
 471 
 472         componentFonts =
 473           (*env)->GetObjectField(env, peer, platformFontIDs.componentFonts);
 474         /* We no longer need peer */
 475         (*env)->DeleteLocalRef(env, peer);
 476 
 477         fdata->charset_num = (*env)->GetArrayLength(env, componentFonts);
 478 
 479         fdata->flist = (awtFontList *) malloc(sizeof(awtFontList)
 480                                               * fdata->charset_num);
 481         fdata->xfont = NULL;
 482         for (i = 0; i < fdata->charset_num; i++) {
 483             /*
 484              * set xlfd name
 485              */
 486 
 487             fontDescriptor = (*env)->GetObjectArrayElement(env, componentFonts, i);
 488             fontDescriptorName =
 489               (*env)->GetObjectField(env, fontDescriptor,
 490                                      fontDescriptorIDs.nativeName);
 491 
 492             if (!JNU_IsNull(env, fontDescriptorName)) {
 493                 nativename = (char *) JNU_GetStringPlatformChars(env, fontDescriptorName, NULL);

 494             } else {
 495                 nativename = "";

 496             }
 497 
 498             fdata->flist[i].xlfd = malloc(strlen(nativename)
 499                                           + strlen(defaultXLFD));
 500             jio_snprintf(fdata->flist[i].xlfd, strlen(nativename) + 10,
 501                          nativename, size * 10);
 502 
 503             if (nativename != NULL && nativename != "")
 504                 JNU_ReleaseStringPlatformChars(env, fontDescriptorName, (const char *) nativename);
 505 
 506             /*
 507              * set charset_name
 508              */
 509 
 510             charsetName =
 511               (*env)->GetObjectField(env, fontDescriptor,
 512                                      fontDescriptorIDs.charsetName);
 513 
 514             fdata->flist[i].charset_name = (char *)
 515                 JNU_GetStringPlatformChars(env, charsetName, NULL);
 516 
 517             /* We are done with the objects. */
 518             (*env)->DeleteLocalRef(env, fontDescriptor);
 519             (*env)->DeleteLocalRef(env, fontDescriptorName);
 520             (*env)->DeleteLocalRef(env, charsetName);
 521 
 522             /*
 523              * set load & XFontStruct




 435     if (cname != NULL)
 436         JNU_ReleaseStringPlatformChars(env, name, (const char *) cname);
 437 
 438     return 1;
 439 }
 440 
 441 struct FontData *
 442 awtJNI_GetFontData(JNIEnv * env, jobject font, char **errmsg)
 443 {
 444     /* We are going to create at most 4 outstanding local refs in this
 445      * function. */
 446     if ((*env)->EnsureLocalCapacity(env, 4) < 0) {
 447         return NULL;
 448     }
 449 
 450     if (!JNU_IsNull(env, font) && awtJNI_IsMultiFont(env, font)) {
 451         struct FontData *fdata = NULL;
 452         int32_t i, size;
 453         char *fontsetname = NULL;
 454         char *nativename = NULL;
 455         Boolean doFree = FALSE;
 456         jobjectArray componentFonts = NULL;
 457         jobject peer = NULL;
 458         jobject fontDescriptor = NULL;
 459         jstring fontDescriptorName = NULL;
 460         jstring charsetName = NULL;
 461 
 462         fdata = (struct FontData *) JNU_GetLongFieldAsPtr(env,font,
 463                                                          fontIDs.pData);
 464 
 465         if (fdata != NULL && fdata->flist != NULL) {
 466             return fdata;
 467         }
 468         size = (*env)->GetIntField(env, font, fontIDs.size);
 469         fdata = (struct FontData *) malloc(sizeof(struct FontData));
 470 
 471         peer = (*env)->CallObjectMethod(env, font, fontIDs.getPeer);
 472 
 473         componentFonts =
 474           (*env)->GetObjectField(env, peer, platformFontIDs.componentFonts);
 475         /* We no longer need peer */
 476         (*env)->DeleteLocalRef(env, peer);
 477 
 478         fdata->charset_num = (*env)->GetArrayLength(env, componentFonts);
 479 
 480         fdata->flist = (awtFontList *) malloc(sizeof(awtFontList)
 481                                               * fdata->charset_num);
 482         fdata->xfont = NULL;
 483         for (i = 0; i < fdata->charset_num; i++) {
 484             /*
 485              * set xlfd name
 486              */
 487 
 488             fontDescriptor = (*env)->GetObjectArrayElement(env, componentFonts, i);
 489             fontDescriptorName =
 490               (*env)->GetObjectField(env, fontDescriptor,
 491                                      fontDescriptorIDs.nativeName);
 492 
 493             if (!JNU_IsNull(env, fontDescriptorName)) {
 494                 nativename = (char *) JNU_GetStringPlatformChars(env, fontDescriptorName, NULL);
 495                 doFree = TRUE;
 496             } else {
 497                 nativename = "";
 498                 doFree = FALSE;
 499             }
 500 
 501             fdata->flist[i].xlfd = malloc(strlen(nativename)
 502                                           + strlen(defaultXLFD));
 503             jio_snprintf(fdata->flist[i].xlfd, strlen(nativename) + 10,
 504                          nativename, size * 10);
 505 
 506             if (nativename != NULL && doFree)
 507                 JNU_ReleaseStringPlatformChars(env, fontDescriptorName, (const char *) nativename);
 508 
 509             /*
 510              * set charset_name
 511              */
 512 
 513             charsetName =
 514               (*env)->GetObjectField(env, fontDescriptor,
 515                                      fontDescriptorIDs.charsetName);
 516 
 517             fdata->flist[i].charset_name = (char *)
 518                 JNU_GetStringPlatformChars(env, charsetName, NULL);
 519 
 520             /* We are done with the objects. */
 521             (*env)->DeleteLocalRef(env, fontDescriptor);
 522             (*env)->DeleteLocalRef(env, fontDescriptorName);
 523             (*env)->DeleteLocalRef(env, charsetName);
 524 
 525             /*
 526              * set load & XFontStruct


src/solaris/native/sun/awt/awt_Font.c
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File