Author: rwhitcomb
Date: Thu Jan 14 05:02:17 2021
New Revision: 1885467

URL: http://svn.apache.org/viewvc?rev=1885467&view=rev
Log:
PIVOT-1051: Finish the code to accept a list of font names.

Modified:
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/FontUtilities.java

Modified: 
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java?rev=1885467&r1=1885466&r2=1885467&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java 
(original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java 
Thu Jan 14 05:02:17 2021
@@ -43,6 +43,7 @@ import org.apache.pivot.wtk.Dialog;
 import org.apache.pivot.wtk.Expander;
 import org.apache.pivot.wtk.FileBrowser;
 import org.apache.pivot.wtk.FileBrowserSheet;
+import org.apache.pivot.wtk.FontUtilities;
 import org.apache.pivot.wtk.Form;
 import org.apache.pivot.wtk.Frame;
 import org.apache.pivot.wtk.Gauge;

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/FontUtilities.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/FontUtilities.java?rev=1885467&r1=1885466&r2=1885467&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/FontUtilities.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/FontUtilities.java Thu Jan 14 
05:02:17 2021
@@ -34,7 +34,7 @@ public final class FontUtilities {
      * A list of "standard" sans-serif fonts, useful when cross-platform
      * support is necessary.
      */
-    public static final String SANS_SERIF_FONTS = 
"Arial,Verdana,Helvetica,SansSerif";
+    public static final String SANS_SERIF_FONTS = 
"Verdana,Helvetica,Arial,SansSerif";
 
     /** The obvious factor needed to convert a number to a percentage value. */
     private static final float PERCENT_SCALE = 100.0f;
@@ -109,17 +109,24 @@ public final class FontUtilities {
                     break;
                 }
             }
+
             int pos = str.indexOf(sep);
             String name = pos < 0 ? str : str.substring(0, pos);
             String spec = pos < 0 ? "" : str.substring(pos);
+
             String[] names = name.split(",");
             for (String nm : names) {
                 Font f = Font.decode(nm + spec);
-System.out.println("getName = " + f.getName() + ", getFontName = " + 
f.getFontName() + ", getFamily = " + f.getFamily());
+                if (f.getName().equals(nm) || f.getFamily().equals(nm)) {
+                    return f;
+                }
             }
-        } else {
-            return Font.decode(str);
+
+            // Nothing quite matched in the name list, so return the default
+            return Font.decode(Font.DIALOG + spec);
         }
+
+        return Font.decode(str);
     }
 
     /**
@@ -141,11 +148,16 @@ System.out.println("getName = " + f.getN
             String[] names = name.split(",");
             for (String nm : names) {
                 Font f = new Font(nm, style, size);
-System.out.println("getName = " + f.getName() + ", getFontName = " + 
f.getFontName() + ", getFamily = " + f.getFamily());
+                if (f.getName().equals(nm) || f.getFamily().equals(nm)) {
+                    return f;
+                }
             }
-        } else {
-            return new Font(name, style, size);
+
+            // Nothing quite matched in the name list, so return the default
+            return new Font(Font.DIALOG, style, size);
         }
+
+        return new Font(name, style, size);
     }
 
     /**


Reply via email to