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 ac...@apache.org on 2008/06/02 16:05:53 UTC

svn commit: r662442 [1/3] - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources: ./ src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/fo/ src/java/org/apache/fop/fonts/ src/java/org/apache/fop/layoutmgr/inline/ src/java/org/apache/fop/layou...

Author: acumiskey
Date: Mon Jun  2 07:05:52 2008
New Revision: 662442

URL: http://svn.apache.org/viewvc?rev=662442&view=rev
Log:
Merged revisions 660979,660998,661276,661310,661999,662009,662203 via svnmerge from 
https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk

........
  r660979 | vhennebert | 2008-05-28 16:24:23 +0100 (Wed, 28 May 2008) | 3 lines
  
  Bugzilla 37579: added support for footnotes in lists and table bodies (not header nor footer).
  This is /not/ to be considered a final fix: similar code is duplicated over several classes (LineLayoutManager, ListItemLayoutManager and to less extent TableStepper). Footnotes should probably be handled another way.
........
  r660998 | maxberger | 2008-05-28 17:10:32 +0100 (Wed, 28 May 2008) | 1 line
  
  Implemented Font auto-selection word-by-word
........
  r661276 | vhennebert | 2008-05-29 10:58:06 +0100 (Thu, 29 May 2008) | 2 lines
  
  Set svn:keywords and svn:eol-style properties for files added in revision 660998
........
  r661310 | maxberger | 2008-05-29 13:03:48 +0100 (Thu, 29 May 2008) | 1 line
  
  Added docs for my recent commit (word-by-word character selection)
........
  r661999 | adelmelle | 2008-05-31 11:56:05 +0100 (Sat, 31 May 2008) | 3 lines
  
  Bugzilla 45097:
  Leading/trailing white-space not removed from nested inline-content when there is no preceding/following text.
........
  r662009 | maxberger | 2008-05-31 12:45:55 +0100 (Sat, 31 May 2008) | 1 line
  
  Code Cleanups (no functional change)
........
  r662203 | maxberger | 2008-06-01 12:57:33 +0100 (Sun, 01 Jun 2008) | 1 line
  
  More code Cleanups (no functional changes)
........

Added:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSelector.java
      - copied unchanged from r662203, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontSelector.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/block_font-autoselect.xml
      - copied unchanged from r662203, xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_font-autoselect.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/footnote_in_list_2.xml
      - copied unchanged from r662203, xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/footnote_in_list_2.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/footnote_in_table_2.xml
      - copied unchanged from r662203, xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/footnote_in_table_2.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/inline_white-space-treatment_bugzilla45097.xml
      - copied unchanged from r662203, xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/inline_white-space-treatment_bugzilla45097.xml
Modified:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/   (props changed)
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/documentation/content/xdocs/trunk/fonts.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOText.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/status.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/disabled-testcases.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/footnote_in_list.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/standard-testcases/footnote_in_table.xml

Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jun  2 07:05:52 2008
@@ -1 +1 @@
-/xmlgraphics/fop/trunk:1-658285
+/xmlgraphics/fop/trunk:1-662410

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/documentation/content/xdocs/trunk/fonts.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/documentation/content/xdocs/trunk/fonts.xml?rev=662442&r1=662441&r2=662442&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/documentation/content/xdocs/trunk/fonts.xml (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/documentation/content/xdocs/trunk/fonts.xml Mon Jun  2 07:05:52 2008
@@ -22,7 +22,7 @@
     <title>Apache FOP: Fonts</title>
     <version>$Revision$</version>
     <authors>
-      <person name="Jeremias Märki" email=""/>
+      <person name="Jeremias M&#xE4;rki" email=""/>
       <person name="Tore Engvig" email=""/>
       <person name="Adrian Cumiskey" email=""/>
       <person name="Max Berger" email=""/>
@@ -96,14 +96,14 @@
           <td>yes (used for layout but not for output)</td>
           <td>no</td>
         </tr>
-        <!--tr> NOT AVAILABLE
+<!--tr> NOT AVAILABLE
           <td>MIF</td>
           <td>n/a (font metrics not needed)</td>
           <td>n/a</td>
           <td>n/a</td>
           <td>n/a</td>
         </tr-->
-        <!--tr> NOT AVAILABLE
+<!--tr> NOT AVAILABLE
           <td>SVG</td>
           <td>if available from OS</td>
           <td>yes</td>
@@ -163,7 +163,6 @@
         PDF or PostScript.
       </p>
     </section>
-    
     <section id="custom">
       <title>Custom Fonts</title>
       <p>
@@ -184,11 +183,14 @@
         Basic information about fonts can be found at:
       </p>
       <ul>
-        <li><a href="http://partners.adobe.com/asn/developer/type/ftypes.html">Adobe font types</a></li>
-        <li><a href="http://partners.adobe.com/asn/developer/technotes/fonts.html">Adobe Font Technote</a></li>
+        <li>
+          <a href="http://partners.adobe.com/asn/developer/type/ftypes.html">Adobe font types</a>
+        </li>
+        <li>
+          <a href="http://partners.adobe.com/asn/developer/technotes/fonts.html">Adobe Font Technote</a>
+        </li>
       </ul>
     </section>
-    
     <section id="basics">
       <title>Basic font configuration</title>
       <p>
@@ -220,7 +222,6 @@
         not possible to easily configure fonts from Java code.
       </note>
     </section>
-    
     <section id="advanced">
       <title>Advanced font configuration</title>
       <p>
@@ -359,7 +360,7 @@
             relative to the base directory.
           </li>
         </ul>
-        <!--note>Cocoon users will need to setup the config, see FOPSerializer for more information.</note-->
+<!--note>Cocoon users will need to setup the config, see FOPSerializer for more information.</note-->
       </section>
       <section id="autodetect">
         <title>Auto-Detect and auto-embed feature</title>
@@ -425,14 +426,14 @@
         </ul>
       </section>
       <section id="substitution">
-         <title>Substitution</title>
-         <p>When a &lt;substitutions/&gt; section is defined in the configuration, FOP will re-map any font-family references found in your FO input to a given substitution font.</p>
-         <ul>
-            <li>If a &lt;substitution/&gt; is declared, it is mandatory that both a &lt;from/&gt; and &lt;to/&gt; child element is declared with a font-family attribute.</li>
-            <li>Both font-weight and font-style are optional attributes, if they are provided then a value of 'normal' is assumed.</li>
-         </ul>
-         <p>For example you could make all FO font-family references to 'Arial' with weights between 700 and 900 reference the normal 'Arial Black' font.</p>
-         <source><![CDATA[
+        <title>Substitution</title>
+        <p>When a &lt;substitutions/&gt; section is defined in the configuration, FOP will re-map any font-family references found in your FO input to a given substitution font.</p>
+        <ul>
+          <li>If a &lt;substitution/&gt; is declared, it is mandatory that both a &lt;from/&gt; and &lt;to/&gt; child element is declared with a font-family attribute.</li>
+          <li>Both font-weight and font-style are optional attributes, if they are provided then a value of 'normal' is assumed.</li>
+        </ul>
+        <p>For example you could make all FO font-family references to 'Arial' with weights between 700 and 900 reference the normal 'Arial Black' font.</p>
+        <source><![CDATA[
 <fop version="1.0">
    <fonts>
       <substitutions>
@@ -448,7 +449,7 @@
    </fonts>
 </fop>]]></source>
       </section>
-      <!-- The following section should no longer be required
+<!-- The following section should no longer be required
       <section id="embedding-base14">
         <title>Explicitly embedding the base 14 fonts</title>
         <p>
@@ -474,5 +475,18 @@
   [..]]]></source>
       </section-->
     </section>
+    <section id="selection">
+      <title>Font Selection Strategies</title>
+      <p>
+          There are two font selection strategies: character-by-character or auto. The default is auto.</p>
+      <p>Auto selected the first font from the list which is able to display the most characters in a given word. This means (assume font A has characters for abclmn, font B for lnmxyz, fontlist is A,B):</p>
+      <ul>
+        <li>aaa lll xxx would be displayed in fonts A A B</li>
+        <li>aaaxx would be displayed in font A</li>
+        <li>aaaxxx would be displayed in font A</li>
+        <li>aaaxxxx would be displayed in font B</li>
+      </ul>
+      <p>Character-by-Character is NOT yet supported!</p>
+    </section>
   </body>
 </document>

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOText.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOText.java?rev=662442&r1=662441&r2=662442&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOText.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/FOText.java Mon Jun  2 07:05:52 2008
@@ -37,7 +37,7 @@
 /**
  * A text node (PCDATA) in the formatting object tree.
  *
- * Unfortunately the BufferManager implementatation holds
+ * Unfortunately the BufferManager implementation holds
  * onto references to the character data in this object
  * longer than the lifetime of the object itself, causing
  * excessive memory consumption and OOM errors.

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java?rev=662442&r1=662441&r2=662442&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java Mon Jun  2 07:05:52 2008
@@ -87,39 +87,49 @@
      * @param nextChild the node that will be added to the list
      *                  after firstTextNode
      */
-    public void handleWhiteSpace(FObjMixed fo, FONode firstTextNode, FONode nextChild) {
-        
+    public void handleWhiteSpace(FObjMixed fo,
+                                 FONode firstTextNode,
+                                 FONode nextChild) {
+
         Block currentBlock = null;
         int foId = fo.getNameId();
         
-        if (foId == Constants.FO_BLOCK) {
-            currentBlock = (Block) fo;
-            if (nestedBlockStack.isEmpty() || fo != nestedBlockStack.peek()) {
-                if (nextChild != null) {
-                    /* if already in a block, push the current block 
-                     * onto the stack of nested blocks
-                     */
-                    nestedBlockStack.push(currentBlock);
+        /* set the current block */
+        switch (foId) {
+            case Constants.FO_BLOCK:
+                currentBlock = (Block) fo;
+                if (nestedBlockStack.empty() || fo != nestedBlockStack.peek()) {
+                    if (nextChild != null) {
+                        /* if already in a block, push the current block 
+                         * onto the stack of nested blocks
+                         */
+                        nestedBlockStack.push(currentBlock);
+                    }
+                } else {
+                    if (nextChild == null) {
+                        nestedBlockStack.pop();
+                    }
                 }
-            } else {
-                if (nextChild == null) {
-                    nestedBlockStack.pop();
+                break;
+            
+            case Constants.FO_RETRIEVE_MARKER:
+                /* look for the nearest block ancestor, if any */
+                FONode ancestor = fo;
+                do {
+                    ancestor = ancestor.getParent();
+                } while (ancestor.getNameId() != Constants.FO_BLOCK
+                        && ancestor.getNameId() != Constants.FO_STATIC_CONTENT);
+                
+                if (ancestor.getNameId() == Constants.FO_BLOCK) {
+                    currentBlock = (Block) ancestor;
+                    nestedBlockStack.push(currentBlock);
                 }
-            }
-        } else if (foId == Constants.FO_RETRIEVE_MARKER) {
-            /* look for the nearest block ancestor, if any */
-            FONode ancestor = fo;
-            do {
-                ancestor = ancestor.getParent();
-            } while (ancestor.getNameId() != Constants.FO_BLOCK
-                    && ancestor.getNameId() != Constants.FO_STATIC_CONTENT);
+                break;
             
-            if (ancestor.getNameId() == Constants.FO_BLOCK) {
-                currentBlock = (Block) ancestor;
-                nestedBlockStack.push(currentBlock);
-            }
-        } else if (!nestedBlockStack.isEmpty()) {
-            currentBlock = (Block) nestedBlockStack.peek();
+            default:
+                if (!nestedBlockStack.empty()) {
+                    currentBlock = (Block) nestedBlockStack.peek();
+                }
         }
         
         if (currentBlock != null) {
@@ -132,8 +142,15 @@
             whiteSpaceTreatment = Constants.EN_IGNORE_IF_SURROUNDING_LINEFEED;
         }
         
+        endOfBlock = (nextChild == null && fo == currentBlock);
+        
         if (firstTextNode == null) {
-            //nothing to do but initialize related properties
+            //no text means no white-space to handle; return early
+            afterLinefeed = (fo == currentBlock && fo.firstChild == null);
+            nonWhiteSpaceCount = 0;
+            if (endOfBlock) {
+                handlePendingInlines();
+            }
             return;
         }
         
@@ -144,13 +161,32 @@
                 || currentBlock == null
                 || (foId == Constants.FO_RETRIEVE_MARKER
                         && fo.getParent() == currentBlock)) {
-            afterLinefeed = (
-                    (firstTextNode == fo.firstChild)
-                        || (firstTextNode.siblings[0].getNameId()
-                                == Constants.FO_BLOCK));
+            if (firstTextNode == fo.firstChild) {
+                afterLinefeed = true;
+            } else {
+                int previousChildId = firstTextNode.siblings[0].getNameId();
+                afterLinefeed = (previousChildId == Constants.FO_BLOCK
+                        || previousChildId == Constants.FO_TABLE_AND_CAPTION
+                        || previousChildId == Constants.FO_TABLE
+                        || previousChildId == Constants.FO_LIST_BLOCK
+                        || previousChildId == Constants.FO_BLOCK_CONTAINER);
+            }
         }
         
-        endOfBlock = (nextChild == null && fo == currentBlock);
+        if (foId == Constants.FO_WRAPPER) {
+            FONode parent = fo.parent;
+            int parentId = parent.getNameId();
+            while (parentId == Constants.FO_WRAPPER) {
+                parent = parent.parent;
+                parentId = parent.getNameId();
+            }
+            if (parentId == Constants.FO_FLOW
+                    || parentId == Constants.FO_STATIC_CONTENT
+                    || parentId == Constants.FO_BLOCK_CONTAINER
+                    || parentId == Constants.FO_TABLE_CELL) {
+                endOfBlock = (nextChild == null);
+            }
+        }
         
         if (nextChild != null) {
             int nextChildId = nextChild.getNameId();
@@ -167,26 +203,8 @@
         handleWhiteSpace();
         
         if (fo == currentBlock 
-                && pendingInlines != null 
-                && !pendingInlines.isEmpty()) {
-            /* current FO is a block, and has pending inlines */
-            if (endOfBlock || nextChildIsBlockLevel) {
-                if (nonWhiteSpaceCount == 0) {
-                    /* handle white-space for all pending inlines*/
-                    PendingInline p;
-                    for (int i = pendingInlines.size(); --i >= 0;) {
-                        p = (PendingInline)pendingInlines.get(i);
-                        charIter = (RecursiveCharIterator)p.firstTrailingWhiteSpace;
-                        handleWhiteSpace();
-                        pendingInlines.remove(p);
-                    }
-                } else {
-                    /* there is non-white-space text between the pending
-                     * inline(s) and the end of the block;
-                     * clear list of pending inlines */
-                    pendingInlines.clear();
-                }
-            }
+                && (endOfBlock || nextChildIsBlockLevel)) {
+            handlePendingInlines();
         }
         
         if (nextChild == null) {
@@ -333,6 +351,26 @@
         pendingInlines.add(new PendingInline(fo, firstWhiteSpaceInSeq));
     }
     
+    private void handlePendingInlines() {
+        if (!(pendingInlines == null || pendingInlines.isEmpty())) {
+            if (nonWhiteSpaceCount == 0) {
+                /* handle white-space for all pending inlines*/
+                PendingInline p;
+                for (int i = pendingInlines.size(); --i >= 0;) {
+                    p = (PendingInline)pendingInlines.get(i);
+                    charIter = (RecursiveCharIterator)p.firstTrailingWhiteSpace;
+                    handleWhiteSpace();
+                    pendingInlines.remove(p);
+                }
+            } else {
+                /* there is non-white-space text between the pending
+                 * inline(s) and the end of the block;
+                 * clear list of pending inlines */
+                pendingInlines.clear();
+            }
+        }
+    }
+    
     /**
      * Helper class, used during white-space handling to look ahead, and
      * see if the next character is a linefeed (or if there will be

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java?rev=662442&r1=662441&r2=662442&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java Mon Jun  2 07:05:52 2008
@@ -26,8 +26,7 @@
 import org.apache.fop.fo.flow.Character;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fonts.Font;
-import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.fonts.FontTriplet;
+import org.apache.fop.fonts.FontSelector;
 import org.apache.fop.layoutmgr.InlineKnuthSequence;
 import org.apache.fop.layoutmgr.KnuthElement;
 import org.apache.fop.layoutmgr.KnuthGlue;
@@ -62,7 +61,7 @@
     /** {@inheritDoc} */
     public void initialize() {
         Character fobj = (Character)this.fobj;        
-        font = this.selectFontForCharacter(fobj);
+        font = FontSelector.selectFontForCharacter(fobj, this);
         SpaceVal ls = SpaceVal.makeLetterSpacing(fobj.getLetterSpacing());
         letterSpaceIPD = ls.getSpace();
         hyphIPD = fobj.getCommonHyphenation().getHyphIPD(font);
@@ -72,33 +71,6 @@
         chArea.setBaselineOffset(font.getAscender());
         setCurrentArea(chArea);
     }
-    
-    /**
-     * Selects a font which is able to display the given character.
-     * <p>
-     * Please note: this implements the font-selection-strategy
-     * character-by-character.
-     * <p>
-     * TODO: The same function could apply to other elements as well.
-     * 
-     * @param fobj
-     *            a Character object containing the character and its
-     *            attributed.
-     * @return a Font object.
-     */
-    private Font selectFontForCharacter(Character fobj) {
-        FontInfo fi = fobj.getFOEventHandler().getFontInfo();
-        FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi);
-        for (int i = 0; i < fontkeys.length; i++) {
-            font = fi.getFontInstance(fontkeys[i],
-                    fobj.getCommonFont().fontSize.getValue(this));
-            if (font.hasChar(fobj.getCharacter())) {
-                return font;
-            }
-        }
-        return fi.getFontInstance(fontkeys[0],
-                fobj.getCommonFont().fontSize.getValue(this));
-    }
 
     private org.apache.fop.area.inline.TextArea getCharacterInlineArea(Character node) {
         org.apache.fop.area.inline.TextArea text



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