aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2007-02-06 20:35:49 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2007-02-06 20:35:49 +0000
commitf183113d083c5e0306cc0e96f28445258419ceb5 (patch)
treeba3755b065739b32be33e9482ad48084c6d7baea /src
parent838b976e8a371dbec1c6d3a4780e653442aff157 (diff)
downloadxmlgraphics-fop-f183113d083c5e0306cc0e96f28445258419ceb5.tar.gz
xmlgraphics-fop-f183113d083c5e0306cc0e96f28445258419ceb5.zip
Fix: override PropertyMaker.make() to properly parse font-family names containing spaces.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@504280 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/fo/properties/FontFamilyProperty.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java b/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java
index 48082e1d8..84000233c 100644
--- a/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java
+++ b/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java
@@ -21,6 +21,7 @@ package org.apache.fop.fo.properties;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.PropertyException;
/**
* Property class for the font-family property.
@@ -40,6 +41,55 @@ public class FontFamilyProperty extends ListProperty {
}
/**
+ * @see org.apache.fop.fo.properties.PropertyMaker#make(
+ * org.apache.fop.fo.PropertyList,
+ * java.lang.String,
+ * org.apache.fop.fo.FObj)
+ */
+ public Property make(PropertyList propertyList, String value, FObj fo) throws PropertyException {
+ ListProperty prop = new ListProperty();
+ String tmpVal;
+ int startIndex = 0;
+ int commaIndex = value.indexOf(',');
+ int quoteIndex;
+ int aposIndex;
+ char qChar;
+ boolean parsed = false;
+ while (!parsed) {
+ if (commaIndex == -1) {
+ tmpVal = value.substring(startIndex).trim();
+ parsed = true;
+ } else {
+ tmpVal = value.substring(startIndex, commaIndex).trim();
+ startIndex = commaIndex + 1;
+ commaIndex = value.indexOf(',', startIndex);
+ }
+ aposIndex = tmpVal.indexOf('\'');
+ quoteIndex = tmpVal.indexOf('\"');
+ if (aposIndex != -1 || quoteIndex != -1) {
+ qChar = (aposIndex == -1) ? '\"' : '\'';
+ if (tmpVal.lastIndexOf(qChar) != tmpVal.length() - 1) {
+ Property.log.warn("Skipping malformed value for font-family: "
+ + tmpVal + " in \"" + value + "\".");
+ tmpVal = "";
+ } else {
+ tmpVal = tmpVal.substring(1, tmpVal.length() - 1);
+ }
+ }
+ if (!"".equals(tmpVal)) {
+ int dblSpaceIndex = tmpVal.indexOf(" ");
+ while (dblSpaceIndex != -1) {
+ tmpVal = tmpVal.substring(0, dblSpaceIndex)
+ + tmpVal.substring(dblSpaceIndex + 1);
+ dblSpaceIndex = tmpVal.indexOf(" ");
+ }
+ prop.addProperty(new StringProperty(tmpVal));
+ }
+ }
+ return prop;
+ }
+
+ /**
* @see PropertyMaker#convertProperty
*/
public Property convertProperty(Property p,