You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by sp...@apache.org on 2010/08/19 21:46:45 UTC

svn commit: r987282 [3/9] - in /xmlgraphics/fop/branches/Temp_ComplexScripts: ./ src/codegen/unicode/java/org/apache/fop/hyphenation/ src/codegen/unicode/java/org/apache/fop/text/bidi/ src/java/org/apache/fop/area/ src/java/org/apache/fop/area/inline/ ...

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/PageSequence.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/PageSequence.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/PageSequence.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/PageSequence.java Thu Aug 19 19:46:41 2010
@@ -25,22 +25,28 @@ import java.util.Map;
 import org.xml.sax.Locator;
 
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.datatypes.Numeric;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
+import org.apache.fop.traits.Direction;
+import org.apache.fop.traits.WritingMode;
+import org.apache.fop.traits.WritingModeTraits;
+import org.apache.fop.traits.WritingModeTraitsGetter;
 
 /**
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_page-sequence">
  * <code>fo:page-sequence</code></a> object.
  */
-public class PageSequence extends AbstractPageSequence {
+public class PageSequence extends AbstractPageSequence implements WritingModeTraitsGetter {
 
-    // The value of properties relevant for fo:page-sequence.
+    // The value of FO traits (refined properties) that apply to fo:page-sequence.
     private String country;
     private String language;
     private String masterReference;
-    //private int writingMode; //XSL 1.1
-    // End of property values
+    private Numeric referenceOrientation;
+    private WritingModeTraits writingModeTraits;
+    // End of trait values
 
     // There doesn't seem to be anything in the spec requiring flows
     // to be in the order given, only that they map to the regions
@@ -86,8 +92,9 @@ public class PageSequence extends Abstra
         country = pList.get(PR_COUNTRY).getString();
         language = pList.get(PR_LANGUAGE).getString();
         masterReference = pList.get(PR_MASTER_REFERENCE).getString();
-        //writingMode = pList.getWritingMode();
-
+        referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric();
+        writingModeTraits = new WritingModeTraits
+            ( WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum()) );
         if (masterReference == null || masterReference.equals("")) {
             missingPropertyError("master-reference");
         }
@@ -292,8 +299,8 @@ public class PageSequence extends Abstra
     }
 
     /**
-     * Get the value of the <code>master-reference</code> property.
-     * @return the "master-reference" property
+     * Get the value of the <code>master-reference</code> trait.
+     * @return the "master-reference" trait
      */
     public String getMasterReference() {
         return masterReference;
@@ -313,22 +320,100 @@ public class PageSequence extends Abstra
     }
 
     /**
-     * Get the value of the <code>country</code> property.
-     * @return the country property value
+     * Get the value of the <code>country</code> trait.
+     * @return the country trait value
      */
     public String getCountry() {
         return this.country;
     }
 
     /**
-     * Get the value of the <code>language</code> property.
-     * @return the language property value
+     * Get the value of the <code>language</code> trait.
+     * @return the language trait value
      */
     public String getLanguage() {
         return this.language;
     }
 
     /**
+     * Get the value of the <code>reference-orientation</code> trait.
+     * @return the reference orientation trait value
+     */
+    public int getReferenceOrientation() {
+        if ( referenceOrientation != null ) {
+            return referenceOrientation.getValue();
+        } else {
+            return 0;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Direction getInlineProgressionDirection() {
+        if ( writingModeTraits != null ) {
+            return writingModeTraits.getInlineProgressionDirection();
+        } else {
+            return Direction.LR;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Direction getBlockProgressionDirection() {
+        if ( writingModeTraits != null ) {
+            return writingModeTraits.getBlockProgressionDirection();
+        } else {
+            return Direction.TB;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Direction getColumnProgressionDirection() {
+        if ( writingModeTraits != null ) {
+            return writingModeTraits.getColumnProgressionDirection();
+        } else {
+            return Direction.LR;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Direction getRowProgressionDirection() {
+        if ( writingModeTraits != null ) {
+            return writingModeTraits.getRowProgressionDirection();
+        } else {
+            return Direction.TB;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Direction getShiftDirection() {
+        if ( writingModeTraits != null ) {
+            return writingModeTraits.getShiftDirection();
+        } else {
+            return Direction.TB;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public WritingMode getWritingMode() {
+        if ( writingModeTraits != null ) {
+            return writingModeTraits.getWritingMode();
+        } else {
+            return WritingMode.LR_TB;
+        }
+    }
+
+    /**
      * Releases a page-sequence's children after the page-sequence has been fully processed.
      */
     public void releasePageSequence() {

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/Region.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/Region.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/Region.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/Region.java Thu Aug 19 19:46:41 2010
@@ -32,20 +32,21 @@ import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.traits.WritingMode;
 
 /**
  * This is an abstract base class for pagination regions.
  */
 public abstract class Region extends FObj {
-    // The value of properties relevant for fo:region
+    // The value of FO traits (refined properties) that apply to fo:region
     private CommonBorderPaddingBackground commonBorderPaddingBackground;
     // private ToBeImplementedProperty clip
     private int displayAlign;
     private int overflow;
     private String regionName;
     private Numeric referenceOrientation;
-    private int writingMode;
-    // End of property values
+    private WritingMode writingMode;
+    // End of FO trait values
 
     private SimplePageMaster layoutMaster;
 
@@ -67,7 +68,7 @@ public abstract class Region extends FOb
         overflow = pList.get(PR_OVERFLOW).getEnum();
         regionName = pList.get(PR_REGION_NAME).getString();
         referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric();
-        writingMode = pList.getWritingMode();
+        writingMode = WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum());
 
         // regions may have name, or default
         if (regionName.equals("")) {
@@ -170,28 +171,28 @@ public abstract class Region extends FOb
         return commonBorderPaddingBackground;
     }
 
-    /** @return the "region-name" property. */
+    /** @return the "region-name" FO trait. */
     public String getRegionName() {
         return regionName;
     }
 
-    /** @return the "writing-mode" property. */
-    public int getWritingMode() {
-        return writingMode;
-    }
-
-    /** @return the "overflow" property. */
+    /** @return the "overflow" FO trait. */
     public int getOverflow() {
         return overflow;
     }
 
-    /** @return the display-align property. */
+    /** @return the display-align FO trait. */
     public int getDisplayAlign() {
         return displayAlign;
     }
 
-    /** @return the "reference-orientation" property. */
+    /** @return the "reference-orientation" FO trait. */
     public int getReferenceOrientation() {
         return referenceOrientation.getValue();
     }
+
+    /** @return the "writing-mode" FO trait. */
+    public WritingMode getWritingMode() {
+        return writingMode;
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionAfter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionAfter.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionAfter.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionAfter.java Thu Aug 19 19:46:41 2010
@@ -23,6 +23,7 @@ package org.apache.fop.fo.pagination;
 import java.awt.Rectangle;
 
 // FOP
+import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.datatypes.FODimension;
 import org.apache.fop.datatypes.LengthBase;
@@ -52,14 +53,22 @@ public class RegionAfter extends RegionB
         PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
         PercentBaseContext neighbourContext;
         Rectangle vpRect;
-        if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
+
+        // [TBD] WRITING MODE ALERT
+        switch ( getWritingMode().getEnumValue() ) {
+        default:
+        case Constants.EN_LR_TB:
+        case Constants.EN_RL_TB:
             neighbourContext = pageWidthContext;
             vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageHeightContext)
                                    , reldims.ipd, getExtent().getValue(pageHeightContext));
-        } else {
+            break;
+        case Constants.EN_TB_LR:
+        case Constants.EN_TB_RL:
             neighbourContext = pageHeightContext;
             vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageWidthContext)
                                    , getExtent().getValue(pageWidthContext), reldims.ipd);
+            break;
         }
         if (getPrecedence() == EN_FALSE) {
             adjustIPD(vpRect, spm.getWritingMode(), neighbourContext);

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionBA.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionBA.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionBA.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionBA.java Thu Aug 19 19:46:41 2010
@@ -26,6 +26,7 @@ import org.apache.fop.apps.FOPException;
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.PropertyList;
+import org.apache.fop.traits.WritingMode;
 
 /**
  * Abstract base class for <a href="http://www.w3.org/TR/xsl/#fo_region-before">
@@ -70,7 +71,8 @@ public abstract class RegionBA extends S
      * @param wm writing mode
      * @param siblingContext the context to use to resolve extent on siblings
      */
-    protected void adjustIPD(Rectangle vpRefRect, int wm, PercentBaseContext siblingContext) {
+    protected void adjustIPD
+        ( Rectangle vpRefRect, WritingMode wm, PercentBaseContext siblingContext ) {
         int offset = 0;
         RegionStart start = (RegionStart) getSiblingRegion(FO_REGION_START);
         if (start != null) {
@@ -81,8 +83,9 @@ public abstract class RegionBA extends S
         if (end != null) {
             offset += end.getExtent().getValue(siblingContext);
         }
+        // [TBD] WRITING MODE ALERT
         if (offset > 0) {
-            if (wm == EN_LR_TB || wm == EN_RL_TB) {
+            if (wm == WritingMode.LR_TB || wm == WritingMode.RL_TB) {
                 vpRefRect.width -= offset;
             } else {
                 vpRefRect.height -= offset;

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionBefore.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionBefore.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionBefore.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionBefore.java Thu Aug 19 19:46:41 2010
@@ -23,6 +23,7 @@ package org.apache.fop.fo.pagination;
 import java.awt.Rectangle;
 
 // FOP
+import org.apache.fop.fo.Constants;
 import org.apache.fop.datatypes.FODimension;
 import org.apache.fop.datatypes.LengthBase;
 import org.apache.fop.datatypes.SimplePercentBaseContext;
@@ -73,12 +74,19 @@ public class RegionBefore extends Region
         }
         SimplePercentBaseContext neighbourContext;
         Rectangle vpRect;
-        if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
+        // [TBD] WRITING MODE ALERT
+        switch ( getWritingMode().getEnumValue() ) {
+        default:
+        case Constants.EN_LR_TB:
+        case Constants.EN_RL_TB:
             neighbourContext = pageWidthContext;
             vpRect = new Rectangle(0, 0, reldims.ipd, getExtent().getValue(pageHeightContext));
-        } else {
+            break;
+        case Constants.EN_TB_LR:
+        case Constants.EN_TB_RL:
             neighbourContext = pageHeightContext;
             vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.ipd);
+            break;
         }
         if (getPrecedence() == EN_FALSE) {
             adjustIPD(vpRect, spm.getWritingMode(), neighbourContext);

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionBody.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionBody.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionBody.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionBody.java Thu Aug 19 19:46:41 2010
@@ -28,9 +28,11 @@ import org.apache.fop.datatypes.Length;
 import org.apache.fop.datatypes.LengthBase;
 import org.apache.fop.datatypes.Numeric;
 import org.apache.fop.datatypes.PercentBaseContext;
+import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.properties.CommonMarginBlock;
+import org.apache.fop.traits.WritingMode;
 
 /**
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_region-body">
@@ -113,12 +115,22 @@ public class RegionBody extends Region {
 
         int start;
         int end;
-        if (spm.getWritingMode() == EN_LR_TB) { // Left-to-right
+        // [TBD] WRITING MODE ALERT
+        switch ( getWritingMode().getEnumValue() ) {
+        default:
+        case Constants.EN_LR_TB:
             start = commonMarginBlock.marginLeft.getValue(pageWidthContext);
             end = commonMarginBlock.marginRight.getValue(pageWidthContext);
-        } else { // all other supported modes are right-to-left
+            break;
+        case Constants.EN_RL_TB:
             start = commonMarginBlock.marginRight.getValue(pageWidthContext);
             end = commonMarginBlock.marginLeft.getValue(pageWidthContext);
+            break;
+        case Constants.EN_TB_LR:
+        case Constants.EN_TB_RL:
+            start = commonMarginBlock.marginTop.getValue(pageWidthContext);
+            end = commonMarginBlock.marginBottom.getValue(pageWidthContext);
+            break;
         }
         int before = commonMarginBlock.spaceBefore.getOptimum(pageHeightContext)
                         .getLength().getValue(pageHeightContext);

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionEnd.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionEnd.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionEnd.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionEnd.java Thu Aug 19 19:46:41 2010
@@ -23,6 +23,7 @@ package org.apache.fop.fo.pagination;
 import java.awt.Rectangle;
 
 // FOP
+import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.datatypes.FODimension;
 import org.apache.fop.datatypes.LengthBase;
@@ -52,17 +53,24 @@ public class RegionEnd extends RegionSE 
         PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
         PercentBaseContext neighbourContext;
         Rectangle vpRect;
-        if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
+        // [TBD] WRITING MODE ALERT
+        switch ( getWritingMode().getEnumValue() ) {
+        default:
+        case Constants.EN_LR_TB:
+        case Constants.EN_RL_TB:
             neighbourContext = pageHeightContext;
             vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageWidthContext), 0,
                     getExtent().getValue(pageWidthContext), reldims.bpd);
-        } else {
+            break;
+        case Constants.EN_TB_LR:
+        case Constants.EN_TB_RL:
             // Rectangle:  x , y (of top left point), width, height
             neighbourContext = pageWidthContext;
             vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageHeightContext), 0,
                     reldims.bpd, getExtent().getValue(pageHeightContext));
+            break;
         }
-        adjustIPD(vpRect, spm.getWritingMode(), neighbourContext);
+        adjustIPD(vpRect, getWritingMode(), neighbourContext);
         return vpRect;
     }
 

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionSE.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionSE.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionSE.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionSE.java Thu Aug 19 19:46:41 2010
@@ -26,6 +26,7 @@ import org.apache.fop.apps.FOPException;
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.PropertyList;
+import org.apache.fop.traits.WritingMode;
 
 /**
  * Abstract base class for <a href="http://www.w3.org/TR/xsl/#fo_region-start">
@@ -61,7 +62,8 @@ public abstract class RegionSE extends S
      * @param wm writing mode
      * @param siblingContext the context to use to resolve extent on siblings
      */
-    protected void adjustIPD(Rectangle vpRefRect, int wm, PercentBaseContext siblingContext) {
+    protected void adjustIPD
+        ( Rectangle vpRefRect, WritingMode wm, PercentBaseContext siblingContext ) {
         int offset = 0;
         RegionBefore before = (RegionBefore) getSiblingRegion(FO_REGION_BEFORE);
         if (before != null && before.getPrecedence() == EN_TRUE) {
@@ -72,8 +74,9 @@ public abstract class RegionSE extends S
         if (after != null && after.getPrecedence() == EN_TRUE) {
             offset += after.getExtent().getValue(siblingContext);
         }
+        // [TBD] WRITING MODE ALERT
         if (offset > 0) {
-            if (wm == EN_LR_TB || wm == EN_RL_TB) {
+            if (wm == WritingMode.LR_TB || wm == WritingMode.RL_TB) {
                 vpRefRect.height -= offset;
             } else {
                 vpRefRect.width -= offset;

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionStart.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionStart.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionStart.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/RegionStart.java Thu Aug 19 19:46:41 2010
@@ -23,6 +23,7 @@ package org.apache.fop.fo.pagination;
 import java.awt.Rectangle;
 
 // FOP
+import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.datatypes.FODimension;
 import org.apache.fop.datatypes.LengthBase;
@@ -52,12 +53,19 @@ public class RegionStart extends RegionS
         PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
         PercentBaseContext neighbourContext;
         Rectangle vpRect;
-        if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
+        // [TBD] WRITING MODE ALERT
+        switch ( getWritingMode().getEnumValue() ) {
+        default:
+        case Constants.EN_LR_TB:
+        case Constants.EN_RL_TB:
             neighbourContext = pageHeightContext;
             vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.bpd);
-        } else {
+            break;
+        case Constants.EN_TB_LR:
+        case Constants.EN_TB_RL:
             neighbourContext = pageWidthContext;
             vpRect = new Rectangle(0, 0, reldims.bpd, getExtent().getValue(pageHeightContext));
+            break;
         }
         adjustIPD(vpRect, spm.getWritingMode(), neighbourContext);
         return vpRect;

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java Thu Aug 19 19:46:41 2010
@@ -36,6 +36,7 @@ import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
 import org.apache.fop.fo.properties.CommonMarginBlock;
+import org.apache.fop.traits.WritingMode;
 
 /**
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_simple-page-master">
@@ -44,14 +45,14 @@ import org.apache.fop.fo.properties.Comm
  * and attributes.
  */
 public class SimplePageMaster extends FObj {
-    // The value of properties relevant for fo:simple-page-master.
+    // The value of FO traits (refined properties) that apply to fo:simple-page-master.
     private CommonMarginBlock commonMarginBlock;
     private String masterName;
     private Length pageHeight;
     private Length pageWidth;
     private Numeric referenceOrientation;
-    private int writingMode;
-    // End of property values
+    private WritingMode writingMode;
+    // End of FO trait values
 
     /**
      * Page regions (regionClass, Region)
@@ -81,7 +82,7 @@ public class SimplePageMaster extends FO
         pageHeight = pList.get(PR_PAGE_HEIGHT).getLength();
         pageWidth = pList.get(PR_PAGE_WIDTH).getLength();
         referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric();
-        writingMode = pList.getWritingMode();
+        writingMode = WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum());
 
         if (masterName == null || masterName.equals("")) {
             missingPropertyError("master-name");
@@ -273,31 +274,31 @@ public class SimplePageMaster extends FO
         return commonMarginBlock;
     }
 
-    /** @return "master-name" property. */
+    /** @return "master-name" FO trait. */
     public String getMasterName() {
         return masterName;
     }
 
-    /** @return the "page-width" property. */
+    /** @return the "page-width" FO trait. */
     public Length getPageWidth() {
         return pageWidth;
     }
 
-    /** @return the "page-height" property. */
+    /** @return the "page-height" FO trait. */
     public Length getPageHeight() {
         return pageHeight;
     }
 
-    /** @return the "writing-mode" property. */
-    public int getWritingMode() {
-        return writingMode;
-    }
-
-    /** @return the "reference-orientation" property. */
+    /** @return the "reference-orientation" FO trait. */
     public int getReferenceOrientation() {
         return referenceOrientation.getValue();
     }
 
+    /** @return the "writing-mode" FO trait. */
+    public WritingMode getWritingMode() {
+        return writingMode;
+    }
+
     /** {@inheritDoc} */
     public String getLocalName() {
         return "simple-page-master";

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java Thu Aug 19 19:46:41 2010
@@ -35,6 +35,8 @@ public class CorrespondingPropertyMaker 
     protected int rltb;
     /** corresponding property for tb-rl writing mode */
     protected int tbrl;
+    /** corresponding property for tb-lr writing mode */
+    protected int tblr;
     /** user parent property list */
     protected boolean useParent;
     private boolean relative;
@@ -48,17 +50,26 @@ public class CorrespondingPropertyMaker 
         baseMaker.setCorresponding(this);
     }
 
+    /**
+     * Set corresponding property values.
+     * @param lrtb a corresponding value
+     * @param rltb a corresponding value
+     * @param tbrl a corresponding value
+     * @param tblr a corresponding value
+     */
 
     /**
      * Set corresponding property identifiers.
      * @param lrtb the property that corresponds with lr-tb writing mode
      * @param rltb the property that corresponds with rl-tb writing mode
      * @param tbrl the property that corresponds with tb-lr writing mode
+     * @param tblr the property that corresponds with tb-lr writing mode
      */
-    public void setCorresponding(int lrtb, int rltb, int tbrl) {
+    public void setCorresponding(int lrtb, int rltb, int tbrl, int tblr) {
         this.lrtb = lrtb;
         this.rltb = rltb;
         this.tbrl = tbrl;
+        this.tblr = tblr;
     }
 
     /**
@@ -72,7 +83,7 @@ public class CorrespondingPropertyMaker 
 
     /**
      * Set relative flag.
-     * @param relative true if relative direction
+     * @param relative true if properties operate on a relative direction
      */
     public void setRelative(boolean relative) {
         this.relative = relative;
@@ -102,7 +113,7 @@ public class CorrespondingPropertyMaker 
 
         PropertyList pList = getWMPropertyList(propertyList);
         if (pList != null) {
-            int correspondingId = pList.getWritingMode(lrtb, rltb, tbrl);
+            int correspondingId = pList.selectFromWritingMode(lrtb, rltb, tbrl, tblr);
 
             if (pList.getExplicit(correspondingId) != null) {
                 return true;
@@ -126,7 +137,7 @@ public class CorrespondingPropertyMaker 
         if (pList == null) {
             return null;
         }
-        int correspondingId = pList.getWritingMode(lrtb, rltb, tbrl);
+        int correspondingId = pList.selectFromWritingMode(lrtb, rltb, tbrl, tblr);
 
         Property p = propertyList.getExplicitOrShorthand(correspondingId);
         if (p != null) {

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java Thu Aug 19 19:46:41 2010
@@ -30,11 +30,11 @@ import org.apache.fop.fo.expr.PropertyEx
  * Window - Preferences - Java - Code Generation - Code and Comments
  */
 public class DimensionPropertyMaker extends CorrespondingPropertyMaker {
-    
-    private int[][] extraCorresponding = null;
+
+    private int[][] extraCorresponding;
 
     /**
-     * Construct a dimension property maker.
+     * Instantiate a dimension property maker.
      * @param baseMaker the base property maker
      */
     public DimensionPropertyMaker(PropertyMaker baseMaker) {
@@ -43,9 +43,18 @@ public class DimensionPropertyMaker exte
 
     /**
      * Set extra correspondences.
-     * @param extraCorresponding the extra correspondences
+     * @param extraCorresponding an array of four element integer arrays
      */
     public void setExtraCorresponding(int[][] extraCorresponding) {
+        if ( extraCorresponding == null ) {
+            throw new NullPointerException();
+        }
+        for ( int i = 0; i < extraCorresponding.length; i++ ) {
+            int[] eca = extraCorresponding[i];
+            if ( ( eca == null ) || ( eca.length != 4 ) ) {
+                throw new IllegalArgumentException ( "bad sub-array @ [" + i + "]" );
+            }
+        }
         this.extraCorresponding = extraCorresponding;
     }
 
@@ -76,18 +85,20 @@ public class DimensionPropertyMaker exte
         }
 
         // Based on min-[width|height]
-        int wmcorr = propertyList.getWritingMode(extraCorresponding[0][0],
+        int wmcorr = propertyList.selectFromWritingMode(extraCorresponding[0][0],
                                         extraCorresponding[0][1],
-                                        extraCorresponding[0][2]);
+                                        extraCorresponding[0][2],
+                                        extraCorresponding[0][3]);
         Property subprop = propertyList.getExplicitOrShorthand(wmcorr);
         if (subprop != null) {
             baseMaker.setSubprop(p, Constants.CP_MINIMUM, subprop);
         }
 
         // Based on max-[width|height]
-        wmcorr = propertyList.getWritingMode(extraCorresponding[1][0],
+        wmcorr = propertyList.selectFromWritingMode(extraCorresponding[1][0],
                                     extraCorresponding[1][1],
-                                    extraCorresponding[1][2]);
+                                    extraCorresponding[1][2],
+                                    extraCorresponding[1][3]);
         subprop = propertyList.getExplicitOrShorthand(wmcorr);
         // TODO: Don't set when NONE.
         if (subprop != null) {

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java Thu Aug 19 19:46:41 2010
@@ -55,6 +55,9 @@ public class IndentPropertyMaker extends
      * @param paddingCorresponding the corresping propids.
      */
     public void setPaddingCorresponding(int[] paddingCorresponding) {
+        if ( ( paddingCorresponding == null ) || ( paddingCorresponding.length != 4 ) ) {
+            throw new IllegalArgumentException();
+        }
         this.paddingCorresponding = paddingCorresponding;
     }
 
@@ -63,6 +66,9 @@ public class IndentPropertyMaker extends
      * @param borderWidthCorresponding the corresping propids.
      */
     public void setBorderWidthCorresponding(int[] borderWidthCorresponding) {
+        if ( ( borderWidthCorresponding == null ) || ( borderWidthCorresponding.length != 4 ) ) {
+            throw new IllegalArgumentException();
+        }
         this.borderWidthCorresponding = borderWidthCorresponding;
     }
 
@@ -99,7 +105,7 @@ public class IndentPropertyMaker extends
         Numeric padding = getCorresponding(paddingCorresponding, propertyList).getNumeric();
         Numeric border = getCorresponding(borderWidthCorresponding, propertyList).getNumeric();
 
-        int marginProp = pList.getWritingMode(lrtb, rltb, tbrl);
+        int marginProp = pList.selectFromWritingMode(lrtb, rltb, tbrl, tblr);
         // Calculate the absolute margin.
         if (propertyList.getExplicitOrShorthand(marginProp) == null) {
             Property indent = propertyList.getExplicit(baseMaker.propId);
@@ -158,7 +164,7 @@ public class IndentPropertyMaker extends
         Numeric padding = getCorresponding(paddingCorresponding, propertyList).getNumeric();
         Numeric border = getCorresponding(borderWidthCorresponding, propertyList).getNumeric();
 
-        int marginProp = pList.getWritingMode(lrtb, rltb, tbrl);
+        int marginProp = pList.selectFromWritingMode(lrtb, rltb, tbrl, tblr);
 
         //Determine whether the nearest anscestor indent was specified through
         //start-indent|end-indent or through a margin property.
@@ -208,7 +214,8 @@ public class IndentPropertyMaker extends
                 throws PropertyException {
         PropertyList pList = getWMPropertyList(propertyList);
         if (pList != null) {
-            int wmcorr = pList.getWritingMode(corresponding[0], corresponding[1], corresponding[2]);
+            int wmcorr = pList.selectFromWritingMode
+                ( corresponding[0], corresponding[1], corresponding[2], corresponding[3] );
             return propertyList.get(wmcorr);
         } else {
             return null;

Added: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/ArabicScriptProcessor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/ArabicScriptProcessor.java?rev=987282&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/ArabicScriptProcessor.java (added)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/ArabicScriptProcessor.java Thu Aug 19 19:46:41 2010
@@ -0,0 +1,527 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fonts;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.text.bidi.BidiClassUtils;
+import org.apache.fop.util.BidiConstants;
+
+// CSOFF: AvoidNestedBlocksCheck
+// CSOFF: NoWhitespaceAfterCheck
+// CSOFF: InnerAssignmentCheck
+// CSOFF: SimplifyBooleanReturnCheck
+// CSOFF: LineLengthCheck
+
+/**
+ * <p>The <code>ArabicScriptProcessor</code> class implements script processor for
+ * performing glypph substitution and positioning operations on content associated with the Arabic script.</p>
+ * @author Glenn Adams
+ */
+public class ArabicScriptProcessor extends ScriptProcessor {
+
+    /**
+     * logging instance
+     */
+    protected static final Log log = LogFactory.getLog(ArabicScriptProcessor.class);                                    // CSOK: ConstantNameCheck
+
+    ArabicScriptProcessor ( String script ) {
+        super ( script );
+    }
+
+    /** {@inheritDoc} */
+    public GlyphSequence substitute ( GlyphSequence gs, String script, String language, Map/*<LookupSpec,GlyphSubtable[]>*/ lookups ) {
+        // finals
+        gs = subFina ( gs, script, language, (GlyphSubtable[]) lookups.get ( new GlyphTable.LookupSpec ( script, language, "fina" ) ) );
+
+        // medials
+        gs = subMedi ( gs, script, language, (GlyphSubtable[]) lookups.get ( new GlyphTable.LookupSpec ( script, language, "medi" ) ) );
+
+        // initials
+        gs = subInit ( gs, script, language, (GlyphSubtable[]) lookups.get ( new GlyphTable.LookupSpec ( script, language, "init" ) ) );
+
+        // isolates
+        gs = subIsol ( gs, script, language, (GlyphSubtable[]) lookups.get ( new GlyphTable.LookupSpec ( script, language, "isol" ) ) );
+
+        // required ligatures
+        gs = subLiga ( gs, script, language, (GlyphSubtable[]) lookups.get ( new GlyphTable.LookupSpec ( script, language, "rlig" ) ) );
+
+        // standard ligatures
+        gs = subLiga ( gs, script, language, (GlyphSubtable[]) lookups.get ( new GlyphTable.LookupSpec ( script, language, "liga" ) ) );
+
+        return gs;
+    }
+
+    /** {@inheritDoc} */
+    public int[] position ( GlyphSequence gs, String script, String language, Map/*<LookupSpec,GlyphSubtable[]>*/ lookups ) {
+        return null;
+    }
+
+    private static GlyphContextTester finalContextTester
+        = new GlyphContextTester() { public boolean test ( GlyphSequence gs, GlyphSequence.CharAssociation ca ) { return inFinalContext ( gs, ca ); } };
+
+    private GlyphSequence subFina ( GlyphSequence gs, String script, String language, GlyphSubtable[] sta ) {
+        return substituteSingle ( gs, script, language, "fina", sta, finalContextTester, false );
+    }
+
+    private static GlyphContextTester medialContextTester
+        = new GlyphContextTester() { public boolean test ( GlyphSequence gs, GlyphSequence.CharAssociation ca ) { return inMedialContext ( gs, ca ); } };
+
+    private GlyphSequence subMedi ( GlyphSequence gs, String script, String language, GlyphSubtable[] sta ) {
+        return substituteSingle ( gs, script, language, "medi", sta, medialContextTester, false );
+    }
+    
+    private static GlyphContextTester initialContextTester
+        = new GlyphContextTester() { public boolean test ( GlyphSequence gs, GlyphSequence.CharAssociation ca ) { return inInitialContext ( gs, ca ); } };
+
+    private GlyphSequence subInit ( GlyphSequence gs, String script, String language, GlyphSubtable[] sta ) {
+        return substituteSingle ( gs, script, language, "init", sta, initialContextTester, false );
+    }
+    
+    private static GlyphContextTester isolateContextTester
+        = new GlyphContextTester() { public boolean test ( GlyphSequence gs, GlyphSequence.CharAssociation ca ) { return inIsolateContext ( gs, ca ); } };
+
+    private GlyphSequence subIsol ( GlyphSequence gs, String script, String language, GlyphSubtable[] sta ) {
+        return substituteSingle ( gs, script, language, "isol", sta, isolateContextTester, false );
+    }
+    
+    private static GlyphContextTester ligatureContextTester
+        = new GlyphContextTester() { public boolean test ( GlyphSequence gs, GlyphSequence.CharAssociation ca ) { return inLigatureContext ( gs, ca ); } };
+
+    private GlyphSequence subLiga ( GlyphSequence gs, String script, String language, GlyphSubtable[] sta ) {
+        return substituteMultiple ( gs, script, language, "liga", sta, ligatureContextTester, false );
+    }
+
+    private GlyphSequence substituteSingle ( GlyphSequence gs, String script, String language, String feature, GlyphSubtable[] sta, GlyphContextTester tester, boolean reverse ) {
+        if ( ( sta != null ) && ( sta.length > 0 ) ) {
+            // enforce subtable type constraints
+            for ( int i = 0, n = sta.length; i < n; i++ ) {
+                GlyphSubtable st = sta [ i ];
+                if ( ! ( st instanceof GlyphSubstitutionSubtable ) ) {
+                    throw new IncompatibleSubtableException ( "'" + feature + "' feature requires glyph substitution subtable" );
+                }
+            }
+            CharSequence ga = gs.getGlyphs();
+            GlyphSequence.CharAssociation[] aa = gs.getAssociations();
+            List gsl = new ArrayList();
+            List cal = new ArrayList();
+            for ( int i = 0, n = ga.length(); i < n; i++ ) {
+                int k = reverse ? ( n - i - 1 ) : i;
+                GlyphSequence.CharAssociation a = aa [ k ];
+                GlyphSequence iss = gs.getGlyphSubsequence ( k, k + 1 );
+                GlyphSequence oss;
+                if ( tester.test ( iss, a ) ) {
+                    oss = doSubstitutions ( iss, script, language, sta );
+                } else {
+                    oss = iss;
+                }
+                gsl.add ( oss );
+                cal.add ( a );
+            }
+            gs = new GlyphSequence ( gs.getCharacters(), gsl, cal, reverse );
+        }
+        return gs;
+    }
+
+    private GlyphSequence substituteMultiple ( GlyphSequence gs, String script, String language, String feature, GlyphSubtable[] sta, GlyphContextTester tester, boolean reverse ) {
+        if ( ( sta != null ) && ( sta.length > 0 ) ) {
+            gs = doSubstitutions ( gs, script, language, sta );
+        }
+        return gs;
+    }
+
+    private GlyphSequence doSubstitutions ( GlyphSequence gs, String script, String language, GlyphSubtable[] sta ) {
+        for ( int i = 0, n = sta.length; i < n; i++ ) {
+            GlyphSubtable st = sta [ i ];
+            assert st instanceof GlyphSubstitutionSubtable;
+            gs = ( (GlyphSubstitutionSubtable) st ) . substitute ( gs, script, language );
+        }
+        return gs;
+    }
+
+    private static boolean inFinalContext ( GlyphSequence gs, GlyphSequence.CharAssociation a ) {
+        CharSequence cs = gs.getCharacters();
+        if ( cs.length() == 0 ) {
+            return false;
+        } else {
+            int s = a.getStart();
+            int e = a.getEnd();
+            if ( ! hasFinalPrecedingContext ( cs, s, e ) ) {
+                return false;
+            } else if ( forcesFinalThisContext ( cs, s, e ) ) {
+                if (log.isDebugEnabled()) {
+                    log.debug ( "+FIN: [" + a.getStart() + "," + a.getEnd() + "]: " + GlyphUtils.toString ( (CharSequence) gs ) );
+                }
+                return true;
+            } else if ( ! hasFinalFollowingContext ( cs, s, e ) ) {
+                return false;
+            } else {
+                if (log.isDebugEnabled()) {
+                    log.debug ( "+FIN: [" + a.getStart() + "," + a.getEnd() + "]: " + GlyphUtils.toString ( (CharSequence) gs ) );
+                }
+                return true;
+            }
+        }
+    }
+
+    private static boolean inMedialContext ( GlyphSequence gs, GlyphSequence.CharAssociation a ) {
+        CharSequence cs = gs.getCharacters();
+        if ( cs.length() == 0 ) {
+            return false;
+        } else {
+            int s = a.getStart();
+            int e = a.getEnd();
+            if ( ! hasMedialPrecedingContext ( cs, s, e ) ) {
+                return false;
+            } else if ( ! hasMedialThisContext ( cs, s, e ) ) {
+                return false;
+            } else if ( ! hasMedialFollowingContext ( cs, s, e ) ) {
+                return false;
+            } else {
+                if (log.isDebugEnabled()) {
+                    log.debug ( "+MED: [" + a.getStart() + "," + a.getEnd() + "]: " + GlyphUtils.toString ( (CharSequence) gs ) );
+                }
+                return true;
+            }
+        }
+    }
+
+    private static boolean inInitialContext ( GlyphSequence gs, GlyphSequence.CharAssociation a ) {
+        CharSequence cs = gs.getCharacters();
+        if ( cs.length() == 0 ) {
+            return false;
+        } else {
+            int s = a.getStart();
+            int e = a.getEnd();
+            if ( ! hasInitialPrecedingContext ( cs, s, e ) ) {
+                return false;
+            } else if ( ! hasInitialFollowingContext ( cs, s, e ) ) {
+                return false;
+            } else {
+                if (log.isDebugEnabled()) {
+                    log.debug ( "+INI: [" + a.getStart() + "," + a.getEnd() + "]: " + GlyphUtils.toString ( (CharSequence) gs ) );
+                }
+                return true;
+            }
+        }
+    }
+
+    private static boolean inIsolateContext ( GlyphSequence gs, GlyphSequence.CharAssociation a ) {
+        CharSequence cs = gs.getCharacters();
+        int n;
+        if ( ( n = cs.length() ) == 0 ) {
+            return false;
+        } else if ( ( a.getStart() == 0 ) && ( a.getEnd() == n ) ) {
+            if (log.isDebugEnabled()) {
+                log.debug ( "+ISO: [" + a.getStart() + "," + a.getEnd() + "]: " + GlyphUtils.toString ( (CharSequence) gs ) );
+            }
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private static boolean inLigatureContext ( GlyphSequence gs, GlyphSequence.CharAssociation a ) {
+        CharSequence cs = gs.getCharacters();
+        if ( cs.length() == 0 ) {
+            return false;
+        } else {
+            int s = a.getStart();
+            int e = a.getEnd();
+            if ( ! hasLigaturePrecedingContext ( cs, s, e ) ) {
+                return false;
+            } else if ( ! hasLigatureFollowingContext ( cs, s, e ) ) {
+                return false;
+            } else {
+                if (log.isDebugEnabled()) {
+                    log.debug ( "+LIG: [" + a.getStart() + "," + a.getEnd() + "]: " + GlyphUtils.toString ( (CharSequence) gs ) );
+                }
+                return true;
+            }
+        }
+    }
+
+    private static boolean hasFinalPrecedingContext ( CharSequence cs, int s, int e ) {
+        int chp = 0;
+        int clp = 0;
+        for ( int i = s; i > 0; i-- ) {
+            chp = cs.charAt ( i - 1 );
+            clp = BidiClassUtils.getBidiClass ( chp );
+            if ( clp != BidiConstants.NSM ) {
+                break;
+            }
+        }
+        if ( clp != BidiConstants.AL ) {
+            return false;
+        } else if ( hasIsolateInitial ( chp ) ) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    private static boolean forcesFinalThisContext ( CharSequence cs, int s, int e ) {
+        int chl = 0;
+        int cll = 0;
+        for ( int i = 0, n = e - s; i < n; i++ ) {
+            int k = n - i - 1;
+            chl = cs.charAt ( s + k );
+            cll = BidiClassUtils.getBidiClass ( chl );
+            if ( cll != BidiConstants.NSM ) {
+                break;
+            }
+        }
+        if ( cll != BidiConstants.AL ) {
+            return false;
+        }
+        if ( hasIsolateInitial ( chl ) ) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private static boolean hasFinalFollowingContext ( CharSequence cs, int s, int e ) {
+        int chf = 0;
+        int clf = 0;
+        for ( int i = e, n = cs.length(); i < n; i++ ) {
+            chf = cs.charAt ( i );
+            clf = BidiClassUtils.getBidiClass ( chf );
+            if ( clf != BidiConstants.NSM ) {
+                break;
+            }
+        }
+        if ( clf != BidiConstants.AL ) {
+            return true;
+        } else if ( hasIsolateFinal ( chf ) ) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private static boolean hasInitialPrecedingContext ( CharSequence cs, int s, int e ) {
+        int chp = 0;
+        int clp = 0;
+        for ( int i = s; i > 0; i-- ) {
+            chp = cs.charAt ( i - 1 );
+            clp = BidiClassUtils.getBidiClass ( chp );
+            if ( clp != BidiConstants.NSM ) {
+                break;
+            }
+        }
+        if ( clp != BidiConstants.AL ) {
+            return true;
+        } else if ( hasIsolateInitial ( chp ) ) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private static boolean hasInitialFollowingContext ( CharSequence cs, int s, int e ) {
+        int chf = 0;
+        int clf = 0;
+        for ( int i = e, n = cs.length(); i < n; i++ ) {
+            chf = cs.charAt ( i );
+            clf = BidiClassUtils.getBidiClass ( chf );
+            if ( clf != BidiConstants.NSM ) {
+                break;
+            }
+        }
+        if ( clf != BidiConstants.AL ) {
+            return false;
+        } else if ( hasIsolateFinal ( chf ) ) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    private static boolean hasMedialPrecedingContext ( CharSequence cs, int s, int e ) {
+        int chp = 0;
+        int clp = 0;
+        for ( int i = s; i > 0; i-- ) {
+            chp = cs.charAt ( i - 1 );
+            clp = BidiClassUtils.getBidiClass ( chp );
+            if ( clp != BidiConstants.NSM ) {
+                break;
+            }
+        }
+        if ( clp != BidiConstants.AL ) {
+            return false;
+        } else if ( hasIsolateInitial ( chp ) ) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    private static boolean hasMedialThisContext ( CharSequence cs, int s, int e ) {
+        int chf = 0;
+        int clf = 0;
+        for ( int i = 0, n = e - s; i < n; i++ ) {
+            chf = cs.charAt ( s + i );
+            clf = BidiClassUtils.getBidiClass ( chf );
+            if ( clf != BidiConstants.NSM ) {
+                break;
+            }
+        }
+        if ( clf != BidiConstants.AL ) {
+            return false;
+        }
+        int chl = 0;
+        int cll = 0;
+        for ( int i = 0, n = e - s; i < n; i++ ) {
+            int k = n - i - 1;
+            chl = cs.charAt ( s + k );
+            cll = BidiClassUtils.getBidiClass ( chl );
+            if ( cll != BidiConstants.NSM ) {
+                break;
+            }
+        }
+        if ( cll != BidiConstants.AL ) {
+            return false;
+        }
+        if ( hasIsolateFinal ( chf ) ) {
+            return false;
+        } else if ( hasIsolateInitial ( chl ) ) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    private static boolean hasMedialFollowingContext ( CharSequence cs, int s, int e ) {
+        int chf = 0;
+        int clf = 0;
+        for ( int i = e, n = cs.length(); i < n; i++ ) {
+            chf = cs.charAt ( i );
+            clf = BidiClassUtils.getBidiClass ( chf );
+            if ( clf != BidiConstants.NSM ) {
+                break;
+            }
+        }
+        if ( clf != BidiConstants.AL ) {
+            return false;
+        } else if ( hasIsolateFinal ( chf ) ) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    private static boolean hasLigaturePrecedingContext ( CharSequence cs, int s, int e ) {
+        return true;
+    }
+
+    private static boolean hasLigatureFollowingContext ( CharSequence cs, int s, int e ) {
+        int chf = 0;
+        int clf = 0;
+        for ( int i = e, n = cs.length(); i < n; i++ ) {
+            chf = cs.charAt ( i );
+            clf = BidiClassUtils.getBidiClass ( chf );
+            if ( clf != BidiConstants.NSM ) {
+                break;
+            }
+        }
+        if ( clf == BidiConstants.AL ) {
+            return true;
+        } else  {
+            return false;
+        }
+    }
+
+    /**
+     * Ordered array of Unicode scalars designating those Arabic (Script) Letters
+     * which exhibit an isolated form in word initial position.
+     */
+    private static int[] isolatedInitials = {
+        0x0621, // HAMZA
+        0x0622, // ALEF WITH MADDA ABOVE
+        0x0623, // ALEF WITH HAMZA ABOVE
+        0x0624, // WAW WITH HAMZA ABOVE
+        0x0625, // ALEF WITH HAMZA BELOWW
+        0x0627, // ALEF
+        0x062F, // DAL
+        0x0630, // THAL
+        0x0631, // REH
+        0x0632, // ZAIN
+        0x0648, // WAW
+        0x0671, // ALEF WASLA
+        0x0672, // ALEF WITH WAVY HAMZA ABOVE
+        0x0673, // ALEF WITH WAVY HAMZA BELOW
+        0x0675, // HIGH HAMZA ALEF
+        0x0676, // HIGH HAMZA WAW
+        0x0677, // U WITH HAMZA ABOVE
+        0x0688, // DDAL
+        0x0689, // DAL WITH RING
+        0x068A, // DAL WITH DOT BELOW
+        0x068B, // DAL WITH DOT BELOW AND SMALL TAH
+        0x068C, // DAHAL
+        0x068D, // DDAHAL
+        0x068E, // DUL
+        0x068F, // DUL WITH THREE DOTS ABOVE DOWNWARDS
+        0x0690, // DUL WITH FOUR DOTS ABOVE
+        0x0691, // RREH
+        0x0692, // REH WITH SMALL V
+        0x0693, // REH WITH RING
+        0x0694, // REH WITH DOT BELOW
+        0x0695, // REH WITH SMALL V BELOW
+        0x0696, // REH WITH DOT BELOW AND DOT ABOVE
+        0x0697, // REH WITH TWO DOTS ABOVE
+        0x0698, // JEH
+        0x0699, // REH WITH FOUR DOTS ABOVE
+        0x06C4, // WAW WITH RING
+        0x06C5, // KIRGHIZ OE
+        0x06C6, // OE
+        0x06C7, // U
+        0x06C8, // YU
+        0x06C9, // KIRGHIZ YU
+        0x06CA, // WAW WITH TWO DOTS ABOVE
+        0x06CB, // VE
+        0x06CF, // WAW WITH DOT ABOVE
+        0x06EE, // DAL WITH INVERTED V
+        0x06EF  // REH WITH INVERTED V
+    };
+
+    private static boolean hasIsolateInitial ( int ch ) {
+        return Arrays.binarySearch ( isolatedInitials, ch ) >= 0;
+    }
+
+    /**
+     * Ordered array of Unicode scalars designating those Arabic (Script) Letters
+     * which exhibit an isolated form in word final position.
+     */
+    private static int[] isolatedFinals = {
+        0x0621  // HAMZA
+    };
+
+    private static boolean hasIsolateFinal ( int ch ) {
+        return Arrays.binarySearch ( isolatedFinals, ch ) >= 0;
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/ArabicScriptProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/ArabicScriptProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFont.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFont.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/CustomFont.java Thu Aug 19 19:46:41 2010
@@ -58,6 +58,7 @@ public abstract class CustomFont extends
     private Map kerning;
 
     private boolean useKerning = true;
+    private boolean useAdvanced = true;
 
     /** {@inheritDoc} */
     public String getFontName() {
@@ -283,6 +284,15 @@ public abstract class CustomFont extends
         }
     }
 
+    /**
+     * Used to determine if advanced typographic features are enabled.
+     * By default, this is false, but may be overridden by subclasses.
+     * @return true if enabled.
+     */
+    public boolean isAdvancedEnabled() {
+        return useAdvanced;
+    }
+
     /* ---- MutableFont interface ---- */
 
     /** {@inheritDoc} */
@@ -426,6 +436,13 @@ public abstract class CustomFont extends
     }
 
     /**
+     * {@inheritDoc}
+     */
+    public void setAdvancedEnabled(boolean enabled) {
+        this.useAdvanced = enabled;
+    }
+
+    /**
      * Sets the font resolver. Needed for URI resolution.
      * @param resolver the font resolver
      */

Added: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/DefaultScriptProcessor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/DefaultScriptProcessor.java?rev=987282&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/DefaultScriptProcessor.java (added)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/DefaultScriptProcessor.java Thu Aug 19 19:46:41 2010
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fonts;
+
+import java.util.Map;
+
+// CSOFF: LineLengthCheck
+
+/**
+ * Default script processor, which performs the identity substitution and produces no positioning information.
+ * @author Glenn Adams
+ */
+public class DefaultScriptProcessor extends ScriptProcessor {
+
+    DefaultScriptProcessor ( String script ) {
+        super ( script );
+    }
+
+    /** {@inheritDoc} */
+    public GlyphSequence substitute ( GlyphSequence gs, String script, String language, Map/*<LookupSpec,GlyphSubtable[]>*/ lookups ) {
+        return gs;
+    }
+
+    /** {@inheritDoc} */
+    public int[] position ( GlyphSequence cs, String script, String language, Map/*<LookupSpec,GlyphSubtable[]>*/ lookups ) {
+        return null;
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/DefaultScriptProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/DefaultScriptProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/DiscontinuousAssociationException.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/DiscontinuousAssociationException.java?rev=987282&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/DiscontinuousAssociationException.java (added)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/DiscontinuousAssociationException.java Thu Aug 19 19:46:41 2010
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fonts;
+
+/**
+ * Exception thrown during when attempting to map glyphs to associated characters
+ * in the case that the associated characters do not represent a compact interval.
+ * @author Glenn Adams
+ */
+public class DiscontinuousAssociationException extends RuntimeException {
+    /**
+     * Instantiate discontinuous association exception
+     */
+    public DiscontinuousAssociationException() {
+        super();
+    }
+    /**
+     * Instantiate discontinuous association exception
+     * @param message a message string
+     */
+    public DiscontinuousAssociationException(String message) {
+        super(message);
+    }
+}

Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/DiscontinuousAssociationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/DiscontinuousAssociationException.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/EmbedFontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/EmbedFontInfo.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/EmbedFontInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/EmbedFontInfo.java Thu Aug 19 19:46:41 2010
@@ -37,6 +37,8 @@ public class EmbedFontInfo implements Se
     protected String embedFile;
     /** false, to disable kerning */
     protected boolean kerning;
+    /** false, to disable advanced typographic features */
+    protected boolean advanced;
     /** the requested encoding mode for the font */
     protected EncodingMode encodingMode = EncodingMode.AUTO;
 
@@ -52,17 +54,19 @@ public class EmbedFontInfo implements Se
 
     /**
      * Main constructor
-     * @param metricsFile Path to the xml file containing font metrics
-     * @param kerning True if kerning should be enabled
-     * @param fontTriplets List of font triplets to associate with this font
-     * @param embedFile Path to the embeddable font file (may be null)
+     * @param metricsFile path to the xml file containing font metrics
+     * @param kerning true if kerning should be enabled
+     * @param advanced true if advanced typography features should be enabled
+     * @param fontTriplets list of font triplets to associate with this font
+     * @param embedFile path to the embeddable font file (may be null)
      * @param subFontName the sub-fontname used for TrueType Collections (null otherwise)
      */
-    public EmbedFontInfo(String metricsFile, boolean kerning,
+    public EmbedFontInfo(String metricsFile, boolean kerning, boolean advanced,
                     List/*<FontTriplet>*/ fontTriplets, String embedFile, String subFontName) {
         this.metricsFile = metricsFile;
         this.embedFile = embedFile;
         this.kerning = kerning;
+        this.advanced = advanced;
         this.fontTriplets = fontTriplets;
         this.subFontName = subFontName;
     }
@@ -85,13 +89,21 @@ public class EmbedFontInfo implements Se
 
     /**
      * Determines if kerning is enabled
-     * @return True if enabled
+     * @return true if enabled
      */
     public boolean getKerning() {
         return kerning;
     }
 
     /**
+     * Determines if advanced typographic features are enabled
+     * @return true if enabled
+     */
+    public boolean getAdvanced() {
+        return advanced;
+    }
+
+    /**
      * Returns the sub-font name of the font. This is primarily used for TrueType Collections
      * to select one of the sub-fonts. For all other fonts, this is always null.
      * @return the sub-font name (or null)
@@ -173,6 +185,7 @@ public class EmbedFontInfo implements Se
     public String toString() {
         return "metrics-url=" + metricsFile + ", embed-url=" + embedFile
             + ", kerning=" + kerning
+            + ", advanced=" + advanced
             + ", enc-mode=" + encodingMode
             + ", font-triplet=" + fontTriplets
             + (getSubFontName() != null ? ", sub-font=" + getSubFontName() : "")

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/Font.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/Font.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/Font.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/Font.java Thu Aug 19 19:46:41 2010
@@ -25,11 +25,13 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.fop.fonts.CodePointMapping;
 
+// CSOFF: LineLengthCheck
+
 /**
  * This class holds font state information and provides access to the font
  * metrics.
  */
-public class Font {
+public class Font implements Substitutable, Positionable {
 
     /** Extra Bold font weight */
     public static final int WEIGHT_EXTRA_BOLD = 800;
@@ -240,8 +242,8 @@ public class Font {
      * {@inheritDoc}
      */
     public String toString() {
-        StringBuffer sbuf = new StringBuffer();
-        sbuf.append('(');
+        StringBuffer sbuf = new StringBuffer(super.toString());
+        sbuf.append('{');
         /*
         sbuf.append(fontFamily);
         sbuf.append(',');*/
@@ -253,7 +255,7 @@ public class Font {
         sbuf.append(fontStyle);
         sbuf.append(',');
         sbuf.append(fontWeight);*/
-        sbuf.append(')');
+        sbuf.append('}');
         return sbuf.toString();
     }
 
@@ -346,6 +348,44 @@ public class Font {
         return width;
     }
 
-}
+    /** {@inheritDoc} */
+    public boolean performsSubstitution() {
+        if ( metric instanceof Substitutable ) {
+            Substitutable s = (Substitutable) metric;
+            return s.performsSubstitution();
+        } else {
+            return false;
+        }
+    }
 
+    /** {@inheritDoc} */
+    public CharSequence performSubstitution ( CharSequence cs, String script, String language ) {
+        if ( metric instanceof Substitutable ) {
+            Substitutable s = (Substitutable) metric;
+            return s.performSubstitution ( cs, script, language );
+        } else {
+            throw new UnsupportedOperationException();
+        }
+    }
 
+    /** {@inheritDoc} */
+    public boolean performsPositioning() {
+        if ( metric instanceof Positionable ) {
+            Positionable p = (Positionable) metric;
+            return p.performsPositioning();
+        } else {
+            return false;
+        }
+    }
+
+    /** {@inheritDoc} */
+    public int[] performPositioning ( CharSequence cs, String script, String language ) {
+        if ( metric instanceof Positionable ) {
+            Positionable p = (Positionable) metric;
+            return p.performPositioning ( cs, script, language );
+        } else {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+}

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontCache.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontCache.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontCache.java Thu Aug 19 19:46:41 2010
@@ -77,7 +77,7 @@ public final class FontCache implements 
      * mapping of font url -> file modified date (for all fonts that have failed
      * to load)
      */
-    private Map failedFontMap/* <String, Long> */= null;
+    private Map failedFontMap/* <String, Long>*/ = null;
 
     /**
      * Default constructor

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontInfoConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontInfoConfigurator.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontInfoConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontInfoConfigurator.java Thu Aug 19 19:46:41 2010
@@ -254,20 +254,26 @@ public class FontInfoConfigurator {
         }
 
         boolean useKerning = fontCfg.getAttributeAsBoolean("kerning", true);
+        boolean useAdvanced = fontCfg.getAttributeAsBoolean("advanced", true);
         EncodingMode encodingMode = EncodingMode.valueOf(
                 fontCfg.getAttribute("encoding-mode", EncodingMode.AUTO.getName()));
         EmbedFontInfo embedFontInfo
-                = new EmbedFontInfo(metricsUrl, useKerning, tripletList, embedUrl, subFont);
+            = new EmbedFontInfo(metricsUrl, useKerning, useAdvanced, tripletList, embedUrl,
+                                subFont);
         embedFontInfo.setEncodingMode(encodingMode);
+        boolean skipCachedFont = false;
         if (fontCache != null) {
             if (!fontCache.containsFont(embedFontInfo)) {
                 fontCache.addFont(embedFontInfo);
+            } else {
+                skipCachedFont = true;
             }
         }
 
         if (log.isDebugEnabled()) {
             String embedFile = embedFontInfo.getEmbedFile();
-            log.debug("Adding font " + (embedFile != null ? embedFile + ", " : "")
+            log.debug( ( skipCachedFont ? "Skipping (cached) font " : "Adding font " )
+                    + (embedFile != null ? embedFile + ", " : "")
                     + "metric file " + embedFontInfo.getMetricsFile());
             for (int j = 0; j < tripletList.size(); ++j) {
                 FontTriplet triplet = (FontTriplet) tripletList.get(j);

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontLoader.java?rev=987282&r1=987281&r2=987282&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/FontLoader.java Thu Aug 19 19:46:41 2010
@@ -43,31 +43,36 @@ public abstract class FontLoader {
     protected static Log log = LogFactory.getLog(FontLoader.class);
 
     /** URI representing the font file */
-    protected String fontFileURI = null;
+    protected String fontFileURI;
     /** the FontResolver to use for font URI resolution */
-    protected FontResolver resolver = null;
+    protected FontResolver resolver;
     /** the loaded font */
-    protected CustomFont returnFont = null;
+    protected CustomFont returnFont;
 
     /** true if the font has been loaded */
-    protected boolean loaded = false;
+    protected boolean loaded;
     /** true if the font will be embedded, false if it will be referenced only. */
-    protected boolean embedded = true;
-    /** true if kerning information shall be loaded if available. */
-    protected boolean useKerning = true;
+    protected boolean embedded;
+    /** true if kerning information false be loaded if available. */
+    protected boolean useKerning;
+    /** true if advanced typographic information shall be loaded if available. */
+    protected boolean useAdvanced;
 
     /**
      * Default constructor.
      * @param fontFileURI the URI to the PFB file of a Type 1 font
      * @param embedded indicates whether the font is embedded or referenced
      * @param useKerning indicates whether kerning information shall be loaded if available
+     * @param useAdvanced indicates whether advanced typographic information shall be loaded if
+     * available
      * @param resolver the font resolver used to resolve URIs
      */
     public FontLoader(String fontFileURI, boolean embedded, boolean useKerning,
-            FontResolver resolver) {
+            boolean useAdvanced, FontResolver resolver) {
         this.fontFileURI = fontFileURI;
         this.embedded = embedded;
         this.useKerning = useKerning;
+        this.useAdvanced = useAdvanced;
         this.resolver = resolver;
     }
 
@@ -105,7 +110,7 @@ public abstract class FontLoader {
             boolean embedded, EncodingMode encodingMode,
             FontResolver resolver) throws IOException {
         return loadFont(fontUrl.toExternalForm(), subFontName,
-                embedded, encodingMode, true,
+                embedded, encodingMode, true, true,
                 resolver);
     }
 
@@ -116,13 +121,15 @@ public abstract class FontLoader {
      * @param embedded indicates whether the font is embedded or referenced
      * @param encodingMode the requested encoding mode
      * @param useKerning indicates whether kerning information should be loaded if available
+     * @param useAdvanced indicates whether advanced typographic information shall be loaded if
+     * available
      * @param resolver the font resolver to use when resolving URIs
      * @return the newly loaded font
      * @throws IOException In case of an I/O error
      */
     public static CustomFont loadFont(String fontFileURI, String subFontName,
             boolean embedded, EncodingMode encodingMode, boolean useKerning,
-            FontResolver resolver) throws IOException {
+            boolean useAdvanced, FontResolver resolver) throws IOException {
         fontFileURI = fontFileURI.trim();
         boolean type1 = isType1(fontFileURI);
         FontLoader loader;
@@ -134,7 +141,7 @@ public abstract class FontLoader {
             loader = new Type1FontLoader(fontFileURI, embedded, useKerning, resolver);
         } else {
             loader = new TTFFontLoader(fontFileURI, subFontName,
-                    embedded, encodingMode, useKerning, resolver);
+                    embedded, encodingMode, useKerning, useAdvanced, resolver);
         }
         return loader.getFont();
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org