< prev index next >

src/java.desktop/windows/native/libfontmanager/fontpath.c

Print this page




 288 /*     fflush(stdout); */
 289 
 290     /* Windows lists fonts which have a vmtx (vertical metrics) table twice.
 291      * Once using their normal name, and again preceded by '@'. These appear
 292      * in font lists in some windows apps, such as wordpad. We don't want
 293      * these so we skip any font where the first character is '@'
 294      */
 295     if (lpelfe->elfLogFont.lfFaceName[0] == L'@') {
 296             return 1;
 297     }
 298     slen = wcslen(lpelfe->elfLogFont.lfFaceName);
 299     fmi->family = (*env)->NewString(env,lpelfe->elfLogFont.lfFaceName, (jsize)slen);
 300     if (fmi->family == NULL) {
 301         (*env)->ExceptionClear(env);
 302         return 1;
 303     }
 304 
 305     familyLC = (*env)->CallObjectMethod(env, fmi->family,
 306                                         fmi->toLowerCaseMID, fmi->locale);
 307     /* Delete the created reference after its usage */
 308     DeleteLocalReference(env, fmi->family);
 309     if ((*env)->ExceptionCheck(env)) {

 310         return 0;
 311     }
 312 
 313     /* check if already seen this family with a different charset */
 314     jboolean mapHasKey = (*env)->CallBooleanMethod(env,
 315                                                    fmi->familyToFontListMap,
 316                                                    fmi->containsKeyMID,
 317                                                    familyLC);
 318     if ((*env)->ExceptionCheck(env)) {
 319         /* Delete the created references before return */

 320         DeleteLocalReference(env, familyLC);
 321         return 0;
 322     } else if (mapHasKey) {
 323         /* Delete the created references before return */

 324         DeleteLocalReference(env, familyLC);
 325         return 1;
 326     }
 327 
 328     fmi->list = (*env)->NewObject(env,
 329                                   fmi->arrayListClass, fmi->arrayListCtr, 4);
 330     if (fmi->list == NULL) {
 331         /* Delete the created references before return */

 332         DeleteLocalReference(env, familyLC);
 333         return 0;
 334     }
 335 
 336     (*env)->CallObjectMethod(env, fmi->familyToFontListMap,
 337                              fmi->putMID, familyLC, fmi->list);
 338     /* Delete the created reference after its usage */
 339     DeleteLocalReference(env, familyLC);
 340     if ((*env)->ExceptionCheck(env)) {
 341         /* Delete the created reference before return */

 342         DeleteLocalReference(env, fmi->list);
 343         return 0;
 344     }
 345 
 346     memset(&lfw, 0, sizeof(lfw));
 347     wcscpy(lfw.lfFaceName, lpelfe->elfLogFont.lfFaceName);
 348     lfw.lfCharSet = lpelfe->elfLogFont.lfCharSet;
 349     EnumFontFamiliesExW(screenDC, &lfw,
 350                         (FONTENUMPROCW)EnumFontFacesInFamilyProcW,
 351                         lParam, 0L);
 352 
 353     /* Delete the created reference after its usage in the enum function */

 354     DeleteLocalReference(env, fmi->list);
 355     return 1;
 356 }
 357 
 358 /* It looks like TrueType fonts have " (TrueType)" tacked on the end of their
 359  * name, so we can try to use that to distinguish TT from other fonts.
 360  * However if a program "installed" a font in the registry the key may
 361  * not include that. We could also try to "pass" fonts which have no "(..)"
 362  * at the end. But that turns out to pass a few .FON files that MS supply.
 363  * If there's no parenthesized type string, we could next try to infer
 364  * the file type from the file name extension. Since the MS entries that
 365  * have no type string are very few, and have odd names like "MS-DOS CP 437"
 366  * and would never return a Java Font anyway its currently OK to put these
 367  * in the font map, although clearly the returned names must never percolate
 368  * up into a list of available fonts returned to the application.
 369  * Additionally for TTC font files the key looks like
 370  * Font 1 & Font 2 (TrueType)
 371  * or sometimes even :
 372  * Font 1 & Font 2 & Font 3 (TrueType)
 373  * Also if a Font has a name for this locale that name also




 288 /*     fflush(stdout); */
 289 
 290     /* Windows lists fonts which have a vmtx (vertical metrics) table twice.
 291      * Once using their normal name, and again preceded by '@'. These appear
 292      * in font lists in some windows apps, such as wordpad. We don't want
 293      * these so we skip any font where the first character is '@'
 294      */
 295     if (lpelfe->elfLogFont.lfFaceName[0] == L'@') {
 296             return 1;
 297     }
 298     slen = wcslen(lpelfe->elfLogFont.lfFaceName);
 299     fmi->family = (*env)->NewString(env,lpelfe->elfLogFont.lfFaceName, (jsize)slen);
 300     if (fmi->family == NULL) {
 301         (*env)->ExceptionClear(env);
 302         return 1;
 303     }
 304 
 305     familyLC = (*env)->CallObjectMethod(env, fmi->family,
 306                                         fmi->toLowerCaseMID, fmi->locale);
 307     /* Delete the created reference after its usage */

 308     if ((*env)->ExceptionCheck(env)) {
 309         DeleteLocalReference(env, fmi->family);
 310         return 0;
 311     }
 312 
 313     /* check if already seen this family with a different charset */
 314     jboolean mapHasKey = (*env)->CallBooleanMethod(env,
 315                                                    fmi->familyToFontListMap,
 316                                                    fmi->containsKeyMID,
 317                                                    familyLC);
 318     if ((*env)->ExceptionCheck(env)) {
 319         /* Delete the created references before return */
 320         DeleteLocalReference(env, fmi->family);
 321         DeleteLocalReference(env, familyLC);
 322         return 0;
 323     } else if (mapHasKey) {
 324         /* Delete the created references before return */
 325         DeleteLocalReference(env, fmi->family);
 326         DeleteLocalReference(env, familyLC);
 327         return 1;
 328     }
 329 
 330     fmi->list = (*env)->NewObject(env,
 331                                   fmi->arrayListClass, fmi->arrayListCtr, 4);
 332     if (fmi->list == NULL) {
 333         /* Delete the created references before return */
 334         DeleteLocalReference(env, fmi->family);
 335         DeleteLocalReference(env, familyLC);
 336         return 0;
 337     }
 338 
 339     (*env)->CallObjectMethod(env, fmi->familyToFontListMap,
 340                              fmi->putMID, familyLC, fmi->list);
 341     /* Delete the created reference after its usage */
 342     DeleteLocalReference(env, familyLC);
 343     if ((*env)->ExceptionCheck(env)) {
 344         /* Delete the created reference before return */
 345         DeleteLocalReference(env, fmi->family);
 346         DeleteLocalReference(env, fmi->list);
 347         return 0;
 348     }
 349 
 350     memset(&lfw, 0, sizeof(lfw));
 351     wcscpy(lfw.lfFaceName, lpelfe->elfLogFont.lfFaceName);
 352     lfw.lfCharSet = lpelfe->elfLogFont.lfCharSet;
 353     EnumFontFamiliesExW(screenDC, &lfw,
 354                         (FONTENUMPROCW)EnumFontFacesInFamilyProcW,
 355                         lParam, 0L);
 356 
 357     /* Delete the created reference after its usage in the enum function */
 358     DeleteLocalReference(env, fmi->family);
 359     DeleteLocalReference(env, fmi->list);
 360     return 1;
 361 }
 362 
 363 /* It looks like TrueType fonts have " (TrueType)" tacked on the end of their
 364  * name, so we can try to use that to distinguish TT from other fonts.
 365  * However if a program "installed" a font in the registry the key may
 366  * not include that. We could also try to "pass" fonts which have no "(..)"
 367  * at the end. But that turns out to pass a few .FON files that MS supply.
 368  * If there's no parenthesized type string, we could next try to infer
 369  * the file type from the file name extension. Since the MS entries that
 370  * have no type string are very few, and have odd names like "MS-DOS CP 437"
 371  * and would never return a Java Font anyway its currently OK to put these
 372  * in the font map, although clearly the returned names must never percolate
 373  * up into a list of available fonts returned to the application.
 374  * Additionally for TTC font files the key looks like
 375  * Font 1 & Font 2 (TrueType)
 376  * or sometimes even :
 377  * Font 1 & Font 2 & Font 3 (TrueType)
 378  * Also if a Font has a name for this locale that name also


< prev index next >