< prev index next >

src/java.desktop/share/classes/sun/awt/FontConfiguration.java

Print this page




 234             int numT1s = (t1s == null) ? 0 : t1s.length;
 235             int len = numTTFs + numT1s;
 236             if (numTTFs + numT1s == 0) {
 237                 return;
 238             }
 239             installedFallbackFontFiles = new String[len];
 240             for (int i=0; i<numTTFs; i++) {
 241                 installedFallbackFontFiles[i] =
 242                     fallbackDir + File.separator + ttfs[i];
 243             }
 244             for (int i=0; i<numT1s; i++) {
 245                 installedFallbackFontFiles[i+numTTFs] =
 246                     fallbackDir + File.separator + t1s[i];
 247             }
 248             fontManager.registerFontsInDir(fallbackDirName);
 249         }
 250     }
 251 
 252     private File findImpl(String fname) {
 253         File f = new File(fname + ".properties");



 254         if (f.canRead()) {



 255             isProperties = true;
 256             return f;
 257         }
 258         f = new File(fname + ".bfc");



 259         if (f.canRead()) {



 260             isProperties = false;
 261             return f;
 262         }
 263         return null;
 264     }
 265 
 266     private File findFontConfigFile(String javaLib) {
 267         String baseName = javaLib + File.separator + "fontconfig";
 268         File configFile;
 269         String osMajorVersion = null;
 270         if (osVersion != null && osName != null) {
 271             configFile = findImpl(baseName + "." + osName + "." + osVersion);
 272             if (configFile != null) {
 273                 return configFile;
 274             }
 275             int decimalPointIndex = osVersion.indexOf('.');
 276             if (decimalPointIndex != -1) {
 277                 osMajorVersion = osVersion.substring(0, osVersion.indexOf('.'));
 278                 configFile = findImpl(baseName + "." + osName + "." + osMajorVersion);
 279                 if (configFile != null) {


 287                 return configFile;
 288             }
 289         }
 290         if (osVersion != null) {
 291             configFile = findImpl(baseName + "." + osVersion);
 292             if (configFile != null) {
 293                 return configFile;
 294             }
 295             if (osMajorVersion != null) {
 296                 configFile = findImpl(baseName + "." + osMajorVersion);
 297                 if (configFile != null) {
 298                     return configFile;
 299                 }
 300             }
 301         }
 302         foundOsSpecificFile = false;
 303 
 304         configFile = findImpl(baseName);
 305         if (configFile != null) {
 306             return configFile;



 307         }
 308         return null;
 309     }
 310 
 311     /* Initialize the internal data tables from binary format font
 312      * configuration file.
 313      */
 314     public static void loadBinary(InputStream inStream) throws IOException {
 315         DataInputStream in = new DataInputStream(inStream);
 316         head = readShortTable(in, HEAD_LENGTH);
 317         int[] tableSizes = new int[INDEX_TABLEEND];
 318         for (int i = 0; i < INDEX_TABLEEND; i++) {
 319             tableSizes[i] = head[i + 1] - head[i];
 320         }
 321         table_scriptIDs       = readShortTable(in, tableSizes[INDEX_scriptIDs]);
 322         table_scriptFonts     = readShortTable(in, tableSizes[INDEX_scriptFonts]);
 323         table_elcIDs          = readShortTable(in, tableSizes[INDEX_elcIDs]);
 324         table_sequences        = readShortTable(in, tableSizes[INDEX_sequences]);
 325         table_fontfileNameIDs = readShortTable(in, tableSizes[INDEX_fontfileNameIDs]);
 326         table_componentFontNameIDs = readShortTable(in, tableSizes[INDEX_componentFontNameIDs]);




 234             int numT1s = (t1s == null) ? 0 : t1s.length;
 235             int len = numTTFs + numT1s;
 236             if (numTTFs + numT1s == 0) {
 237                 return;
 238             }
 239             installedFallbackFontFiles = new String[len];
 240             for (int i=0; i<numTTFs; i++) {
 241                 installedFallbackFontFiles[i] =
 242                     fallbackDir + File.separator + ttfs[i];
 243             }
 244             for (int i=0; i<numT1s; i++) {
 245                 installedFallbackFontFiles[i+numTTFs] =
 246                     fallbackDir + File.separator + t1s[i];
 247             }
 248             fontManager.registerFontsInDir(fallbackDirName);
 249         }
 250     }
 251 
 252     private File findImpl(String fname) {
 253         File f = new File(fname + ".properties");
 254         if (FontUtilities.debugFonts()) {
 255             logger.info("Looking for text fontconfig file : " + f);
 256         }
 257         if (f.canRead()) {
 258             if (FontUtilities.debugFonts()) {
 259                 logger.info("Found file : " + f);
 260             }
 261             isProperties = true;
 262             return f;
 263         }
 264         f = new File(fname + ".bfc");
 265         if (FontUtilities.debugFonts()) {
 266             logger.info("Looking for binary fontconfig file : " + f);
 267         }
 268         if (f.canRead()) {
 269             if (FontUtilities.debugFonts()) {
 270                 logger.info("Found file : " + f);
 271             }
 272             isProperties = false;
 273             return f;
 274         }
 275         return null;
 276     }
 277 
 278     private File findFontConfigFile(String javaLib) {
 279         String baseName = javaLib + File.separator + "fontconfig";
 280         File configFile;
 281         String osMajorVersion = null;
 282         if (osVersion != null && osName != null) {
 283             configFile = findImpl(baseName + "." + osName + "." + osVersion);
 284             if (configFile != null) {
 285                 return configFile;
 286             }
 287             int decimalPointIndex = osVersion.indexOf('.');
 288             if (decimalPointIndex != -1) {
 289                 osMajorVersion = osVersion.substring(0, osVersion.indexOf('.'));
 290                 configFile = findImpl(baseName + "." + osName + "." + osMajorVersion);
 291                 if (configFile != null) {


 299                 return configFile;
 300             }
 301         }
 302         if (osVersion != null) {
 303             configFile = findImpl(baseName + "." + osVersion);
 304             if (configFile != null) {
 305                 return configFile;
 306             }
 307             if (osMajorVersion != null) {
 308                 configFile = findImpl(baseName + "." + osMajorVersion);
 309                 if (configFile != null) {
 310                     return configFile;
 311                 }
 312             }
 313         }
 314         foundOsSpecificFile = false;
 315 
 316         configFile = findImpl(baseName);
 317         if (configFile != null) {
 318             return configFile;
 319         }
 320         if (FontUtilities.debugFonts()) {
 321             logger.info("Did not find a fontconfig file.");
 322         }
 323         return null;
 324     }
 325 
 326     /* Initialize the internal data tables from binary format font
 327      * configuration file.
 328      */
 329     public static void loadBinary(InputStream inStream) throws IOException {
 330         DataInputStream in = new DataInputStream(inStream);
 331         head = readShortTable(in, HEAD_LENGTH);
 332         int[] tableSizes = new int[INDEX_TABLEEND];
 333         for (int i = 0; i < INDEX_TABLEEND; i++) {
 334             tableSizes[i] = head[i + 1] - head[i];
 335         }
 336         table_scriptIDs       = readShortTable(in, tableSizes[INDEX_scriptIDs]);
 337         table_scriptFonts     = readShortTable(in, tableSizes[INDEX_scriptFonts]);
 338         table_elcIDs          = readShortTable(in, tableSizes[INDEX_elcIDs]);
 339         table_sequences        = readShortTable(in, tableSizes[INDEX_sequences]);
 340         table_fontfileNameIDs = readShortTable(in, tableSizes[INDEX_fontfileNameIDs]);
 341         table_componentFontNameIDs = readShortTable(in, tableSizes[INDEX_componentFontNameIDs]);


< prev index next >