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 je...@apache.org on 2007/05/28 16:31:33 UTC

svn commit: r542237 [1/5] - in /xmlgraphics/fop/trunk: ./ lib/ src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/apps/ src/java/org/apache/fop/area/ src/java/org/apache/fop/cli/ src/java/org/apache/fop/fonts/ src/java/org/apache/fop/fonts/...

Author: jeremias
Date: Mon May 28 07:31:24 2007
New Revision: 542237

URL: http://svn.apache.org/viewvc?view=rev&rev=542237
Log:
Bugzilla #41831:
- Add support font auto-detection (easier font configuration) including a font cache to speed up the auto-detection process.
- Refactoring of the configuration code: All Avalon configuration stuff is extracted into separate "Configurator" classes.
- Refactoring of the FOURIResolver.
Submitted by: Adrian Cumiskey <fop-dev.at.cumiskey.com>

Changes to the patch by jeremias during the review:
- Font cache simplified (Java object serialization instead of XML), functionality fixed and moved to the fonts.package.
- Relocated default cache file location to user directory.
- Fixed the font configuration for PDFDocumentGraphics2D/PDFTranscoder that got lost with the patch.
- Fixed a problem with having a non-file URL as font base URL.
- Simplified RendererContextInfo stuff to make it easier to understand.
- Fixed handling of Type 1 fonts in auto-detection.
- Reduced verbosity of font-related log output.
- Updated Jakarta Commons IO to version 1.3.1 (the patch depends on it)
- Various javadocs improvements

Added:
    xmlgraphics/fop/trunk/lib/commons-io-1.3.1.jar   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactoryConfigurator.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CachedFontInfo.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontCache.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontFinder.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/autodetect/package.html   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRendererConfigurator.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRendererConfigurator.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererConfigurator.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerConfigurator.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/util/LogUtil.java   (with props)
    xmlgraphics/fop/trunk/test/config/test_font_attributes_missing.xconf   (with props)
    xmlgraphics/fop/trunk/test/config/test_font_embedurl_bad.xconf   (with props)
    xmlgraphics/fop/trunk/test/config/test_font_embedurl_malformed.xconf   (with props)
    xmlgraphics/fop/trunk/test/config/test_font_metricsurl_bad.xconf   (with props)
    xmlgraphics/fop/trunk/test/config/test_font_metricsurl_malformed.xconf   (with props)
    xmlgraphics/fop/trunk/test/config/test_font_tripletattribute_missing.xconf   (with props)
    xmlgraphics/fop/trunk/test/config/test_fonts_autodetect.xconf   (with props)
    xmlgraphics/fop/trunk/test/config/test_fonts_directory_bad.xconf   (with props)
    xmlgraphics/fop/trunk/test/config/test_fonts_directory_recursive.xconf   (with props)
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java   (with props)
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java   (with props)
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java   (with props)
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java   (with props)
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java   (with props)
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java   (with props)
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java   (with props)
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsDirectoryBadTestCase.java   (with props)
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsDirectoryRecursiveTestCase.java   (with props)
    xmlgraphics/fop/trunk/test/xml/bugtests/font-dir.fo   (with props)
Removed:
    xmlgraphics/fop/trunk/lib/commons-io-1.1.jar
    xmlgraphics/fop/trunk/test/config/test_embedurl_bad.xconf
    xmlgraphics/fop/trunk/test/config/test_embedurl_malformed.xconf
    xmlgraphics/fop/trunk/test/config/test_fontattributes_missing.xconf
    xmlgraphics/fop/trunk/test/config/test_fonttripletattribute_missing.xconf
    xmlgraphics/fop/trunk/test/config/test_metricsurl_bad.xconf
    xmlgraphics/fop/trunk/test/config/test_metricsurl_malformed.xconf
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/EmbedUrlBadTestCase.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/EmbedUrlMalformedTestCase.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/MetricsUrlBadTestCase.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/MetricsUrlMalformedTestCase.java
Modified:
    xmlgraphics/fop/trunk/fop.bat
    xmlgraphics/fop/trunk/fop.cmd
    xmlgraphics/fop/trunk/lib/commons-io.NOTICE.txt
    xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml
    xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/fonts.xml
    xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOURIResolver.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactory.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeParser.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontLoader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontSetup.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUtil.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MultiByteFont.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/apps/TTFReader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFFile.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFFilterList.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRendererMaker.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererContext.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererFactory.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererMaker.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontSetup.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/print/PrintRendererMaker.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRendererMaker.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRendererMaker.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRendererMaker.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFContext.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextElementBridge.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTranscoder.java
    xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/svg/SVGRenderer.java
    xmlgraphics/fop/trunk/status.xml
    xmlgraphics/fop/trunk/test/config/test_fontbase_bad.xconf
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTestCase.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontBaseBadTestCase.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/config/UserConfigTestSuite.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java
    xmlgraphics/fop/trunk/test/test.xconf
    xmlgraphics/fop/trunk/test/xml/pdf-encoding/pdf-encoding-test.xconf

Modified: xmlgraphics/fop/trunk/fop.bat
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop.bat?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/fop.bat (original)
+++ xmlgraphics/fop/trunk/fop.bat Mon May 28 07:31:24 2007
@@ -62,7 +62,7 @@
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\batik-all-1.6.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xmlgraphics-commons-1.2svn.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\avalon-framework-4.2.0.jar
-set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-io-1.1.jar
+set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-io-1.3.1.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-logging-1.0.4.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jimi-1.0.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jai_core.jar
@@ -70,6 +70,8 @@
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\fop-hyph.jar
 set LOCALCLASSPATH=%LOCALCLASSPATH%;%FOP_HYPHENATION_PATH%
 
+set JAVAOPTS=-Denv.windir=%WINDIR%
+
 if "%JAVA_HOME%" == "" goto noJavaHome
 if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
 if "%JAVACMD%" == "" set JAVACMD=%JAVA_HOME%\bin\java
@@ -80,5 +82,4 @@
 
 :runFop
 rem ECHO "%JAVACMD%"
-"%JAVACMD%" %LOGCHOICE% %LOGLEVEL% -cp "%LOCALCLASSPATH%" org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS%
-
+"%JAVACMD%" %JAVAOPTS% %LOGCHOICE% %LOGLEVEL% -cp "%LOCALCLASSPATH%" org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS%

Modified: xmlgraphics/fop/trunk/fop.cmd
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop.cmd?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/fop.cmd (original)
+++ xmlgraphics/fop/trunk/fop.cmd Mon May 28 07:31:24 2007
@@ -58,6 +58,8 @@
 set LOCALCLASSPATH=%FOP_HYPHENATION_PATH%
 for %%l in (%LOCAL_FOP_HOME%build\*.jar %LIBDIR%\*.jar) do set LOCALCLASSPATH=!LOCALCLASSPATH!;%%l
 
+set JAVAOPTS=-Denv.windir=%WINDIR%
+
 if "%JAVA_HOME%" == "" goto noJavaHome
 if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
 if "%JAVACMD%" == "" set JAVACMD=%JAVA_HOME%\bin\java
@@ -68,6 +70,6 @@
 
 :runFop
 rem echo "%JAVACMD%" %LOGCHOICE% %LOGLEVEL% -cp "%LOCALCLASSPATH%" org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS%
-"%JAVACMD%" %LOGCHOICE% %LOGLEVEL% -cp "%LOCALCLASSPATH%" org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS%
+"%JAVACMD%" %JAVAOPTS% %LOGCHOICE% %LOGLEVEL% -cp "%LOCALCLASSPATH%" org.apache.fop.cli.Main %FOP_CMD_LINE_ARGS%
 
 ENDLOCAL

Added: xmlgraphics/fop/trunk/lib/commons-io-1.3.1.jar
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/lib/commons-io-1.3.1.jar?view=auto&rev=542237
==============================================================================
Binary file - no diff available.

Propchange: xmlgraphics/fop/trunk/lib/commons-io-1.3.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: xmlgraphics/fop/trunk/lib/commons-io.NOTICE.txt
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/lib/commons-io.NOTICE.txt?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/lib/commons-io.NOTICE.txt (original)
+++ xmlgraphics/fop/trunk/lib/commons-io.NOTICE.txt Mon May 28 07:31:24 2007
@@ -1,3 +1,6 @@
+Apache Jakarta Commons IO
+Copyright 2001-2007 The Apache Software Foundation
+
 This product includes software developed by
 The Apache Software Foundation (http://www.apache.org/).
 

Modified: xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml (original)
+++ xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml Mon May 28 07:31:24 2007
@@ -152,6 +152,24 @@
         <td>"height" 11 inches, "width" 8.26 inches</td>
       </tr>
       <tr>
+        <td>use-cache</td>
+        <td>boolean (true, false)</td>
+        <td>All fonts information that has been gathered as a result of "directory"
+        or "auto-detect" font configurations will be cached for future rendering runs.
+        This setting should improve performance on systems where
+        fonts have been configured using the "directory" or "auto-detect" tag mechanisms.
+        By default this option is switched on.</td>
+        <td>true</td>
+      </tr>
+      <tr>
+        <td>cache-file</td>
+        <td>String</td>
+        <td>This options specifies the file/directory path of the fop cache file.
+        This option can also be specified on the command-line using the -cache option.
+        This file is currently only used to cache font triplet information for future reference.</td>
+        <td>${base}/conf/fop.cache</td>
+      </tr>
+      <tr>
         <td>renderers</td>
         <td>(see text below)</td>
         <td>Contains the configuration for each renderer. See below.</td>

Modified: xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/fonts.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/fonts.xml?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/fonts.xml (original)
+++ xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/fonts.xml Mon May 28 07:31:24 2007
@@ -24,6 +24,7 @@
     <authors>
       <person name="Jeremias Märki" email=""/>
       <person name="Tore Engvig" email=""/>
+      <person name="Adrian Cumiskey" email=""/>
     </authors>
   </header>
   <body>
@@ -129,8 +130,7 @@
 More 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/technotes/fonts.html">Adobe Font Technote</a></li>
       </ul>
       <section id="type1-metrics">
         <title>Type 1 Font Metrics</title>
@@ -236,10 +236,24 @@
       <section id="register">
         <title>Register Fonts with FOP</title>
         <p>You must tell FOP how to find and use the font metrics files by registering them in the <a href="configuration.html">FOP Configuration</a>. Add entries for your custom fonts, regardless of font type, to the configuration file in a manner similar to the following:</p>
-        <source><![CDATA[<font metrics-url="file:///C:/myfonts/FTL_____.xml" kerning="yes"
+        <source><![CDATA[
+<fonts>
+  <!-- register a particular font -->
+  <font metrics-url="file:///C:/myfonts/FTL_____.xml" kerning="yes"
       embed-url="file:///C:/myfonts/FTL_____.pfb">
-  <font-triplet name="FrutigerLight" style="normal" weight="normal"/>
-</font>]]></source>
+     <font-triplet name="FrutigerLight" style="normal" weight="normal"/>
+  </font>
+  
+  <!-- register all the fonts found in a directory -->
+  <directory>C:\MyFonts1</directory>
+  
+  <!-- register all the fonts found in a directory
+       and all of its sub directories (use with care) -->
+  <directory recursive="true">C:\MyFonts2</directory>
+
+  <!-- automatically detect operating system installed fonts -->
+  <auto-detect/>  
+</fonts>]]></source>
         <note>Review the documentation for <a href="configuration.html">FOP Configuration</a> for instructions on making the FOP configuration available to FOP when it runs. Otherwise, FOP has no way of finding your custom font information.</note>
         <ul>
           <li>
@@ -247,8 +261,14 @@
             Relative URLs are resolved relative to the font-base property (or base) if available.
             See <a href="configuration.html">FOP: Configuration</a> for more information.
           </li>
-          <li>The "kerning" and "embed-url" attributes are optional. Kerning is currently not used at all. If embedding is off, the output will position the text correctly (from the metrics file), but it will not be displayed or printed correctly unless the viewer has the applicable font available to their local system.</li>
-          <li>When setting the embed-url attribute for Type 1 fonts, be sure to specify the PFB (actual font data), not PFM (font metrics) file that you used to generate the XML font metrics file.</li>
+          <li>Either an "embed-url" or a "metrics-url" must be specified for font tag configurations.</li>
+          <li>The font "kerning" attribute is optional. Kerning is currently not used at all.</li>
+	      <li>If embedding is off, the output will position the text correctly (from the metrics file), but it will not be displayed or printed correctly unless the viewer has the applicable font available to their local system.</li>
+          <li>When setting the "embed-url" attribute for Type 1 fonts, be sure to specify the PFB (actual font data), not PFM (font metrics) file that you used to generate the XML font metrics file.</li>
+          <li>The fonts "directory" tag can be used to register fonts contained within a single or list of directory paths.  The "recursive" attribute can be specified to recursively add fonts from all sub directories.</li>
+          <li>The fonts "auto-detect" tag can be used to automatically register fonts that are found to be installed on the native operating system.</li>
+          <li>Fonts registered with "font" tag configurations override fonts found by means of "directory" tag definitions.</li>
+          <li>Fonts found as a result of a "directory" tag configuration override fonts found as a result of the "auto-detect" tag being specified.</li>
           <li>
             If relative URLs are specified, they are evaluated relative to the value of the 
             "font-base" setting. If there is no "font-base" setting, the fonts are evaluated 
@@ -281,7 +301,7 @@
 See <a href="#ttf-encoding">Table of TTF Encoding Options</a> for more details.</p>
       </section>
       <section id="embedding-base14">
-        <title>Explicitely embedding the base 14 fonts</title>
+        <title>Explicitly embedding the base 14 fonts</title>
         <p>
           There are cases where you might want to force the embedding of one or more of the base 14 fonts that
           can normally be considered available on the target platform (viewer, printer). One of these cases is

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOURIResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOURIResolver.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOURIResolver.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOURIResolver.java Mon May 28 07:31:24 2007
@@ -29,6 +29,7 @@
 import java.net.URLConnection;
 
 import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
 import javax.xml.transform.stream.StreamSource;
 
 // commons logging
@@ -47,9 +48,42 @@
 public class FOURIResolver
     implements javax.xml.transform.URIResolver {
     
+    // log
     private Log log = LogFactory.getLog("FOP");
+
+    // true if exceptions are to be thrown if the URIs cannot be resolved.
+    private boolean throwExceptions = false;
+
+    /**
+     * Default constructor
+     */
+    public FOURIResolver() {
+        this(false);
+    }
+    
+    /**
+     * Additional constructor
+     * @param throwExceptions true if exceptions are to be thrown if the URIs cannot be
+     *              resolved.
+     */
+    public FOURIResolver(boolean throwExceptions) {
+        this.throwExceptions = throwExceptions;
+    }
     
     /**
+     * Handles resolve exceptions appropriately.
+     * @param errorStr error string
+     * @param strict strict user config
+     */
+    private void handleException(Exception e, String errorStr, boolean strict)
+    throws TransformerException {
+        if (strict) {
+            throw new TransformerException(errorStr, e);
+        }
+        log.error(e.getMessage());
+    }
+
+    /**
      * Called by the processor through {@link FOUserAgent} when it encounters an 
      * uri in an external-graphic element.
      * (see also {@link javax.xml.transform.URIResolver#resolve(String, String)}
@@ -70,31 +104,25 @@
      * @throws javax.xml.transform.TransformerException Never thrown by this implementation.
      * @see javax.xml.transform.URIResolver#resolve(String, String)
      */
-    public Source resolve(String href, String base)
-        throws javax.xml.transform.TransformerException {
-        
-        //data URLs can be quite long so don't try to build a File (can lead to problems)
+    public Source resolve(String href, String base) throws TransformerException {        
+        // data URLs can be quite long so don't try to build a File (can lead to problems)
         if (href.startsWith("data:")) {
             return parseDataURI(href);
         }
-        
+
         URL absoluteURL = null;
-        File f = new File(href);
-        if (f.exists()) {
+        File file = new File(href);
+        if (file.canRead() && file.isFile()) {
             try {
-                absoluteURL = f.toURL();
+                absoluteURL = file.toURL();
             } catch (MalformedURLException mfue) {
-                log.error("Could not convert filename to URL: " + mfue.getMessage()); 
+                handleException(mfue,
+                        "Could not convert filename '" + href + "' to URL", throwExceptions);
             }
         } else {
-            URL baseURL = null;
-            try {
-                baseURL = toBaseURL(base);
-            } catch (MalformedURLException mfue) {
-                log.error("Error with base URL \"" + base + "\"): " + mfue.getMessage());
-            }
-            if (baseURL == null) {
-                // We don't have a valid baseURL just use the URL as given
+            // no base provided
+            if (base == null) {
+                // We don't have a valid file protocol based URL
                 try {
                     absoluteURL = new URL(href);
                 } catch (MalformedURLException mue) {
@@ -103,64 +131,78 @@
                         // the href contains only a path then file: is assumed
                         absoluteURL = new URL("file:" + href);
                     } catch (MalformedURLException mfue) {
-                        log.error("Error with URL '" + href + "': " + mue.getMessage());
-                        return null;
+                        handleException(mfue,
+                                "Error with URL '" + href + "'", throwExceptions);
                     }
                 }
+
+            // try and resolve from context of base
             } else {
+                URL baseURL = null;
                 try {
-                    /*
-                        This piece of code is based on the following statement in 
-                        RFC2396 section 5.2:
-
-                        3) If the scheme component is defined, indicating that the reference
-                           starts with a scheme name, then the reference is interpreted as an
-                           absolute URI and we are done.  Otherwise, the reference URI's
-                           scheme is inherited from the base URI's scheme component.
-
-                           Due to a loophole in prior specifications [RFC1630], some parsers
-                           allow the scheme name to be present in a relative URI if it is the
-                           same as the base URI scheme.  Unfortunately, this can conflict
-                           with the correct parsing of non-hierarchical URI.  For backwards
-                           compatibility, an implementation may work around such references
-                           by removing the scheme if it matches that of the base URI and the
-                           scheme is known to always use the <hier_part> syntax.
-
-                        The URL class does not implement this work around, so we do.
-                    */
-
-                    String scheme = baseURL.getProtocol() + ":";
-                    if (href.startsWith(scheme)) {
-                        href = href.substring(scheme.length());
-                        if ("file:".equals(scheme)) {
-                            int colonPos = href.indexOf(':');
-                            int slashPos = href.indexOf('/');
-                            if (slashPos >= 0 && colonPos >= 0 && colonPos < slashPos) {
-                                href = "/" + href; //Absolute file URL doesn't have a leading slash
-                            }
+                    baseURL = new URL(base);
+                } catch (MalformedURLException mfue) {
+                    handleException(mfue, "Error with base URL '" + base + "'", throwExceptions);
+                }
+
+                /*
+                 * This piece of code is based on the following statement in
+                 * RFC2396 section 5.2:
+                 * 
+                 * 3) If the scheme component is defined, indicating that the
+                 * reference starts with a scheme name, then the reference is
+                 * interpreted as an absolute URI and we are done. Otherwise,
+                 * the reference URI's scheme is inherited from the base URI's
+                 * scheme component.
+                 * 
+                 * Due to a loophole in prior specifications [RFC1630], some
+                 * parsers allow the scheme name to be present in a relative URI
+                 * if it is the same as the base URI scheme. Unfortunately, this
+                 * can conflict with the correct parsing of non-hierarchical
+                 * URI. For backwards compatibility, an implementation may work
+                 * around such references by removing the scheme if it matches
+                 * that of the base URI and the scheme is known to always use
+                 * the <hier_part> syntax.
+                 * 
+                 * The URL class does not implement this work around, so we do.
+                 */
+                String scheme = baseURL.getProtocol() + ":";
+                if (href.startsWith(scheme)) {
+                    href = href.substring(scheme.length());
+                    if ("file:".equals(scheme)) {
+                        int colonPos = href.indexOf(':');
+                        int slashPos = href.indexOf('/');
+                        if (slashPos >= 0 && colonPos >= 0 && colonPos < slashPos) {
+                            href = "/" + href; // Absolute file URL doesn't
+                                                // have a leading slash
                         }
                     }
+                }
+                try {
                     absoluteURL = new URL(baseURL, href);
                 } catch (MalformedURLException mfue) {
-                    log.error("Error with URL '" + href + "': " + mfue.getMessage());
-                    return null;
+                    handleException(mfue,
+                            "Error with URL; base '" + base + "' " + "href '" + href + "'",
+                            throwExceptions);                        
                 }
             }
         }
         
-        String effURL = absoluteURL.toExternalForm();
-        try {
-            URLConnection connection = absoluteURL.openConnection();
-            connection.setAllowUserInteraction(false);
-            connection.setDoInput(true);
-            updateURLConnection(connection, href);
-            connection.connect();
-            return new StreamSource(connection.getInputStream(), effURL);
-        } catch (FileNotFoundException fnfe) {
-            //Note: This is on "debug" level since the caller is supposed to handle this
-            log.debug("File not found: " + effURL);
-        } catch (java.io.IOException ioe) {
-            log.error("Error with opening URL '" + effURL + "': " + ioe.getMessage());
+        if (absoluteURL != null) {
+            String effURL = absoluteURL.toExternalForm();
+            try {
+                URLConnection connection = absoluteURL.openConnection();
+                connection.setAllowUserInteraction(false);
+                connection.setDoInput(true);
+                updateURLConnection(connection, href);
+                connection.connect();
+                return new StreamSource(connection.getInputStream(), effURL);
+            } catch (FileNotFoundException fnfe) {
+                //Note: This is on "debug" level since the caller is supposed to handle this
+                log.debug("File not found: " + effURL);
+            } catch (java.io.IOException ioe) {
+                log.error("Error with opening URL '" + effURL + "': " + ioe.getMessage());
+            }
         }
         return null;
     }
@@ -200,29 +242,6 @@
         }
     }
     
-    /**
-     * Returns the base URL as a java.net.URL.
-     * If the base URL is not set a default URL pointing to the
-     * current directory is returned.
-     * @param baseURL the base URL
-     * @returns the base URL as java.net.URL
-     */
-    private URL toBaseURL(String base) throws MalformedURLException {
-        if (base == null) {
-            return new java.io.File("").toURL();
-        }
-        if (!base.endsWith("/")) {
-            // The behavior described by RFC 3986 regarding resolution of relative
-            // references may be misleading for normal users:
-            // file://path/to/resources + myResource.res -> file://path/to/myResource.res
-            // file://path/to/resources/ + myResource.res -> file://path/to/resources/myResource.res
-            // We assume that even when the ending slash is missing, users have the second
-            // example in mind
-            base += "/";
-        }
-        return new URL(base);
-    }
-
     /**
      * Parses inline data URIs as generated by MS Word's XML export and FO stylesheet.
      * @see <a href="http://www.ietf.org/rfc/rfc2397">RFC 2397</a>

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java Mon May 28 07:31:24 2007
@@ -63,19 +63,25 @@
 public class FOUserAgent {
 
     /** Defines the default target resolution (72dpi) for FOP */
-    public static final float DEFAULT_TARGET_RESOLUTION = FopFactory.DEFAULT_TARGET_RESOLUTION;
+    public static final float DEFAULT_TARGET_RESOLUTION = FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION;
 
     private static Log log = LogFactory.getLog("FOP");
 
     private FopFactory factory;
     
-    /** The base URL for all URL resolutions, especially for external-graphics */
-    private String baseURL;
-    
+    /**
+     *  The base URL for all URL resolutions, especially for
+     *  external-graphics.
+     */
+    private String base = null;
+
+    /** The base URL for all font URL resolutions. */
+    private String fontBase = null;
+
     /** A user settable URI Resolver */
     private URIResolver uriResolver = null;
     
-    private float targetResolution = DEFAULT_TARGET_RESOLUTION;
+    private float targetResolution = FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION;
     private Map rendererOptions = new java.util.HashMap();
     private File outputFile = null;
     private Renderer rendererOverride = null;
@@ -105,7 +111,6 @@
     
     /**
      * Default constructor
-     * @throws FOPException 
      * @see org.apache.fop.apps.FopFactory
      * @deprecated Provided for compatibility only. Please use the methods from 
      *             FopFactory to construct FOUserAgent instances!
@@ -126,6 +131,7 @@
         }
         this.factory = factory;
         setBaseURL(factory.getBaseURL());
+        setFontBaseURL(factory.getFontBaseURL());
         setTargetResolution(factory.getTargetResolution());
     }
     
@@ -277,10 +283,18 @@
     
     /**
      * Sets the base URL.
-     * @param baseURL base URL
+     * @param baseUrl base URL
      */
-    public void setBaseURL(String baseURL) {
-        this.baseURL = baseURL;
+    public void setBaseURL(String baseUrl) {
+        this.base = baseUrl;
+    }
+
+    /**
+     * sets font base URL
+     * @param fontBaseUrl font base URL
+     */
+    public void setFontBaseURL(String fontBaseUrl) {
+        this.fontBase = fontBaseUrl;
     }
 
     /**
@@ -288,7 +302,7 @@
      * @return the base URL
      */
     public String getBaseURL() {
-        return this.baseURL;
+        return this.base;
     }
 
     /**
@@ -410,8 +424,10 @@
      */
     public void setTargetResolution(float dpi) {
         this.targetResolution = dpi;
-        log.info("target-resolution set to: " + targetResolution 
-                + "dpi (px2mm=" + getTargetPixelUnitToMillimeter() + ")");
+        if (log.isDebugEnabled()) {
+            log.debug("target-resolution set to: " + targetResolution 
+                    + "dpi (px2mm=" + getTargetPixelUnitToMillimeter() + ")");
+        }
     }
 
     /**
@@ -429,8 +445,7 @@
 
     /** @return the font base URL */
     public String getFontBaseURL() {
-        String fontBaseURL = getFactory().getFontBaseURL(); 
-        return fontBaseURL != null ? fontBaseURL : getBaseURL();
+        return fontBase != null ? fontBase : getBaseURL();
     }
 
     /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactory.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactory.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactory.java Mon May 28 07:31:24 2007
@@ -26,6 +26,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
@@ -39,14 +40,13 @@
 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.fo.ElementMapping;
 import org.apache.fop.fo.ElementMappingRegistry;
+import org.apache.fop.fonts.FontCache;
 import org.apache.fop.hyphenation.HyphenationTreeResolver;
 import org.apache.fop.image.ImageFactory;
 import org.apache.fop.layoutmgr.LayoutManagerMaker;
@@ -62,27 +62,6 @@
  */
 public class FopFactory {
     
-    /** Defines the default target resolution (72dpi) for FOP */
-    public static final float DEFAULT_TARGET_RESOLUTION = 72.0f; //dpi
-
-    /** Defines the default source resolution (72dpi) for FOP */
-    private static final float DEFAULT_SOURCE_RESOLUTION = 72.0f; //dpi
-
-    /** Defines the default page-height */
-    private static final String DEFAULT_PAGE_HEIGHT = "11in";
-    
-    /** Defines the default page-width */
-    private static final String DEFAULT_PAGE_WIDTH = "8.26in";
-    
-    /** Defines if FOP should use strict validation for FO and user config */
-    private static final boolean DEFAULT_STRICT_FO_VALIDATION = true;
-
-    /** Defines if FOP should validate the user config strictly */
-    private static final boolean DEFAULT_STRICT_USERCONFIG_VALIDATION = true;
-    
-    /** Defines if FOP should use an alternative rule to determine text indents */
-    private static final boolean DEFAULT_BREAK_INDENT_INHERITANCE = false;
-
     /** logger instance */
     private static Log log = LogFactory.getLog(FopFactory.class);
     
@@ -100,7 +79,7 @@
                 = new ContentHandlerFactoryRegistry();
     
     /** Our default resolver if none is set */
-    private URIResolver foURIResolver = new FOURIResolver();
+    private URIResolver foURIResolver = null;
     
     /** A user settable URI Resolver */
     private URIResolver uriResolver = null;
@@ -108,22 +87,23 @@
     /** The resolver for user-supplied hyphenation patterns */
     private HyphenationTreeResolver hyphResolver;
     
+    /** Image factory for creating fop image objects */
     private ImageFactory imageFactory = new ImageFactory();
 
-    /** user configuration */
-    private Configuration userConfig = null;
-
+    /** Configuration layer used to configure fop */
+    private FopFactoryConfigurator config = null;
+        
     /**
      *  The base URL for all URL resolutions, especially for
      *  external-graphics.
      */
-    private String baseURL;
+    private String base = null;
 
     /** The base URL for all font URL resolutions. */
-    private String fontBaseURL;
+    private String fontBase = null;
 
     /** The base URL for all hyphen URL resolutions. */
-    private String hyphenBaseURL;
+    private String hyphenBase = null;
 
     /**
      * FOP has the ability, for some FO's, to continue processing even if the
@@ -131,32 +111,36 @@
      * behavior for FOP.  However, this flag, if set, provides the user the
      * ability for FOP to halt on all content model violations if desired.
      */ 
-    private boolean strictFOValidation = DEFAULT_STRICT_FO_VALIDATION;
+    private boolean strictFOValidation = FopFactoryConfigurator.DEFAULT_STRICT_FO_VALIDATION;
 
     /**
      * FOP will validate the contents of the user configuration strictly
      * (e.g. base-urls and font urls/paths).
      */
-    private boolean strictUserConfigValidation = DEFAULT_STRICT_USERCONFIG_VALIDATION;
-    
+    private boolean strictUserConfigValidation
+        = FopFactoryConfigurator.DEFAULT_STRICT_USERCONFIG_VALIDATION;
+
+    /** Font cache to speed up auto-font configuration (null if disabled) */
+    private FontCache fontCache = null;
+
     /** Allows enabling kerning on the base 14 fonts, default is false */
     private boolean enableBase14Kerning = false;
     
     /** Source resolution in dpi */
-    private float sourceResolution = DEFAULT_SOURCE_RESOLUTION;
+    private float sourceResolution = FopFactoryConfigurator.DEFAULT_SOURCE_RESOLUTION;
 
     /** Target resolution in dpi */
-    private float targetResolution = DEFAULT_TARGET_RESOLUTION;
+    private float targetResolution = FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION;
 
     /** Page height */
-    private String pageHeight = DEFAULT_PAGE_HEIGHT;
+    private String pageHeight = FopFactoryConfigurator.DEFAULT_PAGE_HEIGHT;
     
     /** Page width */
-    private String pageWidth = DEFAULT_PAGE_WIDTH;
+    private String pageWidth = FopFactoryConfigurator.DEFAULT_PAGE_WIDTH;
 
     /** @see #setBreakIndentInheritanceOnReferenceAreaBoundary(boolean) */
     private boolean breakIndentInheritanceOnReferenceAreaBoundary
-        = DEFAULT_BREAK_INDENT_INHERITANCE;
+        = FopFactoryConfigurator.DEFAULT_BREAK_INDENT_INHERITANCE;
 
     /** Optional overriding LayoutManagerMaker */
     private LayoutManagerMaker lmMakerOverride = null;
@@ -165,14 +149,17 @@
     
     /** Map with cached ICC based ColorSpace objects. */
     private Map colorSpaceMap = null;
-    
+        
     /**
      * Main constructor.
      */
     protected FopFactory() {
+        this.config = new FopFactoryConfigurator(this);
         this.elementMappingRegistry = new ElementMappingRegistry(this);
+        this.foURIResolver = new FOURIResolver(validateUserConfigStrictly());
         // Use a synchronized Map - I am not really sure this is needed, but better safe than sorry.
         this.colorSpaceMap = Collections.synchronizedMap(new java.util.HashMap());
+        setUseCache(FopFactoryConfigurator.DEFAULT_USE_CACHE);
     }
     
     /**
@@ -336,11 +323,42 @@
     }
 
     /**
+     * cleans the base url
+     * @param base
+     * @return
+     * @throws MalformedURLException
+     * @throws URISyntaxException 
+     */
+    private String checkBaseURL(String base) throws MalformedURLException {
+        if (!base.endsWith("/")) {
+            // The behavior described by RFC 3986 regarding resolution of relative
+            // references may be misleading for normal users:
+            // file://path/to/resources + myResource.res -> file://path/to/myResource.res
+            // file://path/to/resources/ + myResource.res -> file://path/to/resources/myResource.res
+            // We assume that even when the ending slash is missing, users have the second
+            // example in mind
+            base += "/";
+        }
+        File dir = new File(base);
+        try {
+            base = (dir.isDirectory() ? dir.toURL() : new URL(base)).toExternalForm(); 
+        } catch (MalformedURLException mfue) {
+            if (strictUserConfigValidation) {
+                throw mfue;
+            }
+            log.error(mfue.getMessage());
+        }
+        return base;
+    }
+    
+    /**
      * Sets the base URL.
-     * @param baseURL base URL
+     * @param base base URL
+     * @throws MalformedURLException 
+     * @throws URISyntaxException 
      */
-    void setBaseURL(String baseURL) {
-        this.baseURL = baseURL;
+    public void setBaseURL(String base) throws MalformedURLException {
+        this.base = checkBaseURL(base);
     }
 
     /**
@@ -348,42 +366,46 @@
      * @return the base URL
      */
     public String getBaseURL() {
-        return this.baseURL;
+        return this.base;
     }
-
+    
     /**
      * Sets the font base URL.
-     * @param fontBaseURL font base URL
+     * @param fontBase font base URL
+     * @throws MalformedURLException 
+     * @throws URISyntaxException 
      */
-    public void setFontBaseURL(String fontBaseURL) {
-        this.fontBaseURL = fontBaseURL;
+    public void setFontBaseURL(String fontBase) throws MalformedURLException {
+        this.fontBase = checkBaseURL(fontBase);
     }
 
     /** @return the font base URL */
     public String getFontBaseURL() {
-        return this.fontBaseURL;
+        return this.fontBase;
     }
 
     /** @return the hyphen base URL */
     public String getHyphenBaseURL() {
-        return hyphenBaseURL;
+        return this.hyphenBase;
     }
 
     /**
      * Sets the hyphen base URL.
-     * @param hyphenBaseURL hythen base URL
-     */
-    public void setHyphenBaseURL(final String hyphenBaseURL) {
-        if (hyphenBaseURL != null) {
+     * @param hyphenBase hythen base URL
+     * @throws MalformedURLException 
+     * @throws URISyntaxException 
+     * */
+    public void setHyphenBaseURL(final String hyphenBase) throws MalformedURLException {
+        if (hyphenBase != null) {
             this.hyphResolver = new HyphenationTreeResolver() {
                 public Source resolve(String href) {
-                    return resolveURI(href, hyphenBaseURL);
+                    return resolveURI(href, hyphenBase);
                 }
             };
         }
-        this.hyphenBaseURL = hyphenBaseURL;
+        this.hyphenBase = checkBaseURL(hyphenBase);
     }
-
+    
     /**
      * Sets the URI Resolver. It is used for resolving factory-level URIs like hyphenation
      * patterns and as backup for URI resolution performed during a rendering run. 
@@ -483,8 +505,10 @@
      */
     public void setSourceResolution(float dpi) {
         this.sourceResolution = dpi;
-        log.info("source-resolution set to: " + sourceResolution 
-                + "dpi (px2mm=" + getSourcePixelUnitToMillimeter() + ")");
+        if (log.isDebugEnabled()) {
+            log.debug("source-resolution set to: " + sourceResolution 
+                    + "dpi (px2mm=" + getSourcePixelUnitToMillimeter() + ")");
+        }
     }
 
     /** @return the resolution for resolution-dependant output */
@@ -538,7 +562,9 @@
      */
     public void setPageHeight(String pageHeight) {
         this.pageHeight = pageHeight;
-        log.info("Default page-height set to: " + pageHeight);
+        if (log.isDebugEnabled()) {
+            log.debug("Default page-height set to: " + pageHeight);
+        }
     }
     
     /**
@@ -559,7 +585,9 @@
      */
     public void setPageWidth(String pageWidth) {
         this.pageWidth = pageWidth;
-        log.info("Default page-width set to: " + pageWidth);
+        if (log.isDebugEnabled()) {
+            log.debug("Default page-width set to: " + pageWidth);
+        }
     }
     
     /**
@@ -595,7 +623,7 @@
     public Set getIgnoredNamespace() {
         return Collections.unmodifiableSet(this.ignoredNamespaces);
     }
-    
+
     //------------------------------------------- Configuration stuff
     
     /**
@@ -605,14 +633,9 @@
      * @throws SAXException if a parsing error occurs
      */
     public void setUserConfig(File userConfigFile) throws SAXException, IOException {
-        try {
-            DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
-            setUserConfig(cfgBuilder.buildFromFile(userConfigFile));
-        } catch (ConfigurationException e) {
-            throw new FOPException(e);
-        }
+        config.setUserConfig(userConfigFile);
     }
-    
+
     /**
      * Set the user configuration from an URI.
      * @param uri the URI to the configuration file
@@ -620,12 +643,7 @@
      * @throws SAXException if a parsing error occurs
      */
     public void setUserConfig(String uri) throws SAXException, IOException {
-        try {
-            DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
-            setUserConfig(cfgBuilder.build(uri));
-        } catch (ConfigurationException e) {
-            throw new FOPException(e);
-        }
+        config.setUserConfig(uri);
     }
     
     /**
@@ -634,12 +652,7 @@
      * @throws FOPException if a configuration problem occurs 
      */
     public void setUserConfig(Configuration userConfig) throws FOPException {
-        this.userConfig = userConfig;
-        try {
-            configure(userConfig);
-        } catch (ConfigurationException e) {            
-            throw new FOPException(e);
-        }
+        config.setUserConfig(userConfig);
     }
 
     /**
@@ -647,162 +660,54 @@
      * @return the user configuration
      */
     public Configuration getUserConfig() {
-        return userConfig;
+        return config.getUserConfig();
     }
 
     /**
-     * Returns the configuration subtree for a specific renderer.
-     * @param mimeType MIME type of the renderer
-     * @return the requested configuration subtree, null if there's no configuration
+     * Is the user configuration to be validated?
+     * @param strictUserConfigValidation strict user config validation
      */
-    public Configuration getUserRendererConfig(String mimeType) {
-        if (userConfig == null || mimeType == null) {
-            return null;
-        }
-        
-        Configuration userRendererConfig = null;
-
-        Configuration[] cfgs
-            = userConfig.getChild("renderers").getChildren("renderer");
-        for (int i = 0; i < cfgs.length; ++i) {
-            Configuration child = cfgs[i];
-            try {
-                if (child.getAttribute("mime").equals(mimeType)) {
-                    userRendererConfig = child;
-                    break;
-                }
-            } catch (ConfigurationException e) {
-                // silently pass over configurations without mime type
-            }
-        }
-        log.debug((userRendererConfig == null ? "No u" : "U")
-                  + "ser configuration found for MIME type " + mimeType);
-        return userRendererConfig;
+    public void setStrictUserConfigValidation(boolean strictUserConfigValidation) {
+        this.strictUserConfigValidation = strictUserConfigValidation;
     }
 
     /**
-     * Initializes user agent settings from the user configuration
-     * file, if present: baseURL, resolution, default page size,...
-     * 
-     * @throws ConfigurationException when there is an entry that 
-     *          misses the required attribute
-     * Configures the FopFactory.
-     * @param cfg Avalon Configuration Object
-     * @see org.apache.avalon.framework.configuration.Configurable
+     * Is the user configuration to be validated?
+     * @return if the user configuration should be validated
      */
-    public void configure(Configuration cfg) throws ConfigurationException {        
-        log.info("Initializing FopFactory Configuration");        
-        
-        if (cfg.getChild("strict-configuration", false) != null) {
-            this.strictUserConfigValidation
-                    = cfg.getChild("strict-configuration").getValueAsBoolean();
-        }
-        if (cfg.getChild("strict-validation", false) != null) {
-            this.strictFOValidation = cfg.getChild("strict-validation").getValueAsBoolean();
-        }
-        if (cfg.getChild("base", false) != null) {
-            try {
-                setBaseURL(getBaseURLfromConfig(cfg, "base"));
-            } catch (ConfigurationException e) {
-                if (strictUserConfigValidation) {
-                    throw e;
-                }
-                log.error(e.getMessage());
-            }
-        }
-        if (cfg.getChild("font-base", false) != null) {
-            try {
-                setFontBaseURL(getBaseURLfromConfig(cfg, "font-base"));
-            } catch (ConfigurationException e) {
-                if (strictUserConfigValidation) {
-                    throw e;
-                }
-                log.error(e.getMessage());
-            }
-        }
-        if (cfg.getChild("hyphenation-base", false) != null) {
-            try {
-                setHyphenBaseURL(getBaseURLfromConfig(cfg, "hyphenation-base"));
-            } catch (ConfigurationException e) {
-                if (strictUserConfigValidation) {
-                    throw e;
-                }
-                log.error(e.getMessage());
-            }
-        }
-        if (cfg.getChild("source-resolution", false) != null) {
-            setSourceResolution(
-                    cfg.getChild("source-resolution").getValueAsFloat(DEFAULT_SOURCE_RESOLUTION));
-        }
-        if (cfg.getChild("target-resolution", false) != null) {
-            setTargetResolution(
-                    cfg.getChild("target-resolution").getValueAsFloat(DEFAULT_TARGET_RESOLUTION));
-        }
-        if (cfg.getChild("break-indent-inheritance", false) != null) {
-            setBreakIndentInheritanceOnReferenceAreaBoundary(
-                    cfg.getChild("break-indent-inheritance").getValueAsBoolean());
-        }        
-        Configuration pageConfig = cfg.getChild("default-page-settings");
-        if (pageConfig.getAttribute("height", null) != null) {
-            setPageHeight(pageConfig.getAttribute("height", DEFAULT_PAGE_HEIGHT));
-        }
-        if (pageConfig.getAttribute("width", null) != null) {
-            setPageWidth(pageConfig.getAttribute("width", DEFAULT_PAGE_WIDTH));
-        }
+    public boolean validateUserConfigStrictly() {
+        return this.strictUserConfigValidation;
     }
 
+    //------------------------------------------- Cache related stuff
+
     /**
-     * Retrieves and verifies a base URL.
-     * @param cfg The Configuration object to retrieve the base URL from
-     * @param name the element name for the base URL
-     * @return the requested base URL or null if not available
-     * @throws ConfigurationException 
-     */    
-    public static String getBaseURLfromConfig(Configuration cfg, String name)
-    throws ConfigurationException {
-        if (cfg.getChild(name, false) != null) {
-            try {
-                String cfgBasePath = cfg.getChild(name).getValue(null);
-                if (cfgBasePath != null) {
-                    // Is the path a dirname?
-                    File dir = new File(cfgBasePath);
-//                    if (!dir.exists()) {
-//                        throw new ConfigurationException("Base URL '" + name
-//                                + "' references non-existent resource '"
-//                                + cfgBasePath + "'");
-//                    } else if (dir.isDirectory()) {
-                    if (dir.isDirectory()) {
-                        // Yes, convert it into a URL
-                        cfgBasePath = dir.toURL().toExternalForm(); 
-                    }
-                    // Otherwise, this is already a URL
-                }
-                log.info(name + " set to: " + cfgBasePath);
-                return cfgBasePath;
-            } catch (MalformedURLException mue) {
-                throw new ConfigurationException("Base URL '" + name
-                        + "' in user config is malformed!");
+     * Whether or not to cache results of font triplet detection/auto-config
+     * @param useCache use cache or not
+     */
+    public void setUseCache(boolean useCache) {
+        if (useCache) {
+            this.fontCache = FontCache.load();
+            if (this.fontCache == null) {
+                this.fontCache = new FontCache();
             }
+        } else {
+            this.fontCache = null;
         }
-        return null;
     }
 
     /**
-     * Is the user configuration to be validated?
-     * @param strictUserConfigValidation strict user config validation
+     * Cache results of font triplet detection/auto-config?
+     * @return whether this factory is uses the cache
      */
-    public void setStrictUserConfigValidation(boolean strictUserConfigValidation) {
-        this.strictUserConfigValidation = strictUserConfigValidation;
+    public boolean useCache() {
+        return (this.fontCache != null);
     }
 
-    /**
-     * Is the user configuration to be validated?
-     * @return if the user configuration should be validated
-     */
-    public boolean validateUserConfigStrictly() {
-        return this.strictUserConfigValidation;
+    public FontCache getFontCache() {
+        return this.fontCache;
     }
-
+    
     //------------------------------------------- URI resolution
 
     /**
@@ -810,26 +715,29 @@
      * Will use the configured resolver and if not successful fall back
      * to the default resolver.
      * @param uri URI to access
-     * @param base the base URI to resolve against
+     * @param baseUri the base URI to resolve against
      * @return A {@link javax.xml.transform.Source} object, or null if the URI
      * cannot be resolved. 
      * @see org.apache.fop.apps.FOURIResolver
      */
-    public Source resolveURI(String uri, String base) {
+    public Source resolveURI(String uri, String baseUri) {
         Source source = null;
         //RFC 2397 data URLs don't need to be resolved, just decode them.
         boolean bypassURIResolution = uri.startsWith("data:");
         if (!bypassURIResolution && uriResolver != null) {
             try {
-                source = uriResolver.resolve(uri, base);
+                source = uriResolver.resolve(uri, baseUri);
             } catch (TransformerException te) {
                 log.error("Attempt to resolve URI '" + uri + "' failed: ", te);
+                if (validateUserConfigStrictly()) {
+                    return null;
+                }
             }
         }
         if (source == null) {
             // URI Resolver not configured or returned null, use default resolver
             try {
-                source = foURIResolver.resolve(uri, base);
+                source = foURIResolver.resolve(uri, baseUri);
             } catch (TransformerException te) {
                 log.error("Attempt to resolve URI '" + uri + "' failed: ", te);
             }
@@ -846,18 +754,18 @@
      * The FOP URI resolver is used to try and locate the ICC file. 
      * If that fails null is returned.
      * 
-     * @param base a base URI to resolve relative URIs
+     * @param baseUri a base URI to resolve relative URIs
      * @param iccProfileSrc ICC Profile source to return a ColorSpace for
      * @return ICC ColorSpace object or null if ColorSpace could not be created 
      */
-    public ColorSpace getColorSpace(String base, String iccProfileSrc) {
+    public ColorSpace getColorSpace(String baseUri, String iccProfileSrc) {
         ColorSpace colorSpace = null;
-        if (!this.colorSpaceMap.containsKey(base + iccProfileSrc)) {
+        if (!this.colorSpaceMap.containsKey(baseUri + iccProfileSrc)) {
             try {
                 ICC_Profile iccProfile = null;
                 // First attempt to use the FOP URI resolver to locate the ICC
                 // profile
-                Source src = this.resolveURI(iccProfileSrc, base);
+                Source src = this.resolveURI(iccProfileSrc, baseUri);
                 if (src != null && src instanceof StreamSource) {
                     // FOP URI resolver found ICC profile - create ICC profile
                     // from the Source
@@ -882,16 +790,16 @@
 
             if (colorSpace != null) {
                 // Put in cache (not when VM resolved it as we can't control
-                this.colorSpaceMap.put(base + iccProfileSrc, colorSpace);
+                this.colorSpaceMap.put(baseUri + iccProfileSrc, colorSpace);
             } else {
                 // TODO To avoid an excessive amount of warnings perhaps
                 // register a null ColorMap in the colorSpaceMap
                 log.warn("Color profile '" + iccProfileSrc + "' not found.");
             }
         } else {
-            colorSpace = (ColorSpace) this.colorSpaceMap.get(base
+            colorSpace = (ColorSpace) this.colorSpaceMap.get(baseUri
                     + iccProfileSrc);
         }
         return colorSpace;
-    }
+    }    
 }

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactoryConfigurator.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactoryConfigurator.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactoryConfigurator.java Mon May 28 07:31:24 2007
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.apps;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+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.util.LogUtil;
+import org.xml.sax.SAXException;
+
+/**
+ * FopFactory configurator
+ */
+public class FopFactoryConfigurator {
+
+    /** Defines if FOP should use an alternative rule to determine text indents */
+    public static final boolean DEFAULT_BREAK_INDENT_INHERITANCE = false;
+    
+    /** Defines if FOP should validate the user config strictly */
+    public static final boolean DEFAULT_STRICT_USERCONFIG_VALIDATION = true;
+    
+    /** Defines if FOP should use strict validation for FO and user config */
+    public static final boolean DEFAULT_STRICT_FO_VALIDATION = true;
+    
+    /** Defines the default page-width */
+    public static final String DEFAULT_PAGE_WIDTH = "8.26in";
+    
+    /** Defines the default page-height */
+    public static final String DEFAULT_PAGE_HEIGHT = "11in";
+    
+    /** Defines the default source resolution (72dpi) for FOP */
+    public static final float DEFAULT_SOURCE_RESOLUTION = 72.0f; //dpi
+    
+    /** Defines the default target resolution (72dpi) for FOP */
+    public static final float DEFAULT_TARGET_RESOLUTION = 72.0f; //dpi
+    
+    /** Use cache (record previously detected font triplet info) */
+    public static final boolean DEFAULT_USE_CACHE = true;
+
+    /** logger instance */
+    private final Log log = LogFactory.getLog(FopFactoryConfigurator.class);
+
+    /** Fop factory */
+    private FopFactory factory = null;
+
+    /** Fop factory configuration */
+    private Configuration cfg = null;
+
+    /**
+     * Default constructor
+     * @param factory fop factory
+     */
+    public FopFactoryConfigurator(FopFactory factory) {
+        super();
+        this.factory = factory;
+    }
+    
+    /**
+     * Initializes user agent settings from the user configuration
+     * file, if present: baseURL, resolution, default page size,...
+     * @param factory fop factory
+     * @throws FOPException fop exception
+     */
+    public void configure(FopFactory factory) throws FOPException {
+        if (log.isDebugEnabled()) {
+            log.debug("Initializing FopFactory Configuration");        
+        }
+
+        // strict configuration
+        if (cfg.getChild("strict-configuration", false) != null) {
+            try {
+                factory.setStrictUserConfigValidation(
+                        cfg.getChild("strict-configuration").getValueAsBoolean());
+            } catch (ConfigurationException e) {
+                LogUtil.handleException(log, e, false);
+            }
+        }        
+        boolean strict = factory.validateUserConfigStrictly();
+        
+        // strict fo validation
+        if (cfg.getChild("strict-validation", false) != null) {
+            try {
+                factory.setStrictValidation(
+                        cfg.getChild("strict-validation").getValueAsBoolean());
+            } catch (ConfigurationException e) {
+                LogUtil.handleException(log, e, strict);
+            }
+        }
+
+        // base definitions for relative path resolution
+        if (cfg.getChild("base", false) != null) {
+            try {
+                factory.setBaseURL(
+                        cfg.getChild("base").getValue(null));
+            } catch (MalformedURLException mfue) {
+                LogUtil.handleException(log, mfue, strict);
+            }
+        }
+        if (cfg.getChild("font-base", false) != null) {
+            try {
+                factory.setFontBaseURL(
+                        cfg.getChild("font-base").getValue(null));
+            } catch (MalformedURLException mfue) {
+                LogUtil.handleException(log, mfue, strict);
+            }
+        }
+        if (cfg.getChild("hyphenation-base", false) != null) {
+            try {
+                factory.setHyphenBaseURL(
+                        cfg.getChild("hyphenation-base").getValue(null));
+            } catch (MalformedURLException mfue) {
+                LogUtil.handleException(log, mfue, strict);
+            }
+        }
+        
+        // renderer options
+        if (cfg.getChild("source-resolution", false) != null) {
+            factory.setSourceResolution(
+                    cfg.getChild("source-resolution").getValueAsFloat(
+                            FopFactoryConfigurator.DEFAULT_SOURCE_RESOLUTION));
+            if (log.isDebugEnabled()) {
+                log.debug("source-resolution set to: " + factory.getSourceResolution() 
+                    + "dpi (px2mm=" + factory.getSourcePixelUnitToMillimeter() + ")");
+            }
+        }
+        if (cfg.getChild("target-resolution", false) != null) {
+            factory.setTargetResolution(
+                    cfg.getChild("target-resolution").getValueAsFloat(
+                            FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION));
+            if (log.isDebugEnabled()) {
+                log.debug("target-resolution set to: " + factory.getTargetResolution() 
+                        + "dpi (px2mm=" + factory.getTargetPixelUnitToMillimeter()
+                        + ")");                
+            }
+        }
+        if (cfg.getChild("break-indent-inheritance", false) != null) {
+            try {
+                factory.setBreakIndentInheritanceOnReferenceAreaBoundary(
+                        cfg.getChild("break-indent-inheritance").getValueAsBoolean());
+            } catch (ConfigurationException e) {
+                LogUtil.handleException(log, e, strict);
+            }
+        }     
+        Configuration pageConfig = cfg.getChild("default-page-settings");
+        if (pageConfig.getAttribute("height", null) != null) {
+            factory.setPageHeight(
+                    pageConfig.getAttribute("height", FopFactoryConfigurator.DEFAULT_PAGE_HEIGHT));
+            if (log.isInfoEnabled()) {
+                log.info("Default page-height set to: " + factory.getPageHeight());        
+            }
+        }
+        if (pageConfig.getAttribute("width", null) != null) {
+            factory.setPageWidth(
+                    pageConfig.getAttribute("width", FopFactoryConfigurator.DEFAULT_PAGE_WIDTH));
+            if (log.isInfoEnabled()) {
+                log.info("Default page-width set to: " + factory.getPageWidth());
+            }
+        }
+
+        // caching (fonts)
+        if (cfg.getChild("use-cache", false) != null) {
+            try {
+                factory.setUseCache(
+                        cfg.getChild("use-cache").getValueAsBoolean());
+            } catch (ConfigurationException mfue) {
+                LogUtil.handleException(log, mfue, strict);
+            }
+        }
+    }
+    
+    /**
+     * Set the user configuration.
+     * @param userConfigFile the configuration file
+     * @throws IOException if an I/O error occurs
+     * @throws SAXException if a parsing error occurs
+     */
+    public void setUserConfig(File userConfigFile) throws SAXException, IOException {
+        try {
+            DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
+            setUserConfig(cfgBuilder.buildFromFile(userConfigFile));
+        } catch (ConfigurationException e) {
+            throw new FOPException(e);
+        }
+    }
+    
+    /**
+     * Set the user configuration from an URI.
+     * @param uri the URI to the configuration file
+     * @throws IOException if an I/O error occurs
+     * @throws SAXException if a parsing error occurs
+     */
+    public void setUserConfig(String uri) throws SAXException, IOException {
+        try {
+            DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
+            setUserConfig(cfgBuilder.build(uri));
+        } catch (ConfigurationException e) {
+            throw new FOPException(e);
+        }
+    }
+    
+    /**
+     * Set the user configuration.
+     * @param cfg avalon configuration
+     * @throws FOPException if a configuration problem occurs 
+     */
+    public void setUserConfig(Configuration cfg) throws FOPException {
+        this.cfg = cfg;
+        configure(this.factory);
+    }
+    
+    /**
+     * Get the avalon user configuration.
+     * @return the user configuration
+     */
+    public Configuration getUserConfig() {
+        return this.cfg;
+    }    
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeParser.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeParser.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeParser.java Mon May 28 07:31:24 2007
@@ -1060,7 +1060,7 @@
                         if (fontName != null) {
                             String fontStyle = attributes.getValue("font-style");
                             int fontWeight = getAttributeAsInteger(
-                                    attributes, "font-weight", Font.NORMAL);
+                                    attributes, "font-weight", Font.WEIGHT_NORMAL);
                             area.addTrait(trait,
                                     FontInfo.createFontKey(fontName, fontStyle, fontWeight));
                         }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java Mon May 28 07:31:24 2007
@@ -143,7 +143,7 @@
                     dumpConfiguration();
                 }
                 checkSettings();
-                createUserConfig();
+                setUserConfig();
                 
                 //Factory config is set up, now we can create the user agent
                 foUserAgent = factory.newFOUserAgent();
@@ -772,11 +772,11 @@
     }    // end checkSettings
 
     /**
-     * Create the user configuration.
+     * Sets the user configuration.
      * @throws FOPException if creating the user configuration fails
      * @throws IOException
      */
-    private void createUserConfig() throws FOPException, IOException {
+    private void setUserConfig() throws FOPException, IOException {
         if (userConfigFile == null) {
             return;
         }

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CachedFontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CachedFontInfo.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CachedFontInfo.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CachedFontInfo.java Mon May 28 07:31:24 2007
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.fonts;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.xml.utils.URI;
+import org.apache.xml.utils.URI.MalformedURIException;
+
+/**
+ * Font info stored in the cache 
+ */
+public class CachedFontInfo extends EmbedFontInfo {
+
+    /** Serialization Version UID */
+    private static final long serialVersionUID = 240028291961081894L;
+    
+    /** file modify date (if available) */
+    private long lastModified = -1;
+
+    /**
+     * Returns a file given a list of urls
+     * @param urls array of possible font urls
+     * @return file font file 
+     */
+    public static File getFileFromUrls(String[] urls) {
+        for (int i = 0; i < urls.length; i++) {
+            String urlStr = urls[i]; 
+            if (urlStr != null) {
+                if (urlStr.startsWith("file:")) {
+                    URI uri;
+                    try {
+                        uri = new URI(urlStr);
+                        urlStr = uri.getPath();
+                    } catch (MalformedURIException e) {
+                        // do nothing
+                    }
+                }
+                File fontFile = new File(urlStr);
+                if (fontFile.exists() && fontFile.canRead()) {
+                    return fontFile;
+                }
+            }
+        } 
+        return null;
+    }
+
+    /**
+     * Default constructor
+     * @param metricsFile metrics file
+     * @param kerning kerning
+     * @param fontTriplets font triplets
+     * @param embedFile embed file
+     * @param lastModified timestamp that this font was last modified 
+     */
+    public CachedFontInfo(String metricsFile, boolean kerning, List fontTriplets,
+            String embedFile, long lastModified) {
+        super(metricsFile, kerning, fontTriplets, embedFile);
+        this.lastModified = lastModified;
+    }
+
+    /**
+     * Constructor
+     * @param fontInfo an existing embed font info
+     */
+    public CachedFontInfo(EmbedFontInfo fontInfo) {
+        super(fontInfo.metricsFile, fontInfo.kerning, fontInfo.fontTriplets, fontInfo.embedFile);
+        // try and determine modified date
+        File fontFile = getFileFromUrls(new String[] {embedFile, metricsFile});
+        if (fontFile != null ) {
+            this.lastModified = fontFile.lastModified();
+        }
+    }
+
+    /**
+     * Gets the modified timestamp for font file (not always available)
+     * @return modified timestamp
+     */
+    public long lastModified() {
+        return this.lastModified;
+    }
+
+    /**
+     * Gets the modified timestamp for font file
+     * (used for the purposes of font info caching) 
+     * @param lastModified modified font file timestamp
+     */
+    public void setLastModified(long lastModified) {
+        this.lastModified = lastModified;
+    }
+    
+    /**
+     * @return string representation of this object 
+     * @see java.lang.Object#toString()
+     */
+    public String toString() {
+        return super.toString() + ", lastModified=" + lastModified;
+    }
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CachedFontInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java Mon May 28 07:31:24 2007
@@ -30,8 +30,9 @@
             implements FontDescriptor, MutableFont {
 
     private String fontName = null;
+    private String fontSubName = null;
     private String embedFileName = null;
-    protected String embedResourceName = null;
+    private String embedResourceName = null;
     private FontResolver resolver = null;
     
     private int capHeight = 0;
@@ -51,7 +52,6 @@
 
     private boolean useKerning = true;
 
-
     /**
      * @see org.apache.fop.fonts.FontMetrics#getFontName()
      */
@@ -60,6 +60,21 @@
     }
 
     /**
+     * @see org.apache.fop.fonts.FontMetrics#getStrippedFontName()
+     */
+    public String getStrippedFontName() {
+        return FontUtil.stripWhiteSpace(fontName);
+    }
+
+    /**
+     * Returns font's subfamily name.
+     * @return the font's subfamily name
+     */
+    public String getFontSubName() {
+        return fontSubName;
+    }
+
+    /**
      * Returns an URI representing an embeddable font file. The URI will often
      * be a filename or an URL.
      * @return URI to an embeddable font file or null if not available.
@@ -238,6 +253,14 @@
         this.fontName = name;
     }
 
+    /**
+     * Sets the font's subfamily name.
+     * @param subFamilyName the subfamily name of the font
+     */
+    public void setFontSubFamilyName(String subFamilyName) {
+        this.fontSubName = subFamilyName;        
+    }
+    
     /**
      * @see org.apache.fop.fonts.MutableFont#setEmbedFileName(String)
      */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EmbedFontInfo.java Mon May 28 07:31:24 2007
@@ -19,17 +19,26 @@
  
 package org.apache.fop.fonts;
 
+import java.io.Serializable;
 import java.util.List;
 
 /**
  * FontInfo contains meta information on fonts (where is the metrics file etc.)
  */
-public class EmbedFontInfo {
+public class EmbedFontInfo implements Serializable {
     
-    private String metricsFile, embedFile;
-    private boolean kerning;
-    private List fontTriplets;
-
+    /** Serialization Version UID */
+    private static final long serialVersionUID = -9075848379822693399L;
+    
+    /** filename of the metrics file */
+    protected String metricsFile;
+    /** filename of the main font file */
+    protected String embedFile;
+    /** false, to disable kerning */
+    protected boolean kerning;
+    /** the list of associated font triplets */
+    protected List fontTriplets;
+      
     /**
      * Main constructor
      * @param metricsFile Path to the xml file containing font metrics
@@ -44,7 +53,7 @@
         this.kerning = kerning;
         this.fontTriplets = fontTriplets;
     }
-
+        
     /**
      * Returns the path to the metrics file
      * @return the metrics file path
@@ -76,6 +85,10 @@
     public List getFontTriplets() {
         return fontTriplets;
     }
-
+    
+    /** @see java.lang.Object#toString() */
+    public String toString() {
+        return "metrics-url=" + metricsFile + ",embed-url=" + embedFile
+            + ", kerning=" + kerning + ", font-triplet=" + fontTriplets; 
+    }
 }
-

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java Mon May 28 07:31:24 2007
@@ -27,12 +27,22 @@
  */
 public class Font {
 
-    /** Default fallback key */
-    public static final FontTriplet DEFAULT_FONT = new FontTriplet("any", "normal", 400);
-    /** Normal font weight */
-    public static final int NORMAL = 400;
     /** Bold font weight */
-    public static final int BOLD = 700;
+    public static final int WEIGHT_BOLD = 700;
+
+    /** Normal font weight */
+    public static final int WEIGHT_NORMAL = 400;
+
+    /** Normal font style */
+    public static final String STYLE_NORMAL = "normal";
+
+    /** Italic font style */
+    public static final String STYLE_ITALIC = "italic";
+
+    /** Default fallback key */
+    public static final FontTriplet DEFAULT_FONT = new FontTriplet(
+                    "any", STYLE_NORMAL, WEIGHT_NORMAL);
+
 
     private String fontName;
     private FontTriplet triplet;



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