[jsword-svn] r1511 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic bibledesktop/src/main/java/org/crosswire/bibledesktop/util jsword/src/main/java/org/crosswire/jsword/book
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Sun Jul 22 17:50:15 MST 2007
Author: dmsmith
Date: 2007-07-22 17:50:14 -0700 (Sun, 22 Jul 2007)
New Revision: 1511
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/bibledesktop/src/main/java/org/crosswire/bibledesktop/util/ConfigurableSwingConverter.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java
Log:
The Font property of the module's conf is now honored.
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java 2007-07-22 22:34:08 UTC (rev 1510)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java 2007-07-23 00:50:14 UTC (rev 1511)
@@ -45,9 +45,11 @@
import org.crosswire.bibledesktop.util.ConfigurableSwingConverter;
import org.crosswire.common.swing.ActionFactory;
import org.crosswire.common.swing.CWScrollPane;
+import org.crosswire.common.swing.GuiConvert;
import org.crosswire.common.swing.GuiUtil;
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.FormatType;
import org.crosswire.common.xml.PrettySerializingContentHandler;
@@ -94,6 +96,20 @@
BookMetaData bmd = book.getBookMetaData();
+ String fontName = bmd.getProperty(BookMetaData.KEY_FONT);
+ 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);
+ // Make sure it is installed. Java does substitution. Make sure we got what we wanted.
+ if (bookFont.getFamily().equalsIgnoreCase(fontName))
+ {
+ fontSpec = newFontSpec;
+ }
+ }
+
SAXEventProvider osissep = bdata.getSAXEventProvider();
// This really looks nice but its performance was terrible.
@@ -115,10 +131,11 @@
else
{
XSLTProperty.CSS.setProperty(htmlsep);
- XSLTProperty.FONT.setProperty(htmlsep);
XSLTProperty.BASE_URL.setProperty(htmlsep);
XSLTProperty.DIRECTION.setProperty(htmlsep);
}
+ // Override the default if needed
+ htmlsep.setParameter(XSLTProperty.FONT.getName(), fontSpec);
// This really looks nice but its performance was terrible.
// ContentHandler html = new HTMLSerializingContentHandler(FormatType.CLASSIC_INDENT);
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-07-22 22:34:08 UTC (rev 1510)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TextPaneBookDataDisplay.java 2007-07-23 00:50:14 UTC (rev 1511)
@@ -23,6 +23,7 @@
import java.awt.Component;
import java.awt.ComponentOrientation;
+import java.awt.Font;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -48,9 +49,11 @@
import org.crosswire.bibledesktop.display.URIEventListener;
import org.crosswire.bibledesktop.passage.KeyChangeListener;
import org.crosswire.common.swing.AntiAliasedTextPane;
+import org.crosswire.common.swing.GuiConvert;
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;
@@ -150,6 +153,20 @@
boolean direction = bmd.isLeftToRight();
txtView.applyComponentOrientation(direction ? ComponentOrientation.LEFT_TO_RIGHT : ComponentOrientation.RIGHT_TO_LEFT);
+ String fontName = bmd.getProperty(BookMetaData.KEY_FONT);
+ 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);
+ // Make sure it is installed. Java does substitution. Make sure we got what we wanted.
+ if (bookFont.getFamily().equalsIgnoreCase(fontName))
+ {
+ fontSpec = newFontSpec;
+ }
+ }
+
try
{
SAXEventProvider osissep = bdata.getSAXEventProvider();
@@ -167,10 +184,11 @@
else
{
XSLTProperty.CSS.setProperty(htmlsep);
- XSLTProperty.FONT.setProperty(htmlsep);
XSLTProperty.BASE_URL.setProperty(htmlsep);
XSLTProperty.DIRECTION.setProperty(htmlsep);
}
+ // Override the default if needed
+ htmlsep.setParameter(XSLTProperty.FONT.getName(), fontSpec);
String text = XMLUtil.writeToString(htmlsep);
/* BUG_PARADE(DMS): 4775730
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/util/ConfigurableSwingConverter.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/util/ConfigurableSwingConverter.java 2007-07-22 22:34:08 UTC (rev 1510)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/util/ConfigurableSwingConverter.java 2007-07-23 00:50:14 UTC (rev 1511)
@@ -89,8 +89,6 @@
// We used to do:
// tsep.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
// however for various reasons, now we don't but nothing seems to be broken ...
- tsep.setParameter("font", font); //$NON-NLS-1$
-
return tsep;
}
catch (MissingResourceException ex)
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java 2007-07-22 22:34:08 UTC (rev 1510)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java 2007-07-23 00:50:14 UTC (rev 1511)
@@ -265,6 +265,11 @@
String KEY_XML_LANG = "Lang"; //$NON-NLS-1$
/**
+ * The key for the name in the properties map
+ */
+ String KEY_FONT = "Font"; //$NON-NLS-1$
+
+ /**
* The key for the initials in the properties map
*/
String KEY_INITIALS = "Initials"; //$NON-NLS-1$
More information about the jsword-svn
mailing list