xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acumis...@apache.org
Subject svn commit: r654562 [1/2] - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources: ./ src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/apps/ src/java/org/apache/fop/events/ src/java/org/apache/fop/fo/flow/ src/java/org/apache/fop/fo/flow/tab...
Date Thu, 08 May 2008 15:45:27 GMT
Author: acumiskey
Date: Thu May  8 08:45:26 2008
New Revision: 654562

URL: http://svn.apache.org/viewvc?rev=654562&view=rev
Log:
Merged revisions 654111,654121,654190,654314,654322-654323,654338,654347,654437,654461,654528,654557 via svnmerge from 
https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk

........
  r654111 | adelmelle | 2008-05-07 15:04:17 +0100 (Wed, 07 May 2008) | 6 lines
  
  Bugzilla 41500:
  Fixed a ClassCastException when fo:wrapper was used as a child of an fo:block-container.
  Bugzilla 42423:
  Added support for the "id" attribute on fo:wrappers that are children of the fo:flow.
........
  r654121 | adelmelle | 2008-05-07 15:19:13 +0100 (Wed, 07 May 2008) | 1 line
  
  Small correction: use appropriate value for 'context'
........
  r654190 | adelmelle | 2008-05-07 18:41:07 +0100 (Wed, 07 May 2008) | 1 line
  
  Added comment
........
  r654314 | adelmelle | 2008-05-07 23:45:46 +0100 (Wed, 07 May 2008) | 1 line
  
  Corrected errors in ColumnNumberPropertyMaker.java; temporarily disabled two testcases for a non-standard feature
........
  r654322 | acumiskey | 2008-05-08 00:27:45 +0100 (Thu, 08 May 2008) | 1 line
  
  Looks like the serialVersionUID got bumped but the log statement wasn't being completely honest about what it was doing.  FontCache now attempts to delete its cache file so subsequent runs should repopulate it.
........
  r654323 | acumiskey | 2008-05-08 00:29:04 +0100 (Thu, 08 May 2008) | 1 line
  
  Whoops.. small checkstyle nit :)
........
  r654338 | adelmelle | 2008-05-08 01:18:14 +0100 (Thu, 08 May 2008) | 1 line
  
  Removed inadvertently added override [Avoid late night commits...]
........
  r654347 | acumiskey | 2008-05-08 01:33:21 +0100 (Thu, 08 May 2008) | 1 line
  
  Removed tabs.  Checkstyle now configured.  Late nights..  and a new machine build.. :S
........
  r654437 | jeremias | 2008-05-08 08:32:02 +0100 (Thu, 08 May 2008) | 1 line
  
  Checkstyle fix.
........
  r654461 | jeremias | 2008-05-08 10:55:55 +0100 (Thu, 08 May 2008) | 5 lines
  
  Added support for font referencing for auto-detected fonts.
  Referenced TrueType fonts can now use glyphs outside the WinAnsi charset (Same approach as for extended glyph support with Type 1 fonts).
  
  Removed FopFactory reference from FontManager to make the class more useful outside this context (ex. transcoders).
  Updated fonts documentation with information that TTCs are now supported through auto-detection.
........
  r654528 | adelmelle | 2008-05-08 14:56:14 +0100 (Thu, 08 May 2008) | 5 lines
  
  Tweak:
  -> add 'runtimeType' member and toString() to PropertyCache to facilitate debugging
  -> modify the initial assignment in the related Property types accordingly
........
  r654557 | pietsch | 2008-05-08 16:36:02 +0100 (Thu, 08 May 2008) | 1 line
  
  Quick fix for XML validation error
........

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/apps/FopFactory.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/events/EventFormatter.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/Wrapper.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFObj.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CharacterProperty.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/ColorProperty.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonFont.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonHyphenation.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/EnumNumber.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/EnumProperty.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/FixedLength.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/KeepProperty.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/NumberProperty.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/PropertyCache.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/StringProperty.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/EmbedFontInfo.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontCache.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontLoader.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontManager.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSetup.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/LazyFont.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/PrintRendererConfigurator.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSFontUtils.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/status.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/basictests.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/fotree/disabled-testcases.xml
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/layoutengine/disabled-testcases.xml

Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu May  8 08:45:26 2008
@@ -1 +1 @@
-/xmlgraphics/fop/trunk:1-653828
+/xmlgraphics/fop/trunk:1-654561

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=654562&r1=654561&r2=654562&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 Thu May  8 08:45:26 2008
@@ -177,10 +177,8 @@
         if you wanted to add a custom font. This unconvenient step has been removed and in
         addition to that, FOP supports auto-registration of fonts, i.e. FOP can find fonts
         installed in your operating system or can scan user-specified directories for fonts.
-        Font registration via XML font metrics file is still supported and is still necessary
-        if you want to use a TrueType Collection (*.ttc). Direct support for TrueType
-        collections may be added later. Furthermore, the XML font metrics files are still
-        required if you don't want to embed, but only reference a font.
+        Font registration via XML font metrics file is still supported and may still be necessary
+        for some very special cases as fallback variant while we stabilize font auto-detection.
       </p>
       <p>
         Basic information about fonts can be found at:
@@ -375,20 +373,56 @@
       </section>
       <section id="embedding">
         <title>Embedding</title>
-        <note>The PostScript renderer does not yet support TrueType fonts, but can embed Type 1 fonts.</note>
-        <note>The font is simply embedded into the PDF file, it is not converted.</note>
-        <p>Font embedding is enabled in the userconfig.xml file and controlled by the embed-url attribute.
-          If you don't specify the embed-url attribute the font will not be embedded, but will only be referenced.</p>
-        <warning>
-          Omitting the embed-url attribute for CID-encoded TrueType fonts will currently produce invalid 
-          PDF files! If you create the XML font metric file using the "-enc ansi" option, you can omit 
-          the embed-url attribute for TrueType fonts but you're restricted to the WinAnsi character set.
-        </warning>
-        <p>When FOP embeds a font, it adds a prefix to the fontname to ensure that the name will not match the fontname of an installed font.
-          This is helpful with older versions of Acrobat Reader that preferred installed fonts over embedded fonts.</p>
-        <p>When embedding PostScript fonts, the entire font is always embedded.</p>
-        <p>When embedding TrueType fonts (ttf) or TrueType Collections (ttc), a subset of the
-          original font, containing only the glyphs used, is embedded in the output document.</p>
+        <p>
+          By default, all fonts are embedded if an output format supports font embedding. In some
+          cases, however, it is preferred that some fonts are only referenced. When working
+          with referenced fonts it is important to be in control of the target environment where
+          the produced document is consumed, i.e. the necessary fonts have to be installed there.
+        </p>
+        <p>
+          There are two different ways how you can specify that a font should be referenced:
+        </p>
+        <ol>
+          <li>
+            When using the old-style "font" element to configure a single font, font referencing
+            is controlled by the embed-url attribute. If you don't specify the embed-url attribute
+            the font will not be embedded, but will only be referenced.
+          </li>
+          <li>
+            For automatically configured fonts there's a different mechanism to specify which
+            fonts should be referenced rather than embedded. This is done in the "referenced-fonts"
+            element in the configuration. Here's an example:
+          </li>
+        </ol>
+        <source><![CDATA[
+<fop version="1.0">
+   <fonts>
+      <referenced-fonts>
+        <match font-family="Helvetica"/>
+        <match font-family="DejaVu.*"/>
+      </referenced-fonts>
+   </fonts>
+</fop>]]></source>
+        <p>
+          At the moment, you can only match fonts against their font-family. It is possible to use
+          regular expressions as is shown in the second example above ("DejaVu.*"). The syntax for
+          the regular expressions used here are the one used by the
+          <a href="http://java.sun.com/j2se/1.4/docs/api/java/util/regex/package-summary.html"><code>java.util.regex</code> package</a>.
+          So, in the above snippet "Helvetica" and all variants of the "DejaVu" font family are
+          referenced. If you want to reference all fonts, just specify <code>font-family=".*"</code>.
+        </p>
+        <p>
+          Various notes related to embedded fonts:
+        </p>
+        <ul>
+          <li>The PostScript renderer does not yet support TrueType fonts, but can embed Type 1 fonts.</li>
+          <li>The font is simply embedded into the PDF file, it is not converted.</li>
+          <li>When FOP embeds a font, it adds a prefix to the fontname to ensure that the name will not match the fontname of an installed font.
+            This is helpful with older versions of Acrobat Reader that preferred installed fonts over embedded fonts.</li>
+          <li>When embedding PostScript fonts, the entire font is always embedded.</li>
+          <li>When embedding TrueType fonts (ttf) or TrueType Collections (ttc), a subset of the
+          original font, containing only the glyphs used, is embedded in the output document.</li>
+        </ul>
       </section>
       <section id="substitution">
          <title>Substitution</title>

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactory.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactory.java Thu May  8 08:45:26 2008
@@ -692,12 +692,19 @@
     }
     
     /**
-     * Returns the font manager
+     * Returns the font manager.
      * @return the font manager
      */
     public FontManager getFontManager() {
         if (fontManager == null) {
-            this.fontManager = new FontManager(this);
+            this.fontManager = new FontManager() {
+                
+                /** {@inheritDoc} */
+                public void setFontBaseURL(String fontBase) throws MalformedURLException {
+                    super.setFontBaseURL(getFOURIResolver().checkBaseURL(fontBase));
+                }
+                
+            };
         }
         return this.fontManager;
     }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactoryConfigurator.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactoryConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactoryConfigurator.java Thu May  8 08:45:26 2008
@@ -23,15 +23,17 @@
 import java.io.IOException;
 import java.net.MalformedURLException;
 
+import org.xml.sax.SAXException;
+
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.fonts.FontManager;
 import org.apache.fop.fonts.FontManagerConfigurator;
 import org.apache.fop.util.LogUtil;
-import org.xml.sax.SAXException;
 
 /**
  * FopFactory configurator
@@ -174,7 +176,7 @@
         // configure font manager
         FontManager fontManager = factory.getFontManager();
         FontManagerConfigurator fontManagerConfigurator = new FontManagerConfigurator(cfg);
-        fontManagerConfigurator.configure(fontManager);
+        fontManagerConfigurator.configure(fontManager, strict);
     }
     
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/events/EventFormatter.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/events/EventFormatter.xml?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/events/EventFormatter.xml (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/events/EventFormatter.xml Thu May  8 08:45:26 2008
@@ -26,9 +26,10 @@
   <message key="rule.childOfSPM">The element must be a child of fo:simple-page-master.</message>
   <message key="rule.childOfDeclarations">The element must be a child of fo:declarations.</message>
   <message key="rule.childOfSPMorDeclarations">The element must be a child of fo:declarations or fo:simple-page-master.</message>
+  <message key="rule.wrapperInvalidChildForParent">An fo:wrapper is only permitted to have children that would be permitted for its parent.</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.tooManyNodes">For "{elementName}", only one "{offendingNode}" may be declared.{{locator}}</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.nodeOutOfOrder">For "{elementName}", "{tooLateNode}" must be declared before "{tooEarlyNode}"!{{locator}}</message>
-  <message key="org.apache.fop.fo.FOValidationEventProducer.invalidChild">"{offendingNode}" is not a valid child element of "{elementName}"![ {ruleViolated,lookup}]{{locator}}</message>
+  <message key="org.apache.fop.fo.FOValidationEventProducer.invalidChild">"{offendingNode}" is not a valid child of "{elementName}"![ {ruleViolated,lookup}]{{locator}}</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.missingChildElement">"{elementName}" is missing child elements.[
 Required content model: {contentModel}]{{locator}}</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.missingProperty">Element "{elementName}" is missing required property "{propertyName}"!{{locator}}</message>

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/Wrapper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/Wrapper.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/Wrapper.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/Wrapper.java Thu May  8 08:45:26 2008
@@ -22,9 +22,10 @@
 import org.xml.sax.Locator;
 
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FOText;
 import org.apache.fop.fo.FObjMixed;
-import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
 
 /**
@@ -39,25 +40,15 @@
     
     // used for FO validation
     private boolean blockOrInlineItemFound = false;
-    private boolean inlineChildrenAllowed = false;
 
     /**
-     * Base constructor
+     * Create a Wrapper instance that is a child of the
+     * given {@link FONode}
      * 
      * @param parent {@link FONode} that is the parent of this object
      */
     public Wrapper(FONode parent) {
         super(parent);
-        /* Check if the fo:wrapper is a child of a FO that allows mixed content
-         * (or a descendant in nested fo:wrapper sequence, the first of which
-         *  is a child of a FO that allows mixed content) */
-        FONode ancestor = this.parent;
-        while (ancestor instanceof Wrapper) {
-            ancestor = ancestor.getParent();
-        }
-        if (ancestor instanceof FObjMixed ) {
-            inlineChildrenAllowed = true;
-        }
     }
 
     /**
@@ -66,7 +57,6 @@
      * <br><i>Additionally (unimplemented): "An fo:wrapper that is a child of an 
      * fo:multi-properties is only permitted to have children that would 
      * be permitted in place of the fo:multi-properties."</i>
-     * 
      */
     protected void validateChildNode(Locator loc, String nsURI, String localName) 
         throws ValidationException {
@@ -77,8 +67,17 @@
                         "(#PCDATA|%inline;|%block;)");
                 }
             } else if (isBlockOrInlineItem(nsURI, localName)) {
-                //delegate validation to parent
-                FONode.validateChildNode(this.parent, loc, nsURI, localName);
+                /* delegate validation to parent, but keep the error reporting
+                 * tidy. If we would simply call validateChildNode() on the
+                 * parent, the user would get a wrong impression, as only the
+                 * locator (if any) will contain a reference to the offending
+                 * fo:wrapper.
+                 */
+                try {
+                    FONode.validateChildNode(this.parent, loc, nsURI, localName);
+                } catch (ValidationException vex) {
+                    invalidChildError(loc, getName(), FO_URI, localName, "rule.wrapperInvalidChildForParent");
+                }
                 blockOrInlineItemFound = true;
             } else {
                 invalidChildError(loc, nsURI, localName);
@@ -87,15 +86,27 @@
     }
 
     /** {@inheritDoc} */
-    protected void addCharacters(
-                char[] data, 
-                int start, 
-                int end, 
-                PropertyList pList, 
-                Locator locator) throws FOPException {
-        /* Only add text if the fo:wrapper's parent allows inline children */
-        if (this.inlineChildrenAllowed) {
-            super.addCharacters(data, start, end, pList, locator);
+    protected void addChildNode(FONode child) throws FOPException {
+        super.addChildNode(child);
+        /* If the child is a text node, and it generates areas
+         * (i.e. contains either non-white-space or preserved
+         * white-space), then check whether the nearest non-wrapper
+         * ancestor allows this.
+         */
+        if (child instanceof FOText
+                && ((FOText)child).willCreateArea()) {
+            FONode ancestor = parent;
+            while (ancestor.getNameId() == Constants.FO_WRAPPER) {
+                ancestor = ancestor.getParent();
+            }
+            if (!(ancestor instanceof FObjMixed)) {
+                invalidChildError(
+                        getLocator(),
+                        getLocalName(),
+                        FONode.FO_URI,
+                        "#PCDATA",
+                        "rule.wrapperInvalidChildForParent");
+            }
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFObj.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFObj.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/flow/table/TableFObj.java Thu May  8 08:45:26 2008
@@ -51,7 +51,7 @@
 
     /**
      * Main constructor
-     * 
+     *
      * @param parent    the parent node
      */
     public TableFObj(FONode parent) {
@@ -76,7 +76,7 @@
     }
 
     /**
-     * 
+     *
      * @param side  the side for which to return the border precedence
      * @return the "border-precedence" value for the given side
      */
@@ -98,9 +98,9 @@
     /**
      * Convenience method to returns a reference
      * to the base Table instance
-     * 
+     *
      * @return  the base table instance
-     * 
+     *
      */
     public Table getTable() {
         // Will be overridden in Table; for any other Table-node, recursive call to
@@ -142,7 +142,7 @@
          * Check the value of the column-number property.
          * Return the parent's column index (initial value) in case
          * of a negative or zero value
-         * 
+         *
          * @see org.apache.fop.fo.properties.PropertyMaker#make(PropertyList, String, FObj)
          */
         public Property make(PropertyList propertyList, String value, FObj fo)
@@ -155,15 +155,18 @@
             int columnIndex = p.getNumeric().getValue();
             int colSpan = propertyList.get(Constants.PR_NUMBER_COLUMNS_SPANNED)
                                 .getNumeric().getValue();
-            int i = -1;
-            while (++i < colSpan) {
-                if (columnIndexManager.isColumnNumberUsed(columnIndex + i)) {
+            
+            int i = columnIndex - 1;
+            int lastIndex = (columnIndex + colSpan) - 1;
+            while (++i < lastIndex) {
+                if (columnIndexManager.isColumnNumberUsed(i)) {
                     /* if column-number is already in use by another
                      * cell/column => error!
                      */
                     TableEventProducer eventProducer = TableEventProducer.Provider.get(
                             fo.getUserAgent().getEventBroadcaster());
-                    eventProducer.cellOverlap(this, fo.getName(), columnIndex + 1, fo.getLocator());
+                    eventProducer.cellOverlap(this, propertyList.getFObj().getName(),
+                                                i, fo.getLocator());
                 }
             }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.java Thu May  8 08:45:26 2008
@@ -41,7 +41,11 @@
      */
     public static class Maker extends ListProperty.Maker {
 
-        /** {@inheritDoc} */
+        /**
+         * Construct an instance of a Maker for the given property.
+         * 
+         * @param propId The Constant ID of the property to be made.
+         */
         public Maker(int propId) {
             super(propId);
         }
@@ -72,7 +76,7 @@
          * Returns a {@link org.apache.fop.datatypes.PercentBase} whose
          * <code>getDimension()</code> returns 1.
          */
-        public PercentBase getPercentBase() {
+        public PercentBase getPercentBase(PropertyList pl) {
             return new PercentBase() {
                 /** {@inheritDoc} */
                 public int getBaseLength(PercentBaseContext context) throws PropertyException {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CharacterProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CharacterProperty.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CharacterProperty.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CharacterProperty.java Thu May  8 08:45:26 2008
@@ -48,7 +48,7 @@
     }
 
     /** cache containing all canonical CharacterProperty instances */
-    private static final PropertyCache cache = new PropertyCache();
+    private static final PropertyCache cache = new PropertyCache(CharacterProperty.class);
 
     private final char character;
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/ColorProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/ColorProperty.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/ColorProperty.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/ColorProperty.java Thu May  8 08:45:26 2008
@@ -33,7 +33,7 @@
 public final class ColorProperty extends Property  {
     
     /** cache holding canonical ColorProperty instances */
-    private static final PropertyCache cache = new PropertyCache();
+    private static final PropertyCache cache = new PropertyCache(ColorProperty.class);
     
     /**
      * The color represented by this property.
@@ -92,6 +92,8 @@
      * 
      * @param foUserAgent FOP user agent
      * @param value RGB value as String to be parsed
+     * @return the canonical ColorProperty instance corresponding 
+     *         to the given value
      * @throws PropertyException if the value can't be parsed
      * @see ColorUtil#parseColorString(FOUserAgent, String)
      */
@@ -99,19 +101,10 @@
         ColorProperty instance = new ColorProperty(
                                        ColorUtil.parseColorString(
                                                foUserAgent, value));
-        return (ColorProperty) cache.fetch(instance);
+        return (ColorProperty)cache.fetch(instance);
     }
 
     /**
-     * Returns an instance of a color property given a color
-     * @param color the color value
-     * @return the color property
-     */
-    public static ColorProperty getInstance(Color color) {
-        return (ColorProperty) cache.fetch(new ColorProperty(color));
-    }
-    
-    /**
      * Create a new ColorProperty with a given color.
      * 
      * @param value the color to use.

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonFont.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonFont.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonFont.java Thu May  8 08:45:26 2008
@@ -37,7 +37,7 @@
 
     /** cache holding canonical CommonFont instances (only those with
      *  absolute font-size and font-size-adjust) */
-    private static final PropertyCache cache = new PropertyCache();
+    private static final PropertyCache cache = new PropertyCache(CommonFont.class);
     
     /**
      * Class holding canonical instances of bundles of the
@@ -47,7 +47,7 @@
     protected static final class CachedCommonFont {
         
         /** cache holding all canonical instances */
-        private static final PropertyCache cache = new PropertyCache();
+        private static final PropertyCache cache = new PropertyCache(CachedCommonFont.class);
         
         private int hash = 0;
         

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonHyphenation.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonHyphenation.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonHyphenation.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/CommonHyphenation.java Thu May  8 08:45:26 2008
@@ -38,7 +38,7 @@
     /** Logger */
     protected static Log log = LogFactory.getLog(CommonHyphenation.class);
     
-    private static final PropertyCache cache = new PropertyCache();
+    private static final PropertyCache cache = new PropertyCache(CommonHyphenation.class);
     
     private int hash = 0;
     

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/EnumNumber.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/EnumNumber.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/EnumNumber.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/EnumNumber.java Thu May  8 08:45:26 2008
@@ -29,7 +29,7 @@
 public final class EnumNumber extends Property implements Numeric {
 
     /** cache holding all canonical EnumNumber instances */
-    private static final PropertyCache cache = new PropertyCache();
+    private static final PropertyCache cache = new PropertyCache(EnumNumber.class);
 
     private final EnumProperty enumProperty;
     

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/EnumProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/EnumProperty.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/EnumProperty.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/EnumProperty.java Thu May  8 08:45:26 2008
@@ -29,7 +29,7 @@
 public final class EnumProperty extends Property {
     
     /** cache holding all canonical EnumProperty instances */
-    private static final PropertyCache cache = new PropertyCache();
+    private static final PropertyCache cache = new PropertyCache(EnumProperty.class);
 
     /**
      * Inner class for creating EnumProperty instances

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/FixedLength.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/FixedLength.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/FixedLength.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/FixedLength.java Thu May  8 08:45:26 2008
@@ -45,7 +45,7 @@
     public static final String MPT = "mpt";
 
     /** cache holding all canonical FixedLength instances */
-    private static final PropertyCache cache = new PropertyCache();
+    private static final PropertyCache cache = new PropertyCache(FixedLength.class);
     
     /** canonical zero-length instance */
     public static final FixedLength ZERO_FIXED_LENGTH = new FixedLength(0, FixedLength.MPT, 1.0f);

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java Thu May  8 08:45:26 2008
@@ -31,7 +31,7 @@
 public final class FontFamilyProperty extends ListProperty {
 
     /** cache holding all canonical FontFamilyProperty instances */
-    private static final PropertyCache cache = new PropertyCache();
+    private static final PropertyCache cache = new PropertyCache(FontFamilyProperty.class);
     
     private int hash = 0;
     

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/KeepProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/KeepProperty.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/KeepProperty.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/KeepProperty.java Thu May  8 08:45:26 2008
@@ -30,7 +30,7 @@
 public final class KeepProperty extends Property implements CompoundDatatype {
     
     /** class holding all canonical KeepProperty instances*/
-    private static final PropertyCache cache = new PropertyCache();
+    private static final PropertyCache cache = new PropertyCache(KeepProperty.class);
     
     private boolean isCachedValue = false;
     private Property withinLine;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/NumberProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/NumberProperty.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/NumberProperty.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/NumberProperty.java Thu May  8 08:45:26 2008
@@ -103,7 +103,7 @@
     }
     
     /** cache holding all canonical NumberProperty instances */
-    private static final PropertyCache cache = new PropertyCache();
+    private static final PropertyCache cache = new PropertyCache(NumberProperty.class);
     
     private final Number number;
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/PropertyCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/PropertyCache.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/PropertyCache.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/PropertyCache.java Thu May  8 08:45:26 2008
@@ -42,7 +42,9 @@
     /** the table of hash-buckets */
     private CacheEntry[] table = new CacheEntry[8];
     
-    boolean[] votesForRehash = new boolean[SEGMENT_MASK + 1];
+    private Class runtimeType;
+    
+    final boolean[] votesForRehash = new boolean[SEGMENT_MASK + 1];
     
     /* same hash function as used by java.util.HashMap */
     private static int hash(Object x) {
@@ -80,10 +82,10 @@
     /* Wrapper objects to synchronize on */
     private final class CacheSegment {
         private int count = 0;
-        private ReferenceQueue staleEntries = new ReferenceQueue();
+        private volatile ReferenceQueue staleEntries = new ReferenceQueue();
     }    
     
-    private final void cleanSegment(int segmentIndex) {
+    private void cleanSegment(int segmentIndex) {
         CacheEntry entry;
         CacheSegment segment = segments[segmentIndex];
         int bucketIndex;
@@ -113,29 +115,26 @@
         }
         synchronized (votesForRehash) {
             if (oldCount > segment.count) {
-                if (votesForRehash[segmentIndex]) {
-                    votesForRehash[segmentIndex] = false;
-                }
+                votesForRehash[segmentIndex] = false;
                 return;
-            } else {
-                /* cleanup had no effect */
-                if (!votesForRehash[segmentIndex]) {
-                    /* first time for this segment */
-                    votesForRehash[segmentIndex] = true;
-                    int voteCount = 0;
-                    for (int i = SEGMENT_MASK + 1; --i >= 0; ) {
-                        if (votesForRehash[i]) {
-                            voteCount++;
-                        }
+            }
+            /* cleanup had no effect */
+            if (!votesForRehash[segmentIndex]) {
+                /* first time for this segment */
+                votesForRehash[segmentIndex] = true;
+                int voteCount = 0;
+                for (int i = SEGMENT_MASK + 1; --i >= 0; ) {
+                    if (votesForRehash[i]) {
+                        voteCount++;
                     }
-                    if (voteCount > SEGMENT_MASK / 4) {
-                        rehash(SEGMENT_MASK);
-                        /* reset votes */
-                        for (int i = SEGMENT_MASK + 1; --i >= 0;) {
-                            votesForRehash[i] = false;
-                        }
-    
+                }
+                if (voteCount > SEGMENT_MASK / 4) {
+                    rehash(SEGMENT_MASK);
+                    /* reset votes */
+                    for (int i = SEGMENT_MASK + 1; --i >= 0;) {
+                        votesForRehash[i] = false;
                     }
+
                 }
             }
         }
@@ -148,7 +147,7 @@
      * cleanup will be performed to try and remove obsolete
      * entries.
      */
-    private final void put(Object o) {
+    private void put(Object o) {
         
         int hash = hash(o);
         CacheSegment segment = segments[hash & SEGMENT_MASK];
@@ -180,7 +179,7 @@
     
 
     /* Gets a cached instance. Returns null if not found */
-    private final Object get(Object o) {
+    private Object get(Object o) {
         
         int hash = hash(o);
         int index = hash & (table.length - 1);
@@ -219,7 +218,7 @@
      * extends the cache and redistributes the entries.
      * 
      */
-    private final void rehash(int index) {
+    private void rehash(int index) {
         
         CacheSegment seg = segments[index];
         synchronized (seg) {
@@ -258,12 +257,15 @@
     }
     
     /**
-     *  Default constructor. 
+     *  Default constructor.
+     *  
+     *  @param c    Runtime type of the objects that will be stored in the cache
      */
-    public PropertyCache() {
+    public PropertyCache(Class c) {
         for (int i = SEGMENT_MASK + 1; --i >= 0;) {
             segments[i] = new CacheSegment();
         }
+        this.runtimeType = c;
     }
     
     /**
@@ -275,7 +277,7 @@
      *  @param obj   the Object to check for
      *  @return  the cached instance
      */
-    private final Object fetch(Object obj) {
+    private Object fetch(Object obj) {
         if (obj == null) {
             return null;
         }
@@ -339,4 +341,11 @@
         
         return (CommonFont) fetch((Object) cf);
     }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return super.toString() + "[runtimeType=" + this.runtimeType + "]";
+    }
+    
+    
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/StringProperty.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/StringProperty.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/StringProperty.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fo/properties/StringProperty.java Thu May  8 08:45:26 2008
@@ -72,13 +72,16 @@
                     value = str;
                 }
             }
-            return new StringProperty(value);
+            return StringProperty.getInstance(value);
         }
 
-    }    // end String.Maker
+    }
 
     /** cache containing all canonical StringProperty instances */
-    private static final PropertyCache cache = new PropertyCache();
+    private static final PropertyCache cache = new PropertyCache(StringProperty.class);
+    
+    /** canonical instance for empty strings */
+    public static final StringProperty EMPTY_STRING_PROPERTY = new StringProperty("");
     
     private final String str;
 
@@ -97,40 +100,38 @@
      * @return  the canonical instance
      */
     public static StringProperty getInstance(String str) {
-        return (StringProperty)cache.fetch(
-                   new StringProperty(str));
+        if ("".equals(str) || str == null) {
+            return EMPTY_STRING_PROPERTY;
+        } else {
+            return (StringProperty)cache.fetch(
+                       new StringProperty(str));
+        }
     }
     
-    /**
-     * @return the Object equivalent of this property
-     */
+    /** @return the Object equivalent of this property */
     public Object getObject() {
         return this.str;
     }
 
-    /**
-     * @return the String equivalent of this property
-     */
+    /** @return the String equivalent of this property */
     public String getString() {
         return this.str;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
         if (obj instanceof StringProperty) {
             StringProperty sp = (StringProperty)obj;
             return (sp.str == this.str
                     || sp.str.equals(this.str));
-        } else {
-            return false;
         }
+        return false;
     }
     
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public int hashCode() {
         return str.hashCode();
     }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/EmbedFontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/EmbedFontInfo.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/EmbedFontInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/EmbedFontInfo.java Thu May  8 08:45:26 2008
@@ -19,6 +19,7 @@
  
 package org.apache.fop.fonts;
 
+import java.io.IOException;
 import java.io.Serializable;
 import java.util.List;
 
@@ -45,6 +46,8 @@
     /** the list of associated font triplets */
     private List/*<FontTriplet>*/ fontTriplets = null;
 
+    private transient boolean embedded = true;
+    
     /**
      * Main constructor
      * @param metricsFile Path to the xml file containing font metrics
@@ -120,11 +123,37 @@
     }
     
     /**
-     * {@inheritDoc}
+     * Indicates whether the font is only referenced rather than embedded.
+     * @return true if the font is embedded, false if it is referenced.
+     */
+    public boolean isEmbedded() {
+        if (metricsFile != null && embedFile == null) {
+            return false;
+        } else {
+            return this.embedded;
+        }
+    }
+    
+    /**
+     * Defines whether the font is embedded or not.
+     * @param value true to embed the font, false to reference it
      */
+    public void setEmbedded(boolean value) {
+        this.embedded = value;
+    }
+    
+    private void readObject(java.io.ObjectInputStream in)
+                throws IOException, ClassNotFoundException {
+        in.defaultReadObject();
+        this.embedded = true;
+    }
+    
+    /** {@inheritDoc} */
     public String toString() {
         return "metrics-url=" + metricsFile + ",embed-url=" + embedFile
             + ", kerning=" + kerning + ", " + "font-triplet=" + fontTriplets
-            + (getSubFontName() != null ? ", sub-font=" + getSubFontName() : ""); 
+            + (getSubFontName() != null ? ", sub-font=" + getSubFontName() : "")
+            + (isEmbedded() ? "" : ", NOT embedded"); 
     }
+
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontCache.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontCache.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontCache.java Thu May  8 08:45:26 2008
@@ -151,6 +151,11 @@
                 //We don't really care about the exception since it's just a cache file
                 log.warn("I/O exception while reading font cache (" + ioe.getMessage() 
                         + "). Discarding font cache file.");
+                try {
+                    cacheFile.delete();
+                } catch (SecurityException ex) {
+                    log.warn("Failed to delete font cache file: " + cacheFile.getAbsolutePath());
+                }
             }
         }
         return null;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontLoader.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontLoader.java Thu May  8 08:45:26 2008
@@ -39,9 +39,7 @@
  */
 public abstract class FontLoader {
 
-    /**
-     * logging instance
-     */
+    /** logging instance */
     protected static Log log = LogFactory.getLog(FontLoader.class);
 
     /** URI representing the font file */
@@ -53,14 +51,18 @@
 
     /** true if the font has been loaded */
     protected boolean loaded = false;
+    /** true if the font will be embedded, false if it will be referenced only. */
+    protected boolean embedded = true;
 
     /**
      * 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 resolver the font resolver used to resolve URIs
      */
-    public FontLoader(String fontFileURI, FontResolver resolver) {
+    public FontLoader(String fontFileURI, boolean embedded, FontResolver resolver) {
         this.fontFileURI = fontFileURI;
+        this.embedded = embedded;
         this.resolver = resolver;
     }
 
@@ -72,46 +74,48 @@
      * Loads a custom font from a File. In the case of Type 1 fonts, the PFB file must be specified.
      * @param fontFile the File representation of the font
      * @param subFontName the sub-fontname of a font (for TrueType Collections, null otherwise)
+     * @param embedded indicates whether the font is embedded or referenced
      * @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(File fontFile, String subFontName, FontResolver resolver)
-                throws IOException {
-        return loadFont(fontFile.getAbsolutePath(), subFontName, resolver);
+    public static CustomFont loadFont(File fontFile, String subFontName,
+            boolean embedded, FontResolver resolver) throws IOException {
+        return loadFont(fontFile.getAbsolutePath(), subFontName, embedded, resolver);
     }
 
     /**
      * Loads a custom font from an URL. In the case of Type 1 fonts, the PFB file must be specified.
      * @param fontUrl the URL representation of the font
      * @param subFontName the sub-fontname of a font (for TrueType Collections, null otherwise)
+     * @param embedded indicates whether the font is embedded or referenced
      * @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(URL fontUrl, String subFontName, FontResolver resolver)
-                throws IOException {
-        return loadFont(fontUrl.toExternalForm(), subFontName, resolver);
+    public static CustomFont loadFont(URL fontUrl, String subFontName,
+            boolean embedded, FontResolver resolver) throws IOException {
+        return loadFont(fontUrl.toExternalForm(), subFontName, embedded, resolver);
     }
     
-    
     /**
      * Loads a custom font from a URI. In the case of Type 1 fonts, the PFB file must be specified.
      * @param fontFileURI the URI to the font
      * @param subFontName the sub-fontname of a font (for TrueType Collections, null otherwise)
+     * @param embedded indicates whether the font is embedded or referenced
      * @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, FontResolver resolver)
-                throws IOException {
+    public static CustomFont loadFont(String fontFileURI, String subFontName,
+            boolean embedded, FontResolver resolver) throws IOException {
         fontFileURI = fontFileURI.trim();
         boolean type1 = isType1(fontFileURI);
         FontLoader loader;
         if (type1) {
-            loader = new Type1FontLoader(fontFileURI, resolver);
+            loader = new Type1FontLoader(fontFileURI, embedded, resolver);
         } else {
-            loader = new TTFFontLoader(fontFileURI, subFontName, resolver);
+            loader = new TTFFontLoader(fontFileURI, subFontName, embedded, resolver);
         }
         return loader.getFont();
     }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontManager.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontManager.java Thu May  8 08:45:26 2008
@@ -25,7 +25,7 @@
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
 
-import org.apache.fop.apps.FopFactory;
+import org.apache.fop.fonts.FontTriplet.Matcher;
 import org.apache.fop.fonts.substitute.FontSubstitutions;
 import org.apache.fop.render.PrintRenderer;
 
@@ -34,7 +34,8 @@
 // and start using POJO config/properties type classes
 
 /**
- * The manager of fonts
+ * The manager of fonts. The class holds a reference to the font cache and information about
+ * font substitution, referenced fonts and similar.
  */
 public class FontManager {
     /** Use cache (record previously detected font triplet info) */
@@ -49,42 +50,31 @@
     /** Font substitutions */
     private FontSubstitutions fontSubstitutions = null;
 
-    private FopFactory fopFactory = null;
-
     /** Allows enabling kerning on the base 14 fonts, default is false */
     private boolean enableBase14Kerning = false;
 
+    /** FontTriplet matcher for fonts that shall be referenced rather than embedded. */
+    private FontTriplet.Matcher referencedFontsMatcher;
+
     /**
      * Main constructor
-     * 
-     * @param fopFactory the fo URI resolver
      */
-    public FontManager(FopFactory fopFactory) {
-        this(fopFactory, DEFAULT_USE_CACHE);
-    }
-    
-    /**
-     * Constructor
-     * 
-     * @param fopFactory the fo URI resolver
-     * @param useCache true if the FontCache should be used
-     */
-    public FontManager(FopFactory fopFactory, boolean useCache) {
-        this.fopFactory  = fopFactory;
-        setUseCache(useCache);
+    public FontManager() {
+        setUseCache(DEFAULT_USE_CACHE);
     }
     
     /**
      * Sets the font base URL.
      * @param fontBase font base URL
-     * @throws MalformedURLException if there's a problem with a file URL
+     * @throws MalformedURLException if there's a problem with a URL
      */
     public void setFontBaseURL(String fontBase) throws MalformedURLException {
-        this.fontBase = fopFactory.getFOURIResolver().checkBaseURL(fontBase);
+        this.fontBase = fontBase;
     }
 
     /**
-     * @return the font base URL
+     * Returns the font base URL.
+     * @return the font base URL (or null if none was set)
      */
     public String getFontBaseURL() {
         return this.fontBase;
@@ -218,4 +208,22 @@
             }
         };
     }
+
+    /**
+     * Sets the {@link FontTriplet.Matcher} that can be used to identify the fonts that shall
+     * be referenced rather than embedded.
+     * @param matcher the font triplet matcher
+     */
+    public void setReferencedFontsMatcher(FontTriplet.Matcher matcher) {
+        this.referencedFontsMatcher = matcher;
+    }
+
+    /**
+     * Gets the {@link FontTriplet.Matcher} that can be used to identify the fonts that shall
+     * be referenced rather than embedded.
+     * @return the font triplet matcher (or null if none is set)
+     */
+    public Matcher getReferencedFontsMatcher() {
+        return this.referencedFontsMatcher;
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontManagerConfigurator.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontManagerConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontManagerConfigurator.java Thu May  8 08:45:26 2008
@@ -20,11 +20,14 @@
 package org.apache.fop.fonts;
 
 import java.net.MalformedURLException;
+import java.util.List;
+import java.util.regex.Pattern;
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fonts.substitute.FontSubstitutions;
 import org.apache.fop.fonts.substitute.FontSubstitutionsConfigurator;
@@ -51,9 +54,11 @@
     /**
      * Initializes font settings from the user configuration
      * @param fontManager a font manager
-     * @throws FOPException fop exception
+     * @param strict true if strict checking of the configuration is enabled
+     * @throws FOPException if an exception occurs while processing the configuration
      */
-    public void configure(FontManager fontManager) throws FOPException {
+    public void configure(FontManager fontManager, boolean strict) throws FOPException {
+        
         // caching (fonts)
         if (cfg.getChild("use-cache", false) != null) {
             try {
@@ -84,6 +89,68 @@
                 fontSubstitutionsConfigurator.configure(substitutions);
                 fontManager.setFontSubstitutions(substitutions);
             }
+            
+            // referenced fonts (fonts which are not to be embedded)
+            Configuration referencedFontsCfg = fontsCfg.getChild("referenced-fonts", false);
+            if (referencedFontsCfg != null) {
+                createReferencedFontsMatcher(referencedFontsCfg, strict, fontManager);
+            }
+
         }
-    }    
+    }
+
+    private static void createReferencedFontsMatcher(Configuration referencedFontsCfg,
+            boolean strict, FontManager fontManager) throws FOPException {
+        List matcherList = new java.util.ArrayList();
+        Configuration[] matches = referencedFontsCfg.getChildren("match");
+        for (int i = 0; i < matches.length; i++) {
+            try {
+                matcherList.add(new FontFamilyRegExFontTripletMatcher(
+                        matches[i].getAttribute("font-family")));
+            } catch (ConfigurationException ce) {
+                LogUtil.handleException(log, ce, strict);
+                continue;
+            }
+        }
+        FontTriplet.Matcher orMatcher = new OrFontTripletMatcher(
+                (FontTriplet.Matcher[])matcherList.toArray(
+                        new FontTriplet.Matcher[matcherList.size()]));
+        fontManager.setReferencedFontsMatcher(orMatcher);
+    }
+
+    private static class OrFontTripletMatcher implements FontTriplet.Matcher {
+
+        private FontTriplet.Matcher[] matchers;
+        
+        public OrFontTripletMatcher(FontTriplet.Matcher[] matchers) {
+            this.matchers = matchers;
+        }
+        
+        /** {@inheritDoc} */
+        public boolean matches(FontTriplet triplet) {
+            for (int i = 0, c = matchers.length; i < c; i++) {
+                if (matchers[i].matches(triplet)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+        
+    }
+    
+    private static class FontFamilyRegExFontTripletMatcher implements FontTriplet.Matcher {
+
+        private Pattern regex;
+        
+        public FontFamilyRegExFontTripletMatcher(String regex) {
+            this.regex = Pattern.compile(regex);
+        }
+        
+        /** {@inheritDoc} */
+        public boolean matches(FontTriplet triplet) {
+            return regex.matcher(triplet.getName()).matches();
+        }
+        
+    }
+    
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSetup.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSetup.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSetup.java Thu May  8 08:45:26 2008
@@ -27,6 +27,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.fonts.base14.Courier;
 import org.apache.fop.fonts.base14.CourierBold;
 import org.apache.fop.fonts.base14.CourierBoldOblique;
@@ -205,20 +206,12 @@
         }
         
         String internalName = null;
-        //FontReader reader = null;
 
         for (int i = 0; i < embedFontInfoList.size(); i++) {
             EmbedFontInfo embedFontInfo = (EmbedFontInfo)embedFontInfoList.get(i);
 
-            //String metricsFile = configFontInfo.getMetricsFile();
             internalName = "F" + num;
             num++;
-            /*
-            reader = new FontReader(metricsFile);
-            reader.useKerning(configFontInfo.getKerning());
-            reader.setFontEmbedPath(configFontInfo.getEmbedFile());
-            fontInfo.addMetrics(internalName, reader.getFont());
-            */
             
             LazyFont font = new LazyFont(embedFontInfo, resolver);
             fontInfo.addMetrics(internalName, font);

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontTriplet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontTriplet.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontTriplet.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontTriplet.java Thu May  8 08:45:26 2008
@@ -128,5 +128,20 @@
     public String toString() {
         return getKey();
     }
+    
+    
+    /**
+     * Matcher interface for {@link FontTriplet}.
+     */
+    public interface Matcher {
+        
+        /**
+         * Indicates whether the given {@link FontTriplet} matches a particular criterium.
+         * @param triplet the font triplet
+         * @return true if the font triplet is a match
+         */
+        boolean matches(FontTriplet triplet);
+    }
+    
 }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/LazyFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/LazyFont.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/LazyFont.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/LazyFont.java Thu May  8 08:45:26 2008
@@ -44,6 +44,7 @@
     private String metricsFileName = null;
     private String fontEmbedPath = null;
     private boolean useKerning = false;
+    private boolean embedded = true;
     private String subFontName = null;
 
     private boolean isMetricsLoaded = false;
@@ -63,6 +64,7 @@
         this.fontEmbedPath = fontInfo.getEmbedFile();
         this.useKerning = fontInfo.getKerning();
         this.subFontName = fontInfo.getSubFontName();
+        this.embedded = fontInfo.isEmbedded();
         this.resolver = resolver;
     }
 
@@ -118,14 +120,17 @@
                                     new URL(metricsFileName).openStream()));
                     }
                     reader.setKerningEnabled(useKerning);
-                    reader.setFontEmbedPath(fontEmbedPath);
+                    if (this.embedded) {
+                        reader.setFontEmbedPath(fontEmbedPath);
+                    }
                     reader.setResolver(resolver);
                     realFont = reader.getFont();
                 } else {
                     if (fontEmbedPath == null) {
                         throw new RuntimeException("Cannot load font. No font URIs available.");
                     }
-                    realFont = FontLoader.loadFont(fontEmbedPath, this.subFontName, resolver);
+                    realFont = FontLoader.loadFont(fontEmbedPath, this.subFontName,
+                            this.embedded, resolver);
                 }
                 if (realFont instanceof FontDescriptor) {
                     realFontDescriptor = (FontDescriptor) realFont;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java Thu May  8 08:45:26 2008
@@ -223,7 +223,8 @@
                     log.debug("Loading " + fontName);
                 }
                 try {
-                    TTFFontLoader ttfLoader = new TTFFontLoader(fontFileURI, fontName, resolver);
+                    TTFFontLoader ttfLoader = new TTFFontLoader(
+                            fontFileURI, fontName, true, resolver);
                     customFont = ttfLoader.getFont();
                     if (this.eventListener != null) {
                         customFont.setEventListener(this.eventListener);
@@ -247,7 +248,7 @@
         } else {
             // The normal case
             try {
-                customFont = FontLoader.loadFont(fontUrl, null, resolver);
+                customFont = FontLoader.loadFont(fontUrl, null, true, resolver);
                 if (this.eventListener != null) {
                     customFont.setEventListener(this.eventListener);
                 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java Thu May  8 08:45:26 2008
@@ -27,11 +27,16 @@
 
 import org.apache.commons.io.IOUtils;
 
+import org.apache.xmlgraphics.fonts.Glyphs;
+
 import org.apache.fop.fonts.BFEntry;
 import org.apache.fop.fonts.CIDFontType;
 import org.apache.fop.fonts.FontLoader;
 import org.apache.fop.fonts.FontResolver;
+import org.apache.fop.fonts.FontType;
 import org.apache.fop.fonts.MultiByteFont;
+import org.apache.fop.fonts.NamedCharacter;
+import org.apache.fop.fonts.SingleByteFont;
 
 /**
  * Loads a TrueType font into memory directly from the original font file.
@@ -39,6 +44,7 @@
 public class TTFFontLoader extends FontLoader {
 
     private MultiByteFont multiFont;
+    private SingleByteFont singleFont;
     private String subFontName;
     
     /**
@@ -47,7 +53,7 @@
      * @param resolver the FontResolver for font URI resolution
      */
     public TTFFontLoader(String fontFileURI, FontResolver resolver) {
-        this(fontFileURI, null, resolver);
+        this(fontFileURI, null, true, resolver);
     }
     
     /**
@@ -55,10 +61,12 @@
      * @param fontFileURI the URI representing the font file
      * @param subFontName the sub-fontname of a font in a TrueType Collection (or null for normal
      *          TrueType fonts)
+     * @param embedded indicates whether the font is embedded or referenced
      * @param resolver the FontResolver for font URI resolution
      */
-    public TTFFontLoader(String fontFileURI, String subFontName, FontResolver resolver) {
-        super(fontFileURI, resolver);
+    public TTFFontLoader(String fontFileURI, String subFontName,
+                boolean embedded, FontResolver resolver) {
+        super(fontFileURI, embedded, resolver);
         this.subFontName = subFontName;
     }
     
@@ -95,43 +103,86 @@
             throw new UnsupportedOperationException(
                     "OpenType fonts with CFF data are not supported, yet");
         }
-        multiFont = new MultiByteFont();
-        multiFont.setResolver(this.resolver);
-        returnFont = multiFont;
+        
+        boolean isCid = this.embedded;
+        
+        if (isCid) {
+            multiFont = new MultiByteFont();
+            returnFont = multiFont;
+            multiFont.setTTCName(ttcFontName);
+        } else {
+            singleFont = new SingleByteFont();
+            returnFont = singleFont;
+        }
+        returnFont.setResolver(resolver);
 
         returnFont.setFontName(ttf.getPostScriptName());
         returnFont.setFullName(ttf.getFullName());
         returnFont.setFamilyNames(ttf.getFamilyNames());
         returnFont.setFontSubFamilyName(ttf.getSubFamilyName());
-        multiFont.setTTCName(ttcFontName);
         returnFont.setCapHeight(ttf.getCapHeight());
         returnFont.setXHeight(ttf.getXHeight());
         returnFont.setAscender(ttf.getLowerCaseAscent());
         returnFont.setDescender(ttf.getLowerCaseDescent());
         returnFont.setFontBBox(ttf.getFontBBox());
-        //returnFont.setFirstChar(ttf.getFirstChar();)
         returnFont.setFlags(ttf.getFlags());
         returnFont.setStemV(Integer.parseInt(ttf.getStemV())); //not used for TTF
         returnFont.setItalicAngle(Integer.parseInt(ttf.getItalicAngle()));
         returnFont.setMissingWidth(0);
         returnFont.setWeight(ttf.getWeightClass());
-                
-        multiFont.setCIDType(CIDFontType.CIDTYPE2);
+
+        if (isCid) {
+            multiFont.setCIDType(CIDFontType.CIDTYPE2);
+            int[] wx = ttf.getWidths();
+            multiFont.setWidthArray(wx);
+            List entries = ttf.getCMaps();
+            BFEntry[] bfentries = new BFEntry[entries.size()];
+            int pos = 0;
+            Iterator iter = ttf.getCMaps().listIterator();
+            while (iter.hasNext()) {
+                TTFCmapEntry ce = (TTFCmapEntry)iter.next();
+                bfentries[pos] = new BFEntry(ce.getUnicodeStart(), ce.getUnicodeEnd(),
+                        ce.getGlyphStartIndex());
+                pos++;
+            }
+            multiFont.setBFEntries(bfentries);
+        } else {
+            singleFont.setFontType(FontType.TRUETYPE);
+            singleFont.setEncoding(ttf.getCharSetName());
+            returnFont.setFirstChar(ttf.getFirstChar());
+            returnFont.setLastChar(ttf.getLastChar());
+            copyWidthsSingleByte(ttf);
+        }
+        
+        copyKerning(ttf, isCid);
+        if (this.embedded && ttf.isEmbeddable()) {
+            multiFont.setEmbedFileName(this.fontFileURI);
+        }
+    }
+
+    private void copyWidthsSingleByte(TTFFile ttf) {
         int[] wx = ttf.getWidths();
-        multiFont.setWidthArray(wx);
-        List entries = ttf.getCMaps();
-        BFEntry[] bfentries = new BFEntry[entries.size()];
-        int pos = 0;
+        for (int i = singleFont.getFirstChar(); i <= singleFont.getLastChar(); i++) {
+            singleFont.setWidth(i, ttf.getCharWidth(i));
+        }
         Iterator iter = ttf.getCMaps().listIterator();
         while (iter.hasNext()) {
             TTFCmapEntry ce = (TTFCmapEntry)iter.next();
-            bfentries[pos] = new BFEntry(ce.getUnicodeStart(), ce.getUnicodeEnd(),
-                    ce.getGlyphStartIndex());
-            pos++;
-        }
-        multiFont.setBFEntries(bfentries);
-        copyKerning(ttf, true);
-        multiFont.setEmbedFileName(this.fontFileURI);
+            if (ce.getUnicodeStart() < 0xFFFE) {
+                for (char u = (char)ce.getUnicodeStart(); u <= ce.getUnicodeEnd(); u++) {
+                    int codePoint = singleFont.getEncoding().mapChar(u);
+                    if (codePoint <= 0) {
+                        String unicode = Character.toString(u);
+                        String charName = Glyphs.stringToGlyph(unicode);
+                        if (charName.length() > 0) {
+                            NamedCharacter nc = new NamedCharacter(charName, unicode);
+                            int glyphIndex = ce.getGlyphStartIndex() + u - ce.getUnicodeStart();
+                            singleFont.addUnencodedCharacter(nc, wx[glyphIndex]);
+                        }
+                    }
+                }
+            }
+        }
     }
     
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java Thu May  8 08:45:26 2008
@@ -44,12 +44,13 @@
     /**
      * Constructs a new Type 1 font loader.
      * @param fontFileURI the URI to the PFB file of a Type 1 font
+     * @param embedded indicates whether the font is embedded or referenced
      * @param resolver the font resolver used to resolve URIs
      * @throws IOException In case of an I/O error
      */
-    public Type1FontLoader(String fontFileURI, FontResolver resolver) 
+    public Type1FontLoader(String fontFileURI, boolean embedded, FontResolver resolver) 
                 throws IOException {
-        super(fontFileURI, resolver);
+        super(fontFileURI, embedded, resolver);
     }
 
     private String getPFMURI(String pfbURI) {
@@ -119,7 +120,9 @@
         singleFont = new SingleByteFont();
         singleFont.setFontType(FontType.TYPE1);
         singleFont.setResolver(this.resolver);
-        singleFont.setEmbedFileName(this.fontFileURI);
+        if (this.embedded) {
+            singleFont.setEmbedFileName(this.fontFileURI);
+        }
         returnFont = singleFont;
         
         handleEncoding(afm, pfm);

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java Thu May  8 08:45:26 2008
@@ -1527,10 +1527,20 @@
     protected void wrapPositionElements(List sourceList, List targetList, boolean force) {
           
         ListIterator listIter = sourceList.listIterator();
+        Object tempElement;
         while (listIter.hasNext()) {
-            ListElement tempElement;
-            tempElement = (ListElement) listIter.next();
-            wrapPositionElement(tempElement, targetList, force);
+            tempElement = listIter.next();
+            if (tempElement instanceof ListElement) {
+                wrapPositionElement(
+                        (ListElement) tempElement,
+                        targetList,
+                        force);
+            } else if (tempElement instanceof List) {
+                wrapPositionElements(
+                        (List) tempElement, 
+                        targetList,
+                        force);
+            }
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java Thu May  8 08:45:26 2008
@@ -30,6 +30,7 @@
 import org.apache.fop.area.BlockParent;
 import org.apache.fop.fo.pagination.Flow;
 import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
+import org.apache.fop.layoutmgr.inline.WrapperLayoutManager;
 
 /**
  * LayoutManager for an fo:flow object.
@@ -75,7 +76,8 @@
         LinkedList returnList = new LinkedList();
 
         while ((curLM = getChildLM()) != null) {
-            if (curLM instanceof InlineLevelLayoutManager) {
+            if (!(curLM instanceof WrapperLayoutManager)
+                && curLM instanceof InlineLevelLayoutManager) {
                 log.error("inline area not allowed under flow - ignoring");
                 curLM.setFinished(true);
                 continue;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java Thu May  8 08:45:26 2008
@@ -20,7 +20,12 @@
 package org.apache.fop.layoutmgr.inline;
 
 import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.InlineParent;
+import org.apache.fop.area.Block;
+import org.apache.fop.area.LineArea;
 import org.apache.fop.fo.flow.Wrapper;
+import org.apache.fop.layoutmgr.BlockLayoutManager;
+import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.layoutmgr.TraitSetter;
@@ -66,7 +71,19 @@
         if (fobj.hasId()) {
             addId();
             InlineArea area = getEffectiveArea();
-            parentLM.addChildArea(area);
+            if (parentLM instanceof BlockStackingLayoutManager
+                    && !(parentLM instanceof BlockLayoutManager)) {
+                Block helperBlock = new Block();
+                LineArea helperLine = new LineArea();
+                InlineParent helperInline = new InlineParent();
+                helperInline.addChildArea(area);
+                helperLine.addInlineArea(helperInline);
+                helperLine.updateExtentsFromChildren();
+                helperBlock.addLineArea(helperLine);
+                parentLM.addChildArea(helperBlock);
+            } else {
+                parentLM.addChildArea(area);
+            }
         }
         while (posIter.hasNext()) {
             posIter.next();

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/PrintRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/PrintRendererConfigurator.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/PrintRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/PrintRendererConfigurator.java Thu May  8 08:45:26 2008
@@ -95,8 +95,7 @@
         FontCache fontCache = fontManager.getFontCache();
 
         List/*<EmbedFontInfo>*/ embedFontInfoList = buildFontListFromConfiguration(cfg, 
-                userAgent.getFontBaseURL(), fontResolver, strict, 
-                fontCache);
+                fontResolver, strict, fontManager);
         
         if (fontCache != null && fontCache.hasChanged()) {
             fontCache.save();
@@ -108,16 +107,17 @@
      * Builds a list of EmbedFontInfo objects for use with the setup() method.
      * 
      * @param cfg Configuration object
-     * @param fontBaseURL the base URL to resolve relative font URLs with
      * @param fontResolver the FontResolver to use
      * @param strict true if an Exception should be thrown if an error is found.
-     * @param fontCache the font cache (or null if it is disabled)
+     * @param fontManager the font manager
      * @return a List of EmbedFontInfo objects.
      * @throws FOPException If an error occurs while processing the configuration
      */
     public static List/*<EmbedFontInfo>*/ buildFontListFromConfiguration(Configuration cfg, 
-            String fontBaseURL, FontResolver fontResolver, 
-            boolean strict, FontCache fontCache) throws FOPException {
+            FontResolver fontResolver, 
+            boolean strict, FontManager fontManager) throws FOPException {
+        FontCache fontCache = fontManager.getFontCache();
+        String fontBaseURL = fontManager.getFontBaseURL();
         List/*<EmbedFontInfo>*/ fontInfoList
             = new java.util.ArrayList/*<EmbedFontInfo>*/();
 
@@ -213,7 +213,10 @@
                     fontInfoList.add(embedFontInfo);
                 }
             }
-                        
+
+            // Update referenced fonts (fonts which are not to be embedded)
+            updateReferencedFonts(fontInfoList, fontManager.getReferencedFontsMatcher());
+            
             if (log.isDebugEnabled()) {
                 log.debug("Finished font configuration in " 
                         + (System.currentTimeMillis() - start) + "ms");
@@ -222,6 +225,25 @@
         return fontInfoList;
     }
 
+    private static void updateReferencedFonts(List fontInfoList, FontTriplet.Matcher matcher) {
+        if (matcher == null) {
+            return; //No referenced fonts
+        }
+        Iterator iter = fontInfoList.iterator();
+        while (iter.hasNext()) {
+            EmbedFontInfo fontInfo = (EmbedFontInfo)iter.next();
+            Iterator triplets = fontInfo.getFontTriplets().iterator();
+            while (triplets.hasNext()) {
+                FontTriplet triplet = (FontTriplet)triplets.next();
+                if (matcher.matches(triplet)) {
+                    fontInfo.setEmbedded(false);
+                    break;
+                }
+            }
+        }
+    }
+
+    
     /**
      * Iterates over font file list adding font info to list
      * @param fontFileList font file list

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java Thu May  8 08:45:26 2008
@@ -25,6 +25,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.fonts.CustomFont;
 import org.apache.fop.fonts.EmbedFontInfo;
 import org.apache.fop.fonts.FontCollection;
@@ -87,7 +88,7 @@
                     Source fontSource = resolver.resolve(configFontInfo.getEmbedFile());
                     font = new CustomFontMetricsMapper(fontMetrics, fontSource);
                 } else {
-                    CustomFont fontMetrics = FontLoader.loadFont(fontFile, null, resolver);
+                    CustomFont fontMetrics = FontLoader.loadFont(fontFile, null, true, resolver);
                     font = new CustomFontMetricsMapper(fontMetrics);
                 }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSFontUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSFontUtils.java?rev=654562&r1=654561&r2=654562&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSFontUtils.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSFontUtils.java Thu May  8 08:45:26 2008
@@ -191,8 +191,7 @@
     }
 
     private static boolean isEmbeddable(CustomFont font) {
-        return font.isEmbeddable() 
-                && (font.getEmbedFileName() != null || font.getEmbedResourceName() != null);
+        return font.isEmbeddable();
     }
     
     private static InputStream getInputStreamOnFont(PSGenerator gen, CustomFont font) 



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


Mime
View raw message