/* Decompiled by Mocha from PlatformFont.class */ /* Originally compiled from PlatformFont.java */ package sun.awt; import java.io.*; import java.util.*; import java.awt.Font; import java.awt.peer.FontPeer; public synchronized abstract class PlatformFont implements FontPeer { protected FontDescriptor componentFonts[]; protected char defaultChar; protected Properties props; protected FontDescriptor defaultFont; protected static Hashtable charsetRegistry; protected String aliasName; protected String styleString; private static Properties fprops; public PlatformFont(String string1, int i1) { Vector vector; int j1; int k1; byte b; int i2; CharToByteConverter charToByteConverter; String string5; int an[]; int j2; int k2; if (fprops == null) { props = null; return; } props = fprops; aliasName = props.getProperty(new StringBuffer("alias.").append(string1.toLowerCase()).toString()); if (aliasName == null) aliasName = string1.toLowerCase(); if (props.getProperty(new StringBuffer(String.valueOf(aliasName)).append(".0").toString()) == null && props.getProperty(new StringBuffer(String.valueOf(aliasName)).append(".plain.0").toString()) == null) aliasName = "sansserif"; styleString = styleStr(i1); vector = new Vector(5); j1 = 0; String string2 = String.valueOf(j1); b = props.getProperty("." + styleString + "." + string2); if (b == null) { String string3; String string4; b = props.getProperty("." + string2); if (b == null) { componentFonts = new FontDescriptor[j1]; for (k1 = 0; k1 < j1; k1++) componentFonts[k1] = (FontDescriptor)vector.elementAt(k1); try { b = Integer.parseInt(props.getProperty("default.char", "003f"), 16); } catch (NumberFormatException e3) { b = 63; } defaultChar = '?'; if (componentFonts.length > 0) defaultFont = componentFonts[0]; for (i2 = 0; i2 < componentFonts.length; i2++) { if (!componentFonts[i2].isExcluded((char)b) && componentFonts[i2].fontCharset.canConvert((char)b)) { defaultFont = componentFonts[i2]; defaultChar = (char)b; return; } } } } string3 = props.getProperty(aliasName + "." + styleString + "." + string2); if (string3 == null) { string3 = props.getProperty(aliasName + "." + string2); if (string3 == null) string3 = "default"; } charToByteConverter = getFontCharset(string3.trim(), b); string4 = props.getProperty(aliasName + "." + styleString + "." + string2); if (string4 == null) { string4 = props.getProperty(aliasName + "." + string2); if (string4 == null) string5 = "none"; } if (!string5.equals("none")) goto 497 else 489; an = new int[0]; j2 = 1; k2 = 0; k2 = string5.indexOf(44, k2); if (k2 == -1) goto 529 else 520; k2++; j2++; an = new int[j2]; for (int i3 = 0; i3 < j2; ) { String string6; String string7; int j3 = 0; int k3 = 0; try { string6 = string5.substring(i3 * 10, i3 * 10 + 4); string7 = string5.substring(i3 * 10 + 5, i3 * 10 + 9); } catch (StringIndexOutOfBoundsException e1) { an = new int[0]; break; } try { j3 = Integer.parseInt(string6, 16); k3 = Integer.parseInt(string7, 16); an[i3] = j3 << 16 | k3; i3++; } catch (NumberFormatException e2) { an = new int[0]; break; } } vector.addElement(new FontDescriptor(b, charToByteConverter, an)); j1++; } public CharsetString[] makeMultiCharsetString(String string1) { Vector vector = new Vector(3, 1); StringBuffer stringBuffer = new StringBuffer(string1); char ch1 = defaultChar; FontDescriptor fontDescriptor1 = defaultFont; if (stringBuffer.length() < 1) return new CharsetString[0]; for (int i1 = 0; i1 < componentFonts.length; i1++) { if (!componentFonts[i1].isExcluded(string1.charAt(0)) && componentFonts[i1].fontCharset.canConvert(string1.charAt(0))) { fontDescriptor1 = componentFonts[i1]; ch1 = string1.charAt(0); break; } } stringBuffer.setCharAt(0, ch1); int? j1 = 0; for (int k = 1; k < string1.length(); k++) { char ch2 = string1.charAt(k); FontDescriptor fontDescriptor2 = defaultFont; ch1 = defaultChar; for (int i2 = 0; i2 < componentFonts.length; i2++) { if (!componentFonts[i2].isExcluded(ch2) && componentFonts[i2].fontCharset.canConvert(ch2)) { fontDescriptor2 = componentFonts[i2]; ch1 = ch2; break; } } stringBuffer.setCharAt(k, ch1); if (fontDescriptor1 != fontDescriptor2) { String string3 = stringBuffer.toString().substring(j1, k); vector.addElement(new CharsetString(string3, fontDescriptor1)); fontDescriptor1 = fontDescriptor2; fontDescriptor2 = defaultFont; j1 = k; } } String string2 = stringBuffer.toString().substring(j1, string1.length()); vector.addElement(new CharsetString(string2, fontDescriptor1)); CharsetString acharsetString[] = new CharsetString[vector.size()]; for (int j2 = 0; j2 < vector.size(); j2++) acharsetString[j2] = (CharsetString)vector.elementAt(j2); return acharsetString; } protected abstract CharToByteConverter getFontCharset(String string1, String string2); public static String styleStr(int i) { switch (i) { case 1: return "bold"; case 2: return "italic"; case 3: return "bolditalic"; default: return "plain"; } } static { File file; charsetRegistry = new Hashtable(5); String string1 = System.getProperty("java.home"); String string2 = System.getProperty("user.home"); if (string1 == null) throw new Error("java.home property not set"); String string3 = System.getProperty("user.language", "en"); String string4 = System.getProperty("user.region"); try { file = null; } catch (Exception e) { } if (string4 != null) file = new File(File.separator + "lib" + File.separator + "font.properties." + string3 + "_" + string4); if (file == null || !file.canRead()) { file = new File(File.separator + "lib" + File.separator + "font.properties." + string3); if (!file.canRead()) { file = new File(File.separator + "lib" + File.separator + "font.properties"); if (!file.canRead()) { if (string4 != null) file = new File(File.separator + "lib" + File.separator + "font.properties." + string3 + "_" + string4); if (!file.canRead()) { file = new File(File.separator + "font.properties." + string3); if (!file.canRead()) { file = new File(File.separator + "font.properties"); if (!file.canRead()) throw new Exception(); } } } } } fprops = new Properties(); BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file.getPath())); fprops.load(bufferedInputStream); bufferedInputStream.close(); return; } }