2002/08/07 04:42:00
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 06:49:45 +0000 (06:49 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 06:49:45 +0000 (06:49 +0000)
darcs-hash:20040130064945-2ba56-6998bf76b04b5f397dd6184ace76b16fa95a2563.gz

CHANGES
src/org/xwt/plat/POSIX.java

diff --git a/CHANGES b/CHANGES
index 1686343..742608c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
 
 06-Jul megacz JSObject.java: constructor now takes sealed argument
 
+06-Jul megacz POSIX.java: font mapper now prefers ISO_8559-1 fonts
+
index 794be06..e47cc9b 100644 (file)
@@ -257,30 +257,34 @@ public class POSIX extends GCJ {
         // use the font list to build nativeFontList
         String[] fonts = listNativeFonts();
 
+        Vector v = new Vector();
         for(int k=0; k<fonts.length; k++) {
+
             String s = fonts[k].toLowerCase();
-            StringTokenizer st = new StringTokenizer(s, "-", true);
-            String[] font = new String[st.countTokens()];
-            
+            String s2 = s;
             try {
-                int i = 0;
-                while(st.hasMoreTokens()) {
-                    String s2 = st.nextToken();
-                    if (!s2.equals("-")) font[i++] = s2;
+                v.setSize(0);
+                s = s.substring(s.indexOf('-') + 1);
+                while (s.indexOf('-') != -1) {
+                    v.addElement(s.substring(0, s.indexOf('-')));
+                    s = s.substring(s.indexOf('-') + 1);
                 }
+                v.addElement(s);
+                String[] font = new String[v.size()];
+                v.copyInto(font);
 
                 // limit to iso8559 until we can do I18N properly....
-                if (i > 13) {
-                    if (!font[13].equals("iso8559")) continue;
-                    if (i < 15 || !font[14].equals("1")) continue;
+                if (font.length > 12) {
+                    if (!font[12].equals("iso8859") && !font[12].equals("")) continue;
+                    if (font.length < 14 || !font[13].equals("1")) continue;
                 }
 
                 String name = font[1];
                 String size = font[6];
                 String slant = (font[3].equals("i") || font[3].equals("o")) ? "i" : "";
                 String bold = font[2].equals("bold") ? "b" : "";
-                String tail = s.substring(1 + font[0].length() + 1 + font[1].length() + 1 + font[2].length() + 1 +
-                                          font[3].length() + 1 + font[4].length() + 1);
+                String tail = s2.substring(1 + font[0].length() + 1 + font[1].length() + 1 + font[2].length() + 1 +
+                                           font[3].length() + 1 + font[4].length() + 1);
                 
                 if (bold.equals("*") && slant.equals("*")) {
                     nativeFontList.put(name + size, font[0] + "-" + font[1] + "-regular-r-" + font[4] + "-" + tail);
@@ -297,11 +301,11 @@ public class POSIX extends GCJ {
                     nativeFontList.put(name + size + bold + "i", font[0] + "-" + font[1] + "-" + font[2] + "-i-" + font[4] + "-" + tail);
                     
                 } else {
-                    nativeFontList.put(name + size + bold + slant, s);
+                    nativeFontList.put(name + size + bold + slant, s2);
                     
                 }
             } catch (ArrayIndexOutOfBoundsException e) {
-                if (Log.on) Log.log(this, "skipping incomplete font string " + s);
+                if (Log.on) Log.log(this, "skipping incomplete font string " + s2);
                 continue;
             }
         }
@@ -365,9 +369,9 @@ public class POSIX extends GCJ {
             for(int j=0; j<6; j++) i = target.indexOf('-', i + 1);
             target = target.substring(0, i + 1) + arg.size + target.substring(target.indexOf('-', i+1));
         }
+        if (Log.on) Log.log(POSIX.class, "mapping font \"" + s + "\" to \"" + target + "\"");
         RawData ret = fontStringToStruct(target);
         if (ret == null) ret = fontStringToStruct("fixed");
-        if (Log.on) Log.log(POSIX.class, "mapping font \"" + s + "\" to \"" + target + "\"");
         xwtFontToFontStruct.put(s, new WrappedRawData(ret));
         return ret;
     }