[jsword-svn] r1604 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic common-swing/src/main/java/org/crosswire/common/swing
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Fri Aug 3 09:12:08 MST 2007
Author: dmsmith
Date: 2007-08-03 09:12:08 -0700 (Fri, 03 Aug 2007)
New Revision: 1604
Modified:
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TextPaneBookDataDisplay.java
trunk/common-swing/src/main/java/org/crosswire/common/swing/GuiConvert.java
Log:
fixed a font bug that prevented a module conf's font property from being used.
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java 2007-08-03 15:37:45 UTC (rev 1603)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java 2007-08-03 16:12:08 UTC (rev 1604)
@@ -100,13 +100,11 @@
String fontSpec = XSLTProperty.FONT.getStringState();
if (fontName != null)
{
- String[] fontParts = StringUtil.split(fontSpec, ","); //$NON-NLS-1$
- String newFontSpec = fontName + ',' + fontParts[1] + ',' + fontParts[2];
- Font bookFont = GuiConvert.string2Font(newFontSpec);
+ Font bookFont = GuiConvert.deriveFont(fontSpec, fontName);
// Make sure it is installed. Java does substitution. Make sure we got what we wanted.
if (bookFont.getFamily().equalsIgnoreCase(fontName))
{
- fontSpec = newFontSpec;
+ fontSpec = GuiConvert.font2String(bookFont);
}
}
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TextPaneBookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TextPaneBookDataDisplay.java 2007-08-03 15:37:45 UTC (rev 1603)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TextPaneBookDataDisplay.java 2007-08-03 16:12:08 UTC (rev 1604)
@@ -53,7 +53,6 @@
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
import org.crosswire.common.util.Reporter;
-import org.crosswire.common.util.StringUtil;
import org.crosswire.common.xml.Converter;
import org.crosswire.common.xml.SAXEventProvider;
import org.crosswire.common.xml.TransformingSAXEventProvider;
@@ -154,16 +153,15 @@
txtView.applyComponentOrientation(direction ? ComponentOrientation.LEFT_TO_RIGHT : ComponentOrientation.RIGHT_TO_LEFT);
String fontName = bmd.getProperty(BookMetaData.KEY_FONT);
+ // normalize to a consistent way
String fontSpec = XSLTProperty.FONT.getStringState();
if (fontName != null)
{
- String[] fontParts = StringUtil.split(fontSpec, ","); //$NON-NLS-1$
- String newFontSpec = fontName + ',' + fontParts[1] + ',' + fontParts[2];
- Font bookFont = GuiConvert.string2Font(newFontSpec);
+ Font bookFont = GuiConvert.deriveFont(fontSpec, fontName);
// Make sure it is installed. Java does substitution. Make sure we got what we wanted.
if (bookFont.getFamily().equalsIgnoreCase(fontName))
{
- fontSpec = newFontSpec;
+ fontSpec = GuiConvert.font2String(bookFont);
}
}
Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/GuiConvert.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/GuiConvert.java 2007-08-03 15:37:45 UTC (rev 1603)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/GuiConvert.java 2007-08-03 16:12:08 UTC (rev 1604)
@@ -91,11 +91,11 @@
if (font.isBold())
{
- strStyle = font.isItalic() ? "bolditalic" : "bold"; // //$NON-NLS-1$ //$NON-NLS-2$
+ strStyle = font.isItalic() ? "bolditalic" : "bold"; //$NON-NLS-1$ //$NON-NLS-2$
}
else if (font.isItalic())
{
- strStyle = "italic"; // //$NON-NLS-1$
+ strStyle = "italic"; //$NON-NLS-1$
}
@@ -103,6 +103,23 @@
}
/**
+ * Create a font just like the another with regard to style and size, but differing in font family.
+ * @param fontspec the font to model
+ * @param fontName the font to use
+ * @return the font
+ */
+ public static Font deriveFont(String fontspec, String fontName)
+ {
+ Font font = string2Font(fontspec);
+ Font derived = null;
+ if (font != null && fontName != null)
+ {
+ derived = new Font(fontName, font.getStyle(), font.getSize());
+ }
+ return derived;
+ }
+
+ /**
* Convert a String to a Color
* @param value the thing to convert
* @return the converted data
More information about the jsword-svn
mailing list