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 2011/10/18 10:33:40 UTC

svn commit: r1185530 [2/14] - in /xmlgraphics/fop/branches/Temp_ComplexScripts: ./ src/documentation/content/xdocs/trunk/ src/foschema/ src/java/org/apache/fop/apps/ src/java/org/apache/fop/area/ src/java/org/apache/fop/cli/ src/java/org/apache/fop/fo/...

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFFile.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFFile.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFFile.java Tue Oct 18 08:33:32 2011
@@ -66,6 +66,10 @@ public class TTFFile {
     private final String encoding = "WinAnsiEncoding";    // Default encoding
 
     private final short firstChar = 0;
+
+    private boolean useKerning = false;
+    private boolean useAdvanced = false;
+
     private boolean isEmbeddable = true;
     private boolean hasSerifs = true;
     /**
@@ -138,9 +142,9 @@ public class TTFFile {
     private boolean isCFF;
 
     /* advanced typographic support */
-    private Map/*<String,Object[3]>*/ seScripts;
-    private Map/*<String,Object[2]>*/ seLanguages;
-    private Map/*<String,List<String>>*/ seFeatures;
+    private Map/*<String,Object[3]>*/ seScripts;                // script-tag         => Object[3] : { default-language-tag, List(language-tag), seLanguages }
+    private Map/*<String,Object[2]>*/ seLanguages;              // language-tag       => Object[2] : { "f<required-feature-index>", List("f<feature-index>")
+    private Map/*<String,List<String>>*/ seFeatures;            // "f<feature-index>" => Object[2] : { feature-tag, List("lu<lookup-index>") }
     private GlyphMappingTable seMapping;
     private List seEntries;
     private List seSubtables;
@@ -154,6 +158,16 @@ public class TTFFile {
     protected Log log = LogFactory.getLog(TTFFile.class);
 
     /**
+     * Constructor
+     * @param useKerning true if kerning data should be loaded
+     * @param useAdvanced true if advanced typographic tables should be loaded
+     */
+    public TTFFile ( boolean useKerning, boolean useAdvanced ) {
+        this.useKerning = useKerning;
+        this.useAdvanced = useAdvanced;
+    }
+
+    /**
      * Key-value helper class
      */
     class UnicodeMapping implements Comparable {
@@ -623,19 +637,23 @@ public class TTFFile {
         // Create cmaps for bfentries
         createCMaps();
 
-        readKerning(in);
+        if ( useKerning ) {
+            readKerning(in);
+        }
 
         // Read advanced typographic tables. If any format exception,
         // reset (thus ignoring) all advanced typographic tables.
-        try {
-            readGDEF(in);
-            readGSUB(in);
-            readGPOS(in);
-        } catch ( AdvancedTypographicTableFormatException e ) {
-            resetATStateAll();
-            log.warn ( "Encountered format constraint violation in advanced (typographic) table (AT) "
-                       + "in font '" + getFullName() + "', ignoring AT data: "
-                       + e.getMessage() );
+        if ( useAdvanced ) {
+            try {
+                readGDEF(in);
+                readGSUB(in);
+                readGPOS(in);
+            } catch ( AdvancedTypographicTableFormatException e ) {
+                resetATStateAll();
+                log.warn ( "Encountered format constraint violation in advanced (typographic) table (AT) "
+                           + "in font '" + getFullName() + "', ignoring AT data: "
+                           + e.getMessage() );
+            }
         }
 
         guessVerticalMetricsFromGlyphBBox();
@@ -2910,14 +2928,14 @@ public class TTFFile {
         }
         // read input glyph count
         int nig = in.readTTFUShort();
-        // read backtrack glyph coverage offsets
+        // read input glyph coverage offsets
         int[] igcoa = new int [ nig ];
         for ( int i = 0; i < nig; i++ ) {
             igcoa [ i ] = in.readTTFUShort();
         }
         // read lookahead glyph count
         int nlg = in.readTTFUShort();
-        // read backtrack glyph coverage offsets
+        // read lookahead glyph coverage offsets
         int[] lgcoa = new int [ nlg ];
         for ( int i = 0; i < nlg; i++ ) {
             lgcoa [ i ] = in.readTTFUShort();
@@ -5121,12 +5139,12 @@ public class TTFFile {
     private GlyphSubtable constructGDEFSubtable ( Object[] stp ) {
         GlyphSubtable st = null;
         assert ( stp != null ) && ( stp.length == 8 );
-        Integer tt = (Integer) stp[0];
-        Integer lt = (Integer) stp[1];
-        Integer ln = (Integer) stp[2];
-        Integer lf = (Integer) stp[3];
-        Integer sn = (Integer) stp[4];
-        Integer sf = (Integer) stp[5];
+        Integer tt = (Integer) stp[0];          // table type
+        Integer lt = (Integer) stp[1];          // lookup type
+        Integer ln = (Integer) stp[2];          // lookup sequence number
+        Integer lf = (Integer) stp[3];          // lookup flags
+        Integer sn = (Integer) stp[4];          // subtable sequence number
+        Integer sf = (Integer) stp[5];          // subtable format
         GlyphMappingTable mapping = (GlyphMappingTable) stp[6];
         List entries = (List) stp[7];
         if ( tt.intValue() == GlyphTable.GLYPH_TABLE_TYPE_DEFINITION ) {
@@ -5157,12 +5175,12 @@ public class TTFFile {
     private GlyphSubtable constructGSUBSubtable ( Object[] stp ) {
         GlyphSubtable st = null;
         assert ( stp != null ) && ( stp.length == 8 );
-        Integer tt = (Integer) stp[0];
-        Integer lt = (Integer) stp[1];
-        Integer ln = (Integer) stp[2];
-        Integer lf = (Integer) stp[3];
-        Integer sn = (Integer) stp[4];
-        Integer sf = (Integer) stp[5];
+        Integer tt = (Integer) stp[0];          // table type
+        Integer lt = (Integer) stp[1];          // lookup type
+        Integer ln = (Integer) stp[2];          // lookup sequence number
+        Integer lf = (Integer) stp[3];          // lookup flags
+        Integer sn = (Integer) stp[4];          // subtable sequence number
+        Integer sf = (Integer) stp[5];          // subtable format
         GlyphCoverageTable coverage = (GlyphCoverageTable) stp[6];
         List entries = (List) stp[7];
         if ( tt.intValue() == GlyphTable.GLYPH_TABLE_TYPE_SUBSTITUTION ) {
@@ -5193,12 +5211,12 @@ public class TTFFile {
     private GlyphSubtable constructGPOSSubtable ( Object[] stp ) {
         GlyphSubtable st = null;
         assert ( stp != null ) && ( stp.length == 8 );
-        Integer tt = (Integer) stp[0];
-        Integer lt = (Integer) stp[1];
-        Integer ln = (Integer) stp[2];
-        Integer lf = (Integer) stp[3];
-        Integer sn = (Integer) stp[4];
-        Integer sf = (Integer) stp[5];
+        Integer tt = (Integer) stp[0];          // table type
+        Integer lt = (Integer) stp[1];          // lookup type
+        Integer ln = (Integer) stp[2];          // lookup sequence number
+        Integer lf = (Integer) stp[3];          // lookup flags
+        Integer sn = (Integer) stp[4];          // subtable sequence number
+        Integer sf = (Integer) stp[5];          // subtable format
         GlyphCoverageTable coverage = (GlyphCoverageTable) stp[6];
         List entries = (List) stp[7];
         if ( tt.intValue() == GlyphTable.GLYPH_TABLE_TYPE_POSITIONING ) {
@@ -5462,7 +5480,9 @@ public class TTFFile {
      */
     public static void main(String[] args) {
         try {
-            TTFFile ttfFile = new TTFFile();
+            boolean useKerning = true;
+            boolean useAdvanced = true;
+            TTFFile ttfFile = new TTFFile(useKerning, useAdvanced);
 
             FontFileReader reader = new FontFileReader(args[0]);
 

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java Tue Oct 18 08:33:32 2011
@@ -94,7 +94,7 @@ public class TTFFontLoader extends FontL
     private void read(String ttcFontName) throws IOException {
         InputStream in = openFontUri(resolver, this.fontFileURI);
         try {
-            TTFFile ttf = new TTFFile();
+            TTFFile ttf = new TTFFile(useKerning, useAdvanced);
             FontFileReader reader = new FontFileReader(in);
             boolean supported = ttf.readFont(reader, ttcFontName);
             if (!supported) {

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java Tue Oct 18 08:33:32 2011
@@ -57,6 +57,22 @@ public class TTFSubSetFile extends TTFFi
     private int locaOffset = 0;
 
     /**
+     * Default Constructor
+     */
+    public TTFSubSetFile() {
+        this(false, false);
+    }
+
+    /**
+     * Constructor
+     * @param useKerning true if kerning data should be loaded
+     * @param useAdvanced true if advanced typographic tables should be loaded
+     */
+    public TTFSubSetFile ( boolean useKerning, boolean useAdvanced ) {
+        super(useKerning, useAdvanced);
+    }
+
+    /**
      * Initalize the output array
      */
     private void init(int size) {

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageBreaker.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageBreaker.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageBreaker.java Tue Oct 18 08:33:32 2011
@@ -367,7 +367,9 @@ public class PageBreaker extends Abstrac
             // Handle special page-master for last page
             BodyRegion currentBody = pageProvider.getPage(false, currentPageNum)
                     .getPageViewport().getBodyRegion();
-            pageProvider.setLastPageIndex(currentPageNum);
+
+            setLastPageIndex(currentPageNum);
+
             BodyRegion lastBody = pageProvider.getPage(false, currentPageNum)
                     .getPageViewport().getBodyRegion();
             lastBody.getMainReference().setSpans(currentBody.getMainReference().getSpans());
@@ -410,7 +412,7 @@ public class PageBreaker extends Abstrac
                 //Add areas now...
                 addAreas(alg, restartPoint, partCount - restartPoint, originalList, effectiveList);
                 //...and add a blank last page
-                pageProvider.setLastPageIndex(currentPageNum + 1);
+                setLastPageIndex(currentPageNum + 1);
                 pslm.setCurrentPage(pslm.makeNewPage(true, true));
                 return;
             }
@@ -419,6 +421,11 @@ public class PageBreaker extends Abstrac
         addAreas(algRestart, optimalPageCount, originalList, effectiveList);
     }
 
+    private void setLastPageIndex(int currentPageNum) {
+        int lastPageIndex = pslm.getForcedLastPageNum(currentPageNum);
+        pageProvider.setLastPageIndex(lastPageIndex);
+    }
+
     /** {@inheritDoc} */
     protected void startPart(BlockSequence list, int breakClass) {
         AbstractBreaker.log.debug("startPart() breakClass=" + getBreakClassName(breakClass));

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageProvider.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageProvider.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageProvider.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageProvider.java Tue Oct 18 08:33:32 2011
@@ -345,6 +345,7 @@ public class PageProvider implements Con
         //Set unique key obtained from the AreaTreeHandler
         page.getPageViewport().setKey(areaTreeHandler.generatePageViewportKey());
         page.getPageViewport().setForeignAttributes(spm.getForeignAttributes());
+        page.getPageViewport().setWritingModeTraits(pageSeq);
         cachedPages.add(page);
         return page;
     }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java Tue Oct 18 08:33:32 2011
@@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.fop.area.AreaTreeHandler;
 import org.apache.fop.area.AreaTreeModel;
 import org.apache.fop.area.LineArea;
+import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.pagination.PageSequence;
 import org.apache.fop.fo.pagination.PageSequenceMaster;
 import org.apache.fop.fo.pagination.SideRegion;
@@ -78,7 +79,9 @@ public class PageSequenceLayoutManager e
         initialize();
 
         // perform step 5.8 of refinement process (Unicode BIDI Processing)
-        BidiUtil.resolveInlineDirectionality(getPageSequence());
+        if ( areaTreeHandler.isComplexScriptFeaturesEnabled() ) {
+            BidiUtil.resolveInlineDirectionality(getPageSequence());
+        }
 
         LineArea title = null;
         if (getPageSequence().getTitleFO() != null) {
@@ -169,4 +172,24 @@ public class PageSequenceLayoutManager e
         super.finishPage();
     }
 
+    /**
+     * The last page number of the sequence may be incremented, as determined by the
+     *  force-page-count formatting property semantics
+     * @param lastPageNum number of sequence
+     * @return the forced last page number of sequence
+     */
+    protected int getForcedLastPageNum(final int lastPageNum) {
+        int forcedLastPageNum = lastPageNum;
+        if (  lastPageNum % 2 != 0
+                && ( getPageSequence().getForcePageCount() ==  Constants.EN_EVEN
+                 || getPageSequence().getForcePageCount() ==  Constants.EN_END_ON_EVEN )) {
+            forcedLastPageNum++;
+        } else if ( lastPageNum % 2 == 0 && (
+                getPageSequence().getForcePageCount() ==  Constants.EN_ODD
+                ||  getPageSequence().getForcePageCount() ==  Constants.EN_END_ON_ODD )) {
+            forcedLastPageNum++;
+        }
+        return forcedLastPageNum;
+    }
+
 }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java Tue Oct 18 08:33:32 2011
@@ -32,6 +32,7 @@ import org.apache.fop.area.inline.Inline
 import org.apache.fop.area.inline.InlineBlockParent;
 import org.apache.fop.area.inline.InlineParent;
 import org.apache.fop.datatypes.Length;
+import org.apache.fop.fo.flow.BasicLink;
 import org.apache.fop.fo.flow.Inline;
 import org.apache.fop.fo.flow.InlineLevel;
 import org.apache.fop.fo.flow.Leader;
@@ -106,10 +107,6 @@ public class InlineLayoutManager extends
         super(node);
     }
 
-    private Inline getInlineFO() {
-        return (Inline) fobj;
-    }
-
     /** {@inheritDoc} */
     @Override
     public void initialize() {
@@ -136,6 +133,11 @@ public class InlineLayoutManager extends
             alignmentBaseline = ((Leader)fobj).getAlignmentBaseline();
             baselineShift = ((Leader)fobj).getBaselineShift();
             dominantBaseline = ((Leader)fobj).getDominantBaseline();
+        } else if (fobj instanceof BasicLink) {
+            alignmentAdjust = ((BasicLink)fobj).getAlignmentAdjust();
+            alignmentBaseline = ((BasicLink)fobj).getAlignmentBaseline();
+            baselineShift = ((BasicLink)fobj).getBaselineShift();
+            dominantBaseline = ((BasicLink)fobj).getDominantBaseline();
         }
         if (borderProps != null) {
             padding = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this);
@@ -209,8 +211,8 @@ public class InlineLayoutManager extends
         } else {
             area = new InlineBlockParent();
         }
-        if (fobj instanceof Inline) {
-            TraitSetter.setProducerID(area, getInlineFO().getId());
+        if (fobj instanceof Inline || fobj instanceof BasicLink) {
+            TraitSetter.setProducerID(area, fobj.getId());
         }
         return area;
     }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/pdf/PDFFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/pdf/PDFFactory.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/pdf/PDFFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/pdf/PDFFactory.java Tue Oct 18 08:33:32 2011
@@ -64,7 +64,6 @@ import org.apache.fop.fonts.truetype.Fon
 import org.apache.fop.fonts.truetype.TTFSubSetFile;
 import org.apache.fop.fonts.type1.PFBData;
 import org.apache.fop.fonts.type1.PFBParser;
-import org.apache.xmlgraphics.xmp.Metadata;
 
 /**
  * This class provides method to create and register PDF objects.

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/AbstractRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/AbstractRenderer.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/AbstractRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/AbstractRenderer.java Tue Oct 18 08:33:32 2011
@@ -397,22 +397,34 @@ public abstract class AbstractRenderer
      * @param mr  The main reference area
      */
     protected void renderMainReference(MainReference mr) {
-        int saveIPPos = currentIPPosition;
-
         Span span = null;
         List spans = mr.getSpans();
         int saveBPPos = currentBPPosition;
         int saveSpanBPPos = saveBPPos;
+        int saveIPPos = currentIPPosition;
         for (int count = 0; count < spans.size(); count++) {
             span = (Span) spans.get(count);
+            int level = span.getBidiLevel();
+            if ( level < 0 ) {
+                level = 0;
+            }
+            if ( ( level & 1 ) == 1 ) {
+                currentIPPosition += span.getIPD();
+                currentIPPosition += mr.getColumnGap();
+            }
             for (int c = 0; c < span.getColumnCount(); c++) {
                 NormalFlow flow = span.getNormalFlow(c);
-
                 if (flow != null) {
                     currentBPPosition = saveSpanBPPos;
+                    if ( ( level & 1 ) == 1 ) {
+                        currentIPPosition -= flow.getIPD();
+                        currentIPPosition -= mr.getColumnGap();
+                    }
                     renderFlow(flow);
-                    currentIPPosition += flow.getIPD();
-                    currentIPPosition += mr.getColumnGap();
+                    if ( ( level & 1 ) == 0 ) {
+                        currentIPPosition += flow.getIPD();
+                        currentIPPosition += mr.getColumnGap();
+                    }
                 }
             }
             currentIPPosition = saveIPPos;

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/DefaultFontResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/DefaultFontResolver.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/DefaultFontResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/DefaultFontResolver.java Tue Oct 18 08:33:32 2011
@@ -44,4 +44,9 @@ public class DefaultFontResolver impleme
         return userAgent.resolveURI(href, userAgent.getFactory().getFontManager().getFontBaseURL());
     }
 
+    /** {@inheritDoc} */
+    public boolean isComplexScriptFeaturesEnabled() {
+        return userAgent.isComplexScriptFeaturesEnabled();
+    }
+
 }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/PrintRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/PrintRenderer.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/PrintRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/PrintRenderer.java Tue Oct 18 08:33:32 2011
@@ -83,7 +83,8 @@ public abstract class PrintRenderer exte
         FontManager fontManager = userAgent.getFactory().getFontManager();
         FontCollection[] fontCollections = new FontCollection[] {
                 new Base14FontCollection(fontManager.isBase14KerningEnabled()),
-                new CustomFontCollection(getFontResolver(), getFontList())
+                new CustomFontCollection(getFontResolver(), getFontList(),
+                                         userAgent.isComplexScriptFeaturesEnabled())
         };
         fontManager.setup(getFontInfo(), fontCollections);
     }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/PrintRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/PrintRendererConfigurator.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/PrintRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/PrintRendererConfigurator.java Tue Oct 18 08:33:32 2011
@@ -95,7 +95,9 @@ public class PrintRendererConfigurator e
         FontManager fontManager = factory.getFontManager();
         if (fontResolver == null) {
             //Ensure that we have minimal font resolution capabilities
-            fontResolver = FontManager.createMinimalFontResolver();
+            fontResolver
+                = FontManager.createMinimalFontResolver
+                    ( userAgent.isComplexScriptFeaturesEnabled() );
         }
 
         boolean strict = factory.validateUserConfigStrictly();
@@ -128,7 +130,8 @@ public class PrintRendererConfigurator e
             FontEventListener listener = new FontEventAdapter(
                     userAgent.getEventBroadcaster());
             List<EmbedFontInfo> fontList = buildFontList(cfg, fontResolver, listener);
-            fontCollections.add(new CustomFontCollection(fontResolver, fontList));
+            fontCollections.add(new CustomFontCollection(fontResolver, fontList,
+                                userAgent.isComplexScriptFeaturesEnabled()));
         }
 
         fontManager.setup(fontInfo,

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigurator.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigurator.java Tue Oct 18 08:33:32 2011
@@ -129,7 +129,8 @@ public class BitmapRendererConfigurator 
             FontEventListener listener = new FontEventAdapter(
                     userAgent.getEventBroadcaster());
             List fontList = buildFontList(cfg, fontResolver, listener);
-            fontCollections.add(new ConfiguredFontCollection(fontResolver, fontList));
+            fontCollections.add(new ConfiguredFontCollection(fontResolver, fontList,
+                                userAgent.isComplexScriptFeaturesEnabled()));
         }
 
         fontManager.setup(fontInfo,

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java Tue Oct 18 08:33:32 2011
@@ -51,13 +51,14 @@ public class ConfiguredFontCollection im
      * Main constructor
      * @param fontResolver a font resolver
      * @param customFonts the list of custom fonts
+     * @param useComplexScriptFeatures true if complex script features enabled
      */
     public ConfiguredFontCollection(FontResolver fontResolver,
-            List/*<EmbedFontInfo>*/ customFonts) {
+            List/*<EmbedFontInfo>*/ customFonts, boolean useComplexScriptFeatures) {
         this.fontResolver = fontResolver;
         if (this.fontResolver == null) {
             //Ensure that we have minimal font resolution capabilities
-            this.fontResolver = FontManager.createMinimalFontResolver();
+            this.fontResolver = FontManager.createMinimalFontResolver(useComplexScriptFeatures);
         }
         this.embedFontInfoList = customFonts;
     }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/java2d/Java2DRenderer.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/java2d/Java2DRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/java2d/Java2DRenderer.java Tue Oct 18 08:33:32 2011
@@ -176,7 +176,8 @@ public abstract class Java2DRenderer ext
         FontCollection[] fontCollections = new FontCollection[] {
                 new Base14FontCollection(java2DFontMetrics),
                 new InstalledFontCollection(java2DFontMetrics),
-                new ConfiguredFontCollection(getFontResolver(), getFontList())
+                new ConfiguredFontCollection(getFontResolver(), getFontList(),
+                                             userAgent.isComplexScriptFeaturesEnabled())
         };
         userAgent.getFactory().getFontManager().setup(
                 getFontInfo(), fontCollections);

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java Tue Oct 18 08:33:32 2011
@@ -119,7 +119,8 @@ public class PCLRendererConfigurator ext
             FontEventListener listener = new FontEventAdapter(
                     userAgent.getEventBroadcaster());
             List fontList = buildFontList(cfg, fontResolver, listener);
-            fontCollections.add(new ConfiguredFontCollection(fontResolver, fontList));
+            fontCollections.add(new ConfiguredFontCollection(fontResolver, fontList,
+                                userAgent.isComplexScriptFeaturesEnabled()));
         }
 
         fontManager.setup(fontInfo,

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java Tue Oct 18 08:33:32 2011
@@ -112,8 +112,9 @@ public abstract class AbstractPSTranscod
         graphics = createDocumentGraphics2D();
         if (!isTextStroked()) {
             try {
+                boolean useComplexScriptFeatures = false; //TODO - FIX ME
                 this.fontInfo = PDFDocumentGraphics2DConfigurator.createFontInfo(
-                        getEffectiveConfiguration());
+                        getEffectiveConfiguration(), useComplexScriptFeatures);
                 graphics.setCustomTextHandler(new NativeTextHandler(graphics, fontInfo));
             } catch (FOPException fe) {
                 throw new TranscoderException(fe);

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/ps/NativeTextHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/ps/NativeTextHandler.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/ps/NativeTextHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/ps/NativeTextHandler.java Tue Oct 18 08:33:32 2011
@@ -73,7 +73,8 @@ public class NativeTextHandler implement
     private void setupFontInfo() {
         //Sets up a FontInfo with default fonts
         fontInfo = new FontInfo();
-        FontSetup.setup(fontInfo);
+        boolean base14Kerning = false;
+        FontSetup.setup(fontInfo, base14Kerning);
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/rtf/RTFHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/rtf/RTFHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/rtf/RTFHandler.java Tue Oct 18 08:33:32 2011
@@ -168,7 +168,8 @@ public class RTFHandler extends FOEventH
         this.os = os;
         bDefer = true;
 
-        FontSetup.setup(fontInfo, null, new DefaultFontResolver(userAgent));
+        boolean base14Kerning = false;
+        FontSetup.setup(fontInfo, null, new DefaultFontResolver(userAgent), base14Kerning);
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/xml/XMLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/xml/XMLRenderer.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/xml/XMLRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/render/xml/XMLRenderer.java Tue Oct 18 08:33:32 2011
@@ -625,6 +625,7 @@ public class XMLRenderer extends Abstrac
             }
             addAreaAttributes(span);
             addTraitAttributes(span);
+            maybeAddLevelAttribute(span);
             startElement("span", atts);
             for (int c = 0; c < span.getColumnCount(); c++) {
                 NormalFlow flow = span.getNormalFlow(c);

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java Tue Oct 18 08:33:32 2011
@@ -159,7 +159,8 @@ public class PDFDocumentGraphics2D exten
         if (fontInfo == null) {
             //Default minimal fonts
             FontInfo fontInfo = new FontInfo();
-            FontSetup.setup(fontInfo);
+            boolean base14Kerning = false;
+            FontSetup.setup(fontInfo, base14Kerning);
             setFontInfo(fontInfo);
         }
     }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java Tue Oct 18 08:33:32 2011
@@ -46,9 +46,11 @@ public class PDFDocumentGraphics2DConfig
      * Configures a PDFDocumentGraphics2D instance using an Avalon Configuration object.
      * @param graphics the PDFDocumentGraphics2D instance
      * @param cfg the configuration
+     * @param useComplexScriptFeatures true if complex script features enabled
      * @throws ConfigurationException if an error occurs while configuring the object
      */
-    public void configure(PDFDocumentGraphics2D graphics, Configuration cfg)
+    public void configure(PDFDocumentGraphics2D graphics, Configuration cfg,
+                          boolean useComplexScriptFeatures )
             throws ConfigurationException {
         PDFDocument pdfDoc = graphics.getPDFDocument();
 
@@ -58,7 +60,7 @@ public class PDFDocumentGraphics2DConfig
 
         //Fonts
         try {
-            FontInfo fontInfo = createFontInfo(cfg);
+            FontInfo fontInfo = createFontInfo(cfg, useComplexScriptFeatures);
             graphics.setFontInfo(fontInfo);
         } catch (FOPException e) {
             throw new ConfigurationException("Error while setting up fonts", e);
@@ -68,13 +70,15 @@ public class PDFDocumentGraphics2DConfig
     /**
      * Creates the {@link FontInfo} instance for the given configuration.
      * @param cfg the configuration
+     * @param useComplexScriptFeatures true if complex script features enabled
      * @return the font collection
      * @throws FOPException if an error occurs while setting up the fonts
      */
-    public static FontInfo createFontInfo(Configuration cfg) throws FOPException {
+    public static FontInfo createFontInfo(Configuration cfg, boolean useComplexScriptFeatures)
+        throws FOPException {
         FontInfo fontInfo = new FontInfo();
         final boolean strict = false;
-        FontResolver fontResolver = FontManager.createMinimalFontResolver();
+        FontResolver fontResolver = FontManager.createMinimalFontResolver(useComplexScriptFeatures);
         //TODO The following could be optimized by retaining the FontManager somewhere
         FontManager fontManager = new FontManager();
         if (cfg != null) {
@@ -92,7 +96,8 @@ public class PDFDocumentGraphics2DConfig
                 = new FontInfoConfigurator(cfg, fontManager, fontResolver, listener, strict);
             List/*<EmbedFontInfo>*/ fontInfoList = new java.util.ArrayList/*<EmbedFontInfo>*/();
             fontInfoConfigurator.configure(fontInfoList);
-            fontCollections.add(new CustomFontCollection(fontResolver, fontInfoList));
+            fontCollections.add(new CustomFontCollection(fontResolver, fontInfoList,
+                                fontResolver.isComplexScriptFeaturesEnabled()));
         }
         fontManager.setup(fontInfo,
                 (FontCollection[])fontCollections.toArray(

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFGraphics2D.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFGraphics2D.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFGraphics2D.java Tue Oct 18 08:33:32 2011
@@ -961,7 +961,8 @@ public class PDFGraphics2D extends Abstr
         preparePainting();
 
         FontInfo specialFontInfo = new FontInfo();
-        FontSetup.setup(specialFontInfo);
+        boolean base14Kerning = false;
+        FontSetup.setup(specialFontInfo, base14Kerning);
 
         PDFResources res = pdfDoc.getFactory().makeResources();
         PDFResourceContext context = new PDFResourceContext(res);

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFTranscoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFTranscoder.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFTranscoder.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFTranscoder.java Tue Oct 18 08:33:32 2011
@@ -126,7 +126,8 @@ public class PDFTranscoder extends Abstr
             if (effCfg != null) {
                 PDFDocumentGraphics2DConfigurator configurator
                         = new PDFDocumentGraphics2DConfigurator();
-                configurator.configure(graphics, effCfg);
+                boolean useComplexScriptFeatures = false; //TODO - FIX ME
+                configurator.configure(graphics, effCfg, useComplexScriptFeatures);
             } else {
                 graphics.setupDefaultFontInfo();
             }

Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/util/CharUtilities.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/util/CharUtilities.java?rev=1185530&r1=1185529&r2=1185530&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/util/CharUtilities.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/util/CharUtilities.java Tue Oct 18 08:33:32 2011
@@ -1117,7 +1117,14 @@ public class CharUtilities {
         return sb.toString();
     }
 
-    private static String padLeft ( String s, int width, char pad ) {
+    /**
+     * Pad a string S on left out to width W using padding character PAD.
+     * @param s string to pad
+     * @param width width of field to add padding
+     * @param pad character to use for padding
+     * @return padded string
+     */
+    public static String padLeft ( String s, int width, char pad ) {
         StringBuffer sb = new StringBuffer();
         for ( int i = s.length(); i < width; i++ ) {
             sb.append(pad);
@@ -1917,4 +1924,96 @@ public class CharUtilities {
         }
     }
 
+    /**
+     * Convert Java string (UTF-16) to a Unicode scalar array (UTF-32).
+     * Note that if there are any non-BMP encoded characters present in the
+     * input, then the number of entries in the output array will be less
+     * than the number of elements in the input string. Any 
+     * @param s input string
+     * @param substitution value to substitute for ill-formed surrogate
+     * @param errorOnSubstitution throw runtime exception (IllegalArgumentException) in
+     * case this argument is true and a substitution would be attempted
+     * @return output scalar array
+     * @throws IllegalArgumentException if substitution required and errorOnSubstitution
+     *   is not false
+     */
+    public static Integer[] toUTF32 ( String s, int substitution, boolean errorOnSubstitution )
+        throws IllegalArgumentException {
+        int n;
+        if ( ( n = s.length() ) == 0 ) {
+            return new Integer[0];
+        } else {
+            Integer[] sa = new Integer [ n ];
+            int k = 0;
+            for ( int i = 0; i < n; i++ ) {
+                int c = (int) s.charAt(i);
+                if ( ( c >= 0xD800 ) && ( c < 0xE000 ) ) {
+                    int s1 = c;
+                    int s2 = ( ( i + 1 ) < n ) ? (int) s.charAt ( i + 1 ) : 0;
+                    if ( s1 < 0xDC00 ) {
+                        if ( ( s2 >= 0xDC00 ) && ( s2 < 0xE000 ) ) {
+                            c = ( ( s1 - 0xD800 ) << 10 ) + ( s2 - 0xDC00 ) + 65536;
+                            i++;
+                        } else {
+                            if ( errorOnSubstitution ) {
+                                throw new IllegalArgumentException
+                                    ( "isolated high (leading) surrogate" );
+                            } else {
+                                c = substitution;
+                            }
+                        }
+                    } else {
+                        if ( errorOnSubstitution ) {
+                            throw new IllegalArgumentException
+                                ( "isolated low (trailing) surrogate" );
+                        } else {
+                            c = substitution;
+                        }
+                    }
+                }
+                sa[k++] = c;
+            }
+            if ( k == n ) {
+                return sa;
+            } else {
+                Integer[] na = new Integer [ k ];
+                System.arraycopy ( sa, 0, na, 0, k );
+                return na;
+            }
+        }
+    }
+
+    /**
+     * Convert a Unicode scalar array (UTF-32) a Java string (UTF-16).
+     * @param sa input scalar array
+     * @return output (UTF-16) string
+     * @throws IllegalArgumentException if an input scalar value is illegal,
+     *   e.g., a surrogate or out of range
+     */
+    public static String fromUTF32 ( Integer[] sa ) throws IllegalArgumentException {
+        StringBuffer sb = new StringBuffer();
+        for ( int s : sa ) {
+            if ( s < 65535 ) {
+                if ( ( s < 0xD800 ) || ( s > 0xDFFF ) ) {
+                    sb.append ( (char) s );
+                } else {
+                    String ncr = charToNCRef(s);
+                    throw new IllegalArgumentException
+                        ( "illegal scalar value 0x" + ncr.substring(2,ncr.length() - 1)
+                          + "; cannot be UTF-16 surrogate" );
+                }
+            } else if ( s < 1114112 ) {
+                int s1 = ( ( ( s - 65536 ) >> 10 ) & 0x3FF ) + 0xD800;
+                int s2 = ( ( ( s - 65536 ) >>  0 ) & 0x3FF ) + 0xDC00;
+                sb.append ( (char) s1 );
+                sb.append ( (char) s2 );
+            } else {
+                String ncr = charToNCRef(s);
+                throw new IllegalArgumentException
+                    ( "illegal scalar value 0x" + ncr.substring(2,ncr.length() - 1)
+                      + "; out of range for UTF-16"  );
+            }
+        }
+        return sb.toString();
+    }
 }



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