You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2021/01/14 19:38:03 UTC
svn commit: r1885499 -
/pivot/trunk/wtk/src/org/apache/pivot/wtk/FontUtilities.java
Author: rwhitcomb
Date: Thu Jan 14 19:38:03 2021
New Revision: 1885499
URL: http://svn.apache.org/viewvc?rev=1885499&view=rev
Log:
Corrected a bug in FontUtilities; corrected style violations there.
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/FontUtilities.java
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=1885499&r1=1885498&r2=1885499&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 19:38:03 2021
@@ -35,7 +35,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 =
+ public static final String SANS_SERIF_FONTS =
"Verdana, Helvetica, Arial, SansSerif";
/**
@@ -74,8 +74,7 @@ public final class FontUtilities {
if (sizeIndex > 0 && sizeIndex + 1 < length) {
try {
Integer.valueOf(str.substring(sizeIndex + 1));
- }
- catch (NumberFormatException nfe) {
+ } catch (NumberFormatException nfe) {
/* Invalid size, maybe this is the style */
styleIndex = sizeIndex;
sizeIndex = length;
@@ -103,13 +102,11 @@ public final class FontUtilities {
break;
}
fontName = str.substring(0, styleIndex);
- }
- else {
+ } else {
int fontEnd = length;
if (styleIndex > 0) {
fontEnd = styleIndex;
- }
- else if (sizeIndex > 0) {
+ } else if (sizeIndex > 0) {
fontEnd = sizeIndex;
}
while (fontEnd > 0 && str.charAt(fontEnd - 1) == sepChar) {
@@ -177,17 +174,17 @@ public final class FontUtilities {
if (str.indexOf(',') > 0) {
String name = getFontName(str);
int pos = name.length();
- String spec = pos < str.length() ? str.substring(0, pos) : "";
+ String spec = pos < str.length() ? str.substring(pos) : "";
String[] names = name.split("\\s*,\\s*");
for (String nm : names) {
Font f = Font.decode(nm + spec);
- if (f.getName().equals(nm) || f.getFamily().equals(nm)) {
+ if (f.getName().equalsIgnoreCase(nm) || f.getFamily().equalsIgnoreCase(nm)) {
return f;
}
}
- // Nothing quite matched in the name list, so return the default
+ // No names matched in the list, so use the default name
return Font.decode(Font.DIALOG + spec);
}
@@ -213,12 +210,12 @@ public final class FontUtilities {
String[] names = name.split("\\s*,\\s*");
for (String nm : names) {
Font f = new Font(nm, style, size);
- if (f.getName().equals(nm) || f.getFamily().equals(nm)) {
+ if (f.getName().equalsIgnoreCase(nm) || f.getFamily().equalsIgnoreCase(nm)) {
return f;
}
}
- // Nothing quite matched in the name list, so return the default
+ // No names matched in the list, so use the default name
return new Font(Font.DIALOG, style, size);
}