You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by bu...@apache.org on 2012/04/15 07:39:54 UTC

svn commit: r813018 [21/24] - in /websites/staging/xmlgraphics/trunk/content: ./ fop/ fop/0.95/ fop/0.95/images/ fop/1.0/ fop/1.0/images/ fop/dev/ fop/dev/design/ fop/dev/fo/ fop/dev/svg/ fop/fo/ fop/trunk/ fop/trunk/images/

Added: websites/staging/xmlgraphics/trunk/content/fop/trunk/events.html
==============================================================================
--- websites/staging/xmlgraphics/trunk/content/fop/trunk/events.html (added)
+++ websites/staging/xmlgraphics/trunk/content/fop/trunk/events.html Sun Apr 15 05:39:50 2012
@@ -0,0 +1,269 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html lang="en">
+  <head>
+    <title>Apache™ FOP: Events/Processing Feedback</title>
+
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+    <meta property="og:image" content="http://www.apache.org/images/asf_logo.gif" />
+<!--
+    <link rel="stylesheet" type="text/css" media="screen" href="http://www.apache.org/css/style.css">
+    <link rel="stylesheet" type="text/css" media="screen" href="http://www.apache.org/css/code.css">
+-->
+    <link href="/css/xmlgraphics.css" rel="stylesheet" type="text/css">
+
+    </style>
+
+    
+
+    
+    
+  </head>
+
+  <body>
+	  <div id="banner">&nbsp;
+	  </div>
+
+	  <div id="navigation">
+	  <h1 id="xml-graphics">XML Graphics</h1>
+<ul>
+<li><a href="/">Overview</a></li>
+<li><a href="/team.html">Who We Are</a></li>
+<li><a href="/legal.html">Legal Stuff</a></li>
+<li><a href="/charter.html">Project Charter</a></li>
+<li><a href="/mail.html">Mailing Lists</a></li>
+<li><a href="/repo.html">Code Repositories</a></li>
+<li><a href="http://www.apache.org/foundation/sponsorship.html">ASF Sponsorship Program</a></li>
+<li><a href="http://www.apache.org/foundation/thanks.html">ASF Thanks</a></li>
+</ul>
+<h1 id="subprojects">Subprojects</h1>
+<ul>
+<li><a href="/batik/">Batik</a></li>
+<li><a href="/fop/">FOP</a></li>
+<li><a href="/commons/">Commons</a></li>
+</ul>
+<form name="search" id="search" action="http://www.google.com/search" method="get">
+  <input value="xmlgraphics.apache.org" name="sitesearch" type="hidden"/>
+  <input type="text" name="q" id="query" /><br />
+  <input type="submit" id="submit" value="Search" />
+</form>
+	  </div>
+	
+	  <div id="bannertext">
+        <a href="/"><img src="/images/apache-xml-graphics.gif" alt="The Apache XML Graphics Project" width="220" heigh="51" /></a>
+        <h1>Apache™ FOP: Events/Processing Feedback</h1>
+      </div>
+        <p><a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/fop/">Fop</a>&nbsp;&raquo&nbsp;<a href="/fop/trunk/">Trunk</a></p>
+      </div>
+      <div id="content" class="grid_16"><div class="section-content"><p><version>$Revision: 1298724 $</version></p>
+<h1 id="introduction">Introduction</h1>
+<p>In versions until 0.20.5, Apache™ FOP used <a href="http://excalibur.apache.org/framework/index.html">Avalon-style Logging</a> where it was possible to supply a logger per processing run. During the redesign the logging infrastructure was switched over to <a href="http://commons.apache.org/logging/">Commons Logging</a> which is (like Log4J or java.util.logging) a "static" logging framework (the logger is accessed through static variables). This made it very difficult in a multi-threaded system to retrieve information for a single processing run.</p>
+<p>With FOP's event subsystem, we'd like to close this gap again and even go further. The first point is to realize that we have two kinds of "logging". Firstly, we have the logging infrastructure for the (FOP) developer who needs to be able to enable finer log messages for certain parts of FOP to track down a certain problem. Secondly, we have the user who would like to be informed about missing images, overflowing lines or substituted fonts. These messages (or events) are targeted at less technical people and may ideally be localized (translated). Furthermore, tool and solution builders would like to integrate FOP into their own solutions. For example, an FO editor should be able to point the user to the right place where a particular problem occurred while developing a document template. Finally, some integrators would like to abort processing if a resource (an image or a font) has not been found, while others would simply continue. The event system allows to react on the
 se events.</p>
+<p>On this page, we won't discuss logging as such. We will show how the event subsystem can be used for various tasks. We'll first look at the event subsystem from the consumer side. Finally, the production of events inside FOP will be discussed (this is mostly interesting for FOP developers only).</p>
+<h1 id="consumer">The consumer side</h1>
+<p>The event subsystem is located in the <code>org.apache.fop.events</code> package and its base is the <code>Event</code> class. An instance is created for each event and is sent to a set of <code>EventListener</code> instances by the <code>EventBroadcaster</code> . An <code>Event</code> contains:</p>
+<ul>
+<li>
+<p>an event ID,</p>
+</li>
+<li>
+<p>a source object (which generated the event),</p>
+</li>
+<li>
+<p>a severity level (Info, Warning, Error and Fatal Error) and</p>
+</li>
+<li>
+<p>a map of named parameters.</p>
+</li>
+</ul>
+<p>The <code>EventFormatter</code> class can be used to translate the events into human-readable, localized messages.</p>
+<p>A full example of what is shown here can be found in the <code>examples/embedding/java/embedding/events</code> directory in the FOP distribution. The example can also be accessed <a href="http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/examples/embedding/java/embedding/events/">via the web</a> .</p>
+<h2 id="write-listener">Writing an EventListener</h2>
+<p>The following code sample shows a very simple EventListener. It basically just sends all events to System.out (stdout) or System.err (stderr) depending on the event severity.
+import org.apache.fop.events.Event;
+import org.apache.fop.events.EventFormatter;
+import org.apache.fop.events.EventListener;
+import org.apache.fop.events.model.EventSeverity;</p>
+<p>/*<em> A simple event listener that writes the events to stdout and stderr. </em>/
+public class SysOutEventListener implements EventListener {</p>
+<div class="codehilite"><pre><span class="sr">/** {@inheritDoc} */</span>
+<span class="n">public</span> <span class="n">void</span> <span class="n">processEvent</span><span class="p">(</span><span class="n">Event</span> <span class="n">event</span><span class="p">)</span> <span class="p">{</span>
+    <span class="n">String</span> <span class="n">msg</span> <span class="o">=</span> <span class="n">EventFormatter</span><span class="o">.</span><span class="nb">format</span><span class="p">(</span><span class="n">event</span><span class="p">);</span>
+    <span class="n">EventSeverity</span> <span class="n">severity</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">getSeverity</span><span class="p">();</span>
+    <span class="k">if</span> <span class="p">(</span><span class="n">severity</span> <span class="o">==</span> <span class="n">EventSeverity</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span> <span class="p">{</span>
+        <span class="n">System</span><span class="o">.</span><span class="n">out</span><span class="o">.</span><span class="n">println</span><span class="p">(</span><span class="s">&quot;[INFO ] &quot;</span> <span class="o">+</span> <span class="n">msg</span><span class="p">);</span>
+    <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">severity</span> <span class="o">==</span> <span class="n">EventSeverity</span><span class="o">.</span><span class="n">WARN</span><span class="p">)</span> <span class="p">{</span>
+        <span class="n">System</span><span class="o">.</span><span class="n">out</span><span class="o">.</span><span class="n">println</span><span class="p">(</span><span class="s">&quot;[WARN ] &quot;</span> <span class="o">+</span> <span class="n">msg</span><span class="p">);</span>
+    <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">severity</span> <span class="o">==</span> <span class="n">EventSeverity</span><span class="o">.</span><span class="n">ERROR</span><span class="p">)</span> <span class="p">{</span>
+        <span class="n">System</span><span class="o">.</span><span class="n">err</span><span class="o">.</span><span class="n">println</span><span class="p">(</span><span class="s">&quot;[ERROR] &quot;</span> <span class="o">+</span> <span class="n">msg</span><span class="p">);</span>
+    <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">severity</span> <span class="o">==</span> <span class="n">EventSeverity</span><span class="o">.</span><span class="n">FATAL</span><span class="p">)</span> <span class="p">{</span>
+        <span class="n">System</span><span class="o">.</span><span class="n">err</span><span class="o">.</span><span class="n">println</span><span class="p">(</span><span class="s">&quot;[FATAL] &quot;</span> <span class="o">+</span> <span class="n">msg</span><span class="p">);</span>
+    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+        <span class="n">assert</span> <span class="n">false</span><span class="p">;</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>}
+You can see that for every event the method <code>processEvent</code> of the <code>EventListener</code> will be called. Inside this method you can do whatever processing you would like including throwing a <code>RuntimeException</code> , if you want to abort the current processing run.</p>
+<p>The code above also shows how you can turn an event into a human-readable, localized message that can be presented to a user. The <code>EventFormatter</code> class does this for you. It provides additional methods if you'd like to explicitly specify the locale.</p>
+<p>It is possible to gather all events for a whole processing run so they can be evaluated afterwards. However, care should be taken about memory consumption since the events provide references to objects inside FOP which may themselves have references to other objects. So holding on to these objects may mean that whole object trees cannot be released!</p>
+<h2 id="add-listener">Adding an EventListener</h2>
+<p>To register the event listener with FOP, get the <code>EventBroadcaster</code> which is associated with the user agent ( <code>FOUserAgent</code> ) and add it there:
+FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
+foUserAgent.getEventBroadcaster().addEventListener(new SysOutEventListener());
+Please note that this is done separately for each processing run, i.e. for each new user agent.</p>
+<h2 id="listener-example1">An additional listener example</h2>
+<p>Here's an additional example of an event listener:</p>
+<p>By default, FOP continues processing even if an image wasn't found. If you have more strict requirements and want FOP to stop if an image is not available, you can do something like the following in the simplest case:
+public class MyEventListener implements EventListener {</p>
+<div class="codehilite"><pre><span class="n">public</span> <span class="n">void</span> <span class="n">processEvent</span><span class="p">(</span><span class="n">Event</span> <span class="n">event</span><span class="p">)</span> <span class="p">{</span>
+    <span class="k">if</span> <span class="p">(</span><span class="s">&quot;org.apache.fop.ResourceEventProducer&quot;</span><span class="o">.</span><span class="n">equals</span><span class="p">(</span>
+            <span class="n">event</span><span class="o">.</span><span class="n">getEventGroupID</span><span class="p">()))</span> <span class="p">{</span>
+        <span class="n">event</span><span class="o">.</span><span class="n">setSeverity</span><span class="p">(</span><span class="n">EventSeverity</span><span class="o">.</span><span class="n">FATAL</span><span class="p">);</span>
+    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+        <span class="sr">//ig</span><span class="n">nore</span> <span class="n">all</span> <span class="n">other</span> <span class="n">events</span> <span class="p">(</span><span class="ow">or</span> <span class="k">do</span> <span class="n">something</span> <span class="n">of</span> <span class="n">your</span> <span class="n">choice</span><span class="p">)</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>}
+Increasing the event severity to FATAL will signal the event broadcaster to throw an exception and stop further processing. In the above case, all resource-related events will cause FOP to stop processing.</p>
+<p>You can also customize the exception to throw (you can may throw a RuntimeException or subclass yourself) and/or which event to respond to:
+public class MyEventListener implements EventListener {</p>
+<div class="codehilite"><pre><span class="n">public</span> <span class="n">void</span> <span class="n">processEvent</span><span class="p">(</span><span class="n">Event</span> <span class="n">event</span><span class="p">)</span> <span class="p">{</span>
+    <span class="k">if</span> <span class="p">(</span><span class="s">&quot;org.apache.fop.ResourceEventProducer.imageNotFound&quot;</span>
+            <span class="o">.</span><span class="n">equals</span><span class="p">(</span><span class="n">event</span><span class="o">.</span><span class="n">getEventID</span><span class="p">()))</span> <span class="p">{</span>
+
+        <span class="sr">//</span><span class="n">Get</span> <span class="n">the</span> <span class="n">FileNotFoundException</span> <span class="n">that</span><span class="s">&#39;s part of the event&#39;</span><span class="n">s</span> <span class="n">parameters</span>
+        <span class="n">FileNotFoundException</span> <span class="n">fnfe</span> <span class="o">=</span> <span class="p">(</span><span class="n">FileNotFoundException</span><span class="p">)</span><span class="n">event</span><span class="o">.</span><span class="n">getParam</span><span class="p">(</span><span class="s">&quot;fnfe&quot;</span><span class="p">);</span>
+
+        <span class="n">throw</span> <span class="k">new</span> <span class="n">RuntimeException</span><span class="p">(</span><span class="n">EventFormatter</span><span class="o">.</span><span class="nb">format</span><span class="p">(</span><span class="n">event</span><span class="p">),</span> <span class="n">fnfe</span><span class="p">);</span>
+    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+        <span class="sr">//ig</span><span class="n">nore</span> <span class="n">all</span> <span class="n">other</span> <span class="n">events</span> <span class="p">(</span><span class="ow">or</span> <span class="k">do</span> <span class="n">something</span> <span class="n">of</span> <span class="n">your</span> <span class="n">choice</span><span class="p">)</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>}
+This throws a <code>RuntimeException</code> with the <code>FileNotFoundException</code> as the cause. Further processing effectively stops in FOP. You can catch the exception in your code and react as you see necessary.</p>
+<h1 id="producer">The producer side (for FOP developers)</h1>
+<p>This section is primarily for FOP and FOP plug-in developers. It describes how to use the event subsystem for producing events.
+The event package has been designed in order to be theoretically useful for use cases outside FOP. If you think this is interesting independently from FOP, please talk to <a href="mailto:fop-dev@xmlgraphics.apache.org">us</a> .</p>
+<h2 id="basic-event-production">Producing and sending an event</h2>
+<p>The basics are very simple. Just instantiate an <code>Event</code> object and fill it with the necessary parameters. Then pass it to the <code>EventBroadcaster</code> which distributes the events to the interested listeneners. Here's a code example:
+Event ev = new Event(this, "complain", EventSeverity.WARN,
+        Event.paramsBuilder()
+            .param("reason", "I'm tired")
+            .param("blah", new Integer(23))
+            .build());
+EventBroadcaster broadcaster = [get it from somewhere];
+broadcaster.broadcastEvent(ev);</p>
+<p>The <code>Event.paramsBuilder()</code> is a <a href="http://en.wikipedia.org/wiki/Fluent_interface">fluent interface</a> to help with the build-up of the parameters. You could just as well instantiate a <code>Map</code> ( <code>Map&lt;String, Object&gt;</code> ) and fill it with values.</p>
+<h2 id="event-producer">The EventProducer interface</h2>
+<p>To simplify event production, the event subsystem provides the <code>EventProducer</code> interface. You can create interfaces which extend <code>EventProducer</code> . These interfaces will contain one method per event to be generated. By contract, each event method must have as its first parameter a parameter named "source" (Type Object) which indicates the object that generated the event. After that come an arbitrary number of parameters of any type as needed by the event.</p>
+<p>The event producer interface does not need to have any implementation. The implementation is produced at runtime by a dynamic proxy created by <code>DefaultEventBroadcaster</code> . The dynamic proxy creates <code>Event</code> instances for each method call against the event producer interface. Each parameter (except "source") is added to the event's parameter map.</p>
+<p>To simplify the code needed to get an instance of the event producer interface it is suggested to create a public inner provider class inside the interface.</p>
+<p>Here's an example of such an event producer interface:
+public interface MyEventProducer extends EventProducer {</p>
+<div class="codehilite"><pre><span class="n">public</span> <span class="n">class</span> <span class="n">Provider</span> <span class="p">{</span>
+
+    <span class="n">public</span> <span class="n">static</span> <span class="n">MyEventProducer</span> <span class="n">get</span><span class="p">(</span><span class="n">EventBroadcaster</span> <span class="n">broadcaster</span><span class="p">)</span> <span class="p">{</span>
+        <span class="k">return</span> <span class="p">(</span><span class="n">MyEventProducer</span><span class="p">)</span><span class="n">broadcaster</span><span class="o">.</span><span class="n">getEventProducerFor</span><span class="p">(</span><span class="n">MyEventProducer</span><span class="o">.</span><span class="n">class</span><span class="p">);</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+
+<span class="o">/**</span>
+ <span class="o">*</span> <span class="n">Complain</span> <span class="n">about</span> <span class="n">something</span><span class="o">.</span>
+ <span class="o">*</span> <span class="nv">@param</span> <span class="n">source</span> <span class="n">the</span> <span class="n">event</span> <span class="n">source</span>
+ <span class="o">*</span> <span class="nv">@param</span> <span class="n">reason</span> <span class="n">the</span> <span class="n">reason</span> <span class="k">for</span> <span class="n">the</span> <span class="n">complaint</span>
+ <span class="o">*</span> <span class="nv">@param</span> <span class="n">blah</span> <span class="n">the</span> <span class="n">complaint</span>
+ <span class="o">*</span> <span class="nv">@event</span><span class="o">.</span><span class="n">severity</span> <span class="n">WARN</span>
+ <span class="o">*/</span>
+<span class="n">void</span> <span class="n">complain</span><span class="p">(</span><span class="n">Object</span> <span class="n">source</span><span class="p">,</span> <span class="n">String</span> <span class="n">reason</span><span class="p">,</span> <span class="nb">int</span> <span class="n">blah</span><span class="p">);</span>
+</pre></div>
+
+
+<p>}
+To produce the same event as in the first example above, you'd use the following code:
+EventBroadcaster broadcaster = [get it from somewhere];
+TestEventProducer producer = TestEventProducer.Provider.get(broadcaster);
+producer.complain(this, "I'm tired", 23);</p>
+<h2 id="event-model">The event model</h2>
+<p>Inside an invocation handler for a dynamic proxy, there's no information about the names of each parameter. The JVM doesn't provide it. The only thing you know is the interface and method name. In order to properly fill the <code>Event</code> 's parameter map we need to know the parameter names. These are retrieved from an event object model. This is found in the <code>org.apache.fop.events.model</code> package. The data for the object model is retrieved from an XML representation of the event model that is loaded as a resource. The XML representation is generated using an Ant task at build time ( <code>ant resourcegen</code> ). The Ant task (found in <code>src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java</code> ) scans FOP's sources for descendants of the <code>EventProducer</code> interface and uses <a href="http://qdox.codehaus.org/">QDox</a> to parse these interfaces.</p>
+<p>The event model XML files are generated during build by the Ant task mentioned above when running the "resourcegen" task. So just run <code>"ant resourcegen"</code> if you receive a <code>MissingResourceException</code> at runtime indicating that <code>"event-model.xml"</code> is missing.</p>
+<p>Primarily, the QDox-based collector task records the parameters' names and types. Furthermore, it extracts additional attributes embedded as Javadoc comments from the methods. At the moment, the only such attribute is "@event.severity" which indicates the default event severity (which can be changed by event listeners). The example event producer above shows the Javadocs for an event method.</p>
+<p>There's one more information that is extracted from the event producer information for the event model: an optional primary exception. The first exception in the "throws" declaration of an event method is noted. It is used to throw an exception from the invocation handler if the event has an event severity of "FATAL" when all listeners have been called (listeners can update the event severity). Please note that an implementation of <code>org.apache.fop.events.EventExceptionManager$ExceptionFactory</code> has to be registered for the <code>EventExceptionManager</code> to be able to construct the exception from an event.</p>
+<p>For a given application, there can be multiple event models active at the same time. In FOP, each renderer is considered to be a plug-in and provides its own specific event model. The individual event models are provided through an <code>EventModelFactory</code> . This interface is implemented for each event model and registered through the service provider mechanism (see the <a href="#plug-ins">plug-ins section</a> for details).</p>
+<h2 id="event-severity">Event severity</h2>
+<p>Four different levels of severity for events has been defined:</p>
+<ol>
+<li>
+<p>INFO: informational only</p>
+</li>
+<li>
+<p>WARN: a Warning</p>
+</li>
+<li>
+<p>ERROR: an error condition from which FOP can recover. FOP will continue processing.</p>
+</li>
+<li>
+<p>FATAL: a fatal error which causes an exception in the end and FOP will stop processing.</p>
+</li>
+</ol>
+<p>Event listeners can choose to ignore certain events based on their event severity. Please note that you may recieve an event "twice" in a specific case: if there is a fatal error an event is generated and sent to the listeners. After that an exception is thrown with the same information and processing stops. If the fatal event is shown to the user and the following exception is equally presented to the user it may appear that the event is duplicated. Of course, the same information is just published through two different channels.</p>
+<h2 id="plug-ins">Plug-ins to the event subsystem</h2>
+<p>The event subsystem is extensible. There are a number of extension points:</p>
+<ul>
+<li>
+<p><strong> <code>org.apache.fop.events.model.EventModelFactory</code> :</strong> Provides an event model to the event subsystem.</p>
+</li>
+<li>
+<p><strong> <code>org.apache.fop.events.EventExceptionManager$ExceptionFactory</code> :</strong> Creates exceptions for events, i.e. turns an event into a specific exception.</p>
+</li>
+</ul>
+<p>The names in bold above are used as filenames for the service provider files that are placed in the <code>META-INF/services</code> directory. That way, they are automatically detected. This is a mechanism defined by the <a href="http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Service%20Provider">JAR file specification</a> .</p>
+<h2 id="l10n">Localization (L10n)</h2>
+<p>One goal of the event subsystem was to have localized (translated) event messages. The <code>EventFormatter</code> class can be used to convert an event to a human-readable message. Each <code>EventProducer</code> can provide its own XML-based translation file. If there is none, a central translation file is used, called "EventFormatter.xml" (found in the same directory as the <code>EventFormatter</code> class).</p>
+<p>The XML format used by the <code>EventFormatter</code> is the same as <a href="http://cocoon.apache.org/">Apache Cocoon's</a> catalog format. Here's an example:
+&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+<catalogue xml:lang="en">
+  <message key="locator">
+    [ (See position {loc})| (See {#gatherContextInfo})| (No context info available)]
+  </message>
+  <message key="org.apache.fop.render.rtf.RTFEventProducer.explicitTableColumnsRequired">
+    RTF output requires that all table-columns for a table are defined. Output will be incorrect.{{locator}}
+  </message>
+  <message key="org.apache.fop.render.rtf.RTFEventProducer.ignoredDeferredEvent">
+    Ignored deferred event for {node} ({start,if,start,end}).{{locator}}
+  </message>
+</catalogue></p>
+<p>The example (extracted from the RTF handler's event producer) has message templates for two event methods. The class used to do variable replacement in the templates is <code>org.apache.fop.util.text.AdvancedMessageFormat</code> which is more powerful than the <code>MessageFormat</code> classes provided by the Java class library ( <code>java.util.text</code> package).</p>
+<p>"locator" is a template that is reused by the other message templates by referencing it through "{{locator}}". This is some kind of include command.</p>
+<p>Normal event parameters are accessed by name inside single curly braces, for example: "{node}". For objects, this format just uses the <code>toString()</code> method to turn the object into a string, unless there is an <code>ObjectFormatter</code> registered for that type (there's an example for <code>org.xml.sax.Locator</code> ).</p>
+<p>The single curly braces pattern supports additional features. For example, it is possible to do this: "{start,if,start,end}". "if" here is a special field modifier that evaluates "start" as a boolean and if that is true returns the text right after the second comma ("start"). Otherwise it returns the text after the third comma ("end"). The "equals" modifier is similar to "if" but it takes as an additional (comma-separated) parameter right after the "equals" modifier, a string that is compared to the value of the variable. An example: {severity,equals,EventSeverity:FATAL,,some text} (this adds "some text" if the severity is not FATAL).</p>
+<p>Additional such modifiers can be added by implementing the <code>AdvancedMessageFormat$Part</code> and <code>AdvancedMessageFormat$PartFactory</code> interfaces.</p>
+<p>Square braces can be used to specify optional template sections. The whole section will be omitted if any of the variables used within are unavailable. Pipe (|) characters can be used to specify alternative sub-templates (see "locator" above for an example).</p>
+<p>Developers can also register a function (in the above example: <code>{#gatherContextInfo})</code> to do more complex information rendering. These functions are implementations of the <code>AdvancedMessageFormat$Function</code> interface. Please take care that this is done in a locale-independent way as there is no locale information available, yet.</p></div></div>
+      <div class="clear"></div>
+
+	  <div id="footer">
+		<a alt="Apache Software Foundation" href="http://www.apache.org">
+		  <img id="asf-logo" alt="Apache Software Foundation" src="/images/feather-small.gif"/ width="100">
+		</a>
+		<div class="copyright">
+		  <p>
+			Copyright &copy; 2011 The Apache Software Foundation, Licensed under
+			the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.
+			<br />
+			Apache, Apache XML Graphics, the Apache feather logo, and the Apache XML Graphics logos are
+			trademarks of <a href="http://www.apache.org">The Apache Software Foundation</a>. All other
+			marks mentioned may be trademarks or registered trademarks of their respective owners.
+			<br />
+		  </p>
+		</div> 
+	  </div>
+  </body>
+</html>

Added: websites/staging/xmlgraphics/trunk/content/fop/trunk/extensions.html
==============================================================================
--- websites/staging/xmlgraphics/trunk/content/fop/trunk/extensions.html (added)
+++ websites/staging/xmlgraphics/trunk/content/fop/trunk/extensions.html Sun Apr 15 05:39:50 2012
@@ -0,0 +1,212 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html lang="en">
+  <head>
+    <title>Standard Apache™ FOP Extensions</title>
+
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+    <meta property="og:image" content="http://www.apache.org/images/asf_logo.gif" />
+<!--
+    <link rel="stylesheet" type="text/css" media="screen" href="http://www.apache.org/css/style.css">
+    <link rel="stylesheet" type="text/css" media="screen" href="http://www.apache.org/css/code.css">
+-->
+    <link href="/css/xmlgraphics.css" rel="stylesheet" type="text/css">
+
+    </style>
+
+    
+
+    
+    
+  </head>
+
+  <body>
+	  <div id="banner">&nbsp;
+	  </div>
+
+	  <div id="navigation">
+	  <h1 id="xml-graphics">XML Graphics</h1>
+<ul>
+<li><a href="/">Overview</a></li>
+<li><a href="/team.html">Who We Are</a></li>
+<li><a href="/legal.html">Legal Stuff</a></li>
+<li><a href="/charter.html">Project Charter</a></li>
+<li><a href="/mail.html">Mailing Lists</a></li>
+<li><a href="/repo.html">Code Repositories</a></li>
+<li><a href="http://www.apache.org/foundation/sponsorship.html">ASF Sponsorship Program</a></li>
+<li><a href="http://www.apache.org/foundation/thanks.html">ASF Thanks</a></li>
+</ul>
+<h1 id="subprojects">Subprojects</h1>
+<ul>
+<li><a href="/batik/">Batik</a></li>
+<li><a href="/fop/">FOP</a></li>
+<li><a href="/commons/">Commons</a></li>
+</ul>
+<form name="search" id="search" action="http://www.google.com/search" method="get">
+  <input value="xmlgraphics.apache.org" name="sitesearch" type="hidden"/>
+  <input type="text" name="q" id="query" /><br />
+  <input type="submit" id="submit" value="Search" />
+</form>
+	  </div>
+	
+	  <div id="bannertext">
+        <a href="/"><img src="/images/apache-xml-graphics.gif" alt="The Apache XML Graphics Project" width="220" heigh="51" /></a>
+        <h1>Standard Apache™ FOP Extensions</h1>
+      </div>
+        <p><a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/fop/">Fop</a>&nbsp;&raquo&nbsp;<a href="/fop/trunk/">Trunk</a></p>
+      </div>
+      <div id="content" class="grid_16"><div class="section-content"><p><version>$Revision: 1298724 $</version></p>
+<p>By "extension", we mean any data that can be placed in the input XML document that is not addressed by the XSL-FO standard. By having a mechanism for supporting extensions, Apache™ FOP is able to add features that are not covered in the specification.</p>
+<p>The extensions documented here are included with FOP, and are automatically available to you. If you wish to add an extension of your own to FOP, please see the <a href="../dev/extensions.html">Developers' Extension Page</a> .
+All extensions require the correct use of an appropriate namespace in your input document.</p>
+<h1 id="svg">SVG</h1>
+<p>Please see the <a href="graphics.html#svg">SVG documentation</a> for more details.</p>
+<h1 id="fo-extensions">FO Extensions</h1>
+<h2 id="fox-namespace">Namespace</h2>
+<p>By convention, FO extensions in FOP use the "fox" namespace prefix. To use any of the FO extensions, add a namespace entry for <code>http://xmlgraphics.apache.org/fop/extensions</code> to the root element:
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
+               xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"></p>
+<h2 id="bookmarks">PDF Bookmarks</h2>
+<p>In old versions of Apache FOP there was a <code>fox:outline</code> element which was used to create outlines in PDF files. The redesigned code makes use of the <a href="http://www.w3.org/TR/xsl11/#fo_bookmark-tree">bookmark feature defined in the W3C XSL 1.1 standard</a> .</p>
+<h2 id="named-destinations">Anchors or Named Destinations</h2>
+<p>Use the fox:destination element to define "named destinations" inside a PDF document. These are useful as fragment identifiers, e.g. "http://server/document.pdf#anchor-name". fox:destination elements can be placed almost anywhere in the fo document, including a child of root, a block-level element, or an inline-level element. For the destination to actually work, it must correspond to an "id" attribute on some fo element within the document. In other words, the "id" attribute actually creates the "view" within the PDF document. The fox:destination simply gives that view an independent name.
+<fox:destination internal-destination="table-of-contents"/>
+...
+<fo:block id="table-of-contents">Table of Contents</fo:block><warning>It is possible that in some future release of FOP, <em>all</em> elements with "id" attributes will generate named-destinations, which will eliminate the need for fox:destination.</warning></p>
+<h2 id="table-continue-label">Table Continuation Label</h2>
+<p>This extension element hasn't been reimplemented for the redesigned code, yet.</p>
+<h2 id="widow-orphan-content-limit">fox:orphan-content-limit and fox:widow-content-limit</h2>
+<p>The two proprietary extension properties, fox:orphan-content-limit and fox:widow-content-limit, are used to improve the layout of list-blocks and tables. If you have a table with many entries, you don't want a single row to be left over on a page. You will want to make sure that at least two or three lines are kept together. The properties take an absolute length which specifies the area at the beginning (fox:widow-content-limit) or at the end (fox:orphan-content-limit) of a table or list-block. The properties are inherited and only have an effect on fo:table and fo:list-block. An example: fox:widow-content-limit="3 * 1.2em" would make sure the you'll have at least three lines (assuming line-height="1.2") together on a table or list-block.</p>
+<h2 id="external-document">fox:external-document</h2>
+<p>This feature is incomplete. Support for multi-page documents will be added shortly. At the moment, only single-page images will work. And this will not work with RTF output.
+This is a proprietary extension element which allows to add whole images as pages to an FO document. For example, if you have a scanned document or a fax as multi-page TIFF file, you can append or insert this document using the <code>fox:external-document</code> element. Each page of the external document will create one full page in the target format.</p>
+<p>The <code>fox:external-document</code> element is structurally a peer to <code>fo:page-sequence</code> , so wherever you can put an <code>fo:page-sequence</code> you could also place a <code>fox:external-document</code> . Therefore, the specified contents for <code>fo:root</code> change to:</p>
+<p><code>(layout-master-set, declarations?, bookmark-tree?, (page-sequence|page-sequence-wrapper|fox:external-document|fox:destination)+)</code> </p>
+<h3 id="Specification">Specification</h3>
+<p>The <code>fox:external-document</code> extension formatting object is used to specify how to create a (sub-)sequence of pages within a document. The content of these pages comes from the individual subimages/pages of an image or paged document (for example: multi-page TIFF in the form of faxes or scanned documents, or PDF files). The formatting object creates the necessary areas to display one image per page.</p>
+<p>In terms of page numbers, the behaviour is the same as for <code>fo:page-sequence</code> . The placement of the image inside the page is similar to that of <code>fo:external-graphic</code> or <code>fo:instream-foreign-object</code> , i.e. the viewport (and therefore the page size) is defined by either the intrinsic size of the image or by the size properties that apply to this formatting object.</p>
+<p>Content: EMPTY</p>
+<p>The following properties apply to this formatting object:</p>
+<ul>
+<li>
+<p>(Common Accessibility Properties) (not implemented, yet)</p>
+</li>
+<li>
+<p>(Common Aural Properties) (not implemented, yet)</p>
+</li>
+<li>
+<p>block-progression-dimension</p>
+</li>
+<li>
+<p>content-height</p>
+</li>
+<li>
+<p>content-type</p>
+</li>
+<li>
+<p>content-width</p>
+</li>
+<li>
+<p>display-align</p>
+</li>
+<li>
+<p>height</p>
+</li>
+<li>
+<p>id</p>
+</li>
+<li>
+<p>inline-progression-dimension</p>
+</li>
+<li>
+<p>overflow</p>
+</li>
+<li>
+<p>pages: <page-set> (see below) (not implemented, yet)</p>
+</li>
+<li>
+<p>reference-orientation</p>
+</li>
+<li>
+<p>scaling</p>
+</li>
+<li>
+<p>scaling-method</p>
+</li>
+<li>
+<p>src</p>
+</li>
+<li>
+<p>text-align</p>
+</li>
+<li>
+<p>width</p>
+</li>
+</ul>
+<p>Datatype "page-set": Value: auto | <integer-range>, Default: "auto" which means all pages/subimages of the document. <integer-range> allows values such as "7" or "1-3"
+ <code>fox:external-document</code> is not suitable for concatenating FO documents. For this, XInclude is recommended.</p>
+<h2 id="transform">Free-form Transformation for fo:block-container</h2>
+<p>For <code>fo:block-container</code> elements whose <code>absolute-position</code> set to "absolute" or "fixed" you can use the extension attribute <code>fox:transform</code> to apply a free-form transformation to the whole block-container. The content of the <code>fox:transform</code> attribute is the same as for <a href="http://www.w3.org/TR/SVG/coords.html#TransformAttribute">SVG's transform attribute</a> . The transformation specified here is performed in addition to other implicit transformations of the block-container (resulting from top, left and other properties) and after them.</p>
+<p>Examples: <code>fox:transform="rotate(45)"</code> would rotate the block-container by 45 degrees clock-wise around its upper-left corner. <code>fox:transform="translate(10000,0)"</code> would move the block-container to the right by 10 points (=10000 millipoints, FOP uses millipoints internally!).
+This extension attribute doesn't work for all output formats! It's currently only supported for PDF, PS and Java2D-based renderers.</p>
+<h2 id="color-functions">Color functions</h2>
+<p>XSL-FO supports specifying color using the rgb(), rgb-icc() and system-color() functions. Apache FOP provides additional color functions for special use cases. Please note that using these functions compromises the interoperability of an FO document.</p>
+<h3 id="color-function-cmyk">cmyk()</h3>
+<p><code>color cmyk(numeric, numeric, numeric, numeric)</code> </p>
+<p>This function will construct a color in device-specific CMYK color space. The numbers must be between 0.0 and 1.0. For output formats that don't support device-specific color space the CMYK value is converted to an sRGB value.</p>
+<h3 id="pseudo-color-profiles">#CMYK pseudo-profile</h3>
+<p><code>color rgb-icc(numeric, numeric, numeric, #CMYK, numeric, numeric, numeric, numeric)</code> </p>
+<p>The <code>rgb-icc</code> function will respond to a pseudo-profile called "#CMYK" which indicates a device-specific CMYK color space. The "#CMYK" profile is implicitely available and doesn't have to be (and cannot be) defined through an <code>fo:color-profile</code> element. It is provided for compatibility with certain commercial XSL-FO implementations. Please note that this is not part of the official specification but rather a convention. The following two color specifications are equivalent:</p>
+<ul>
+<li>
+<p><code>cmyk(0%,0%,20%,40%)</code> </p>
+</li>
+<li>
+<p><code>rgb-icc(153, 153, 102, #CMYK, 0, 0, 0.2, 0.4)</code> </p>
+</li>
+</ul>
+<h2 id="prepress">Prepress Support</h2>
+<p>This section defines a number of extensions related to <a href="http://en.wikipedia.org/wiki/Prepress">prepress</a> support. <code>fox:scale</code> defines a general scale factor for the generated pages. <code>fox:bleed</code> defines the <a href="http://en.wikipedia.org/wiki/Bleed_%28printing%29">bleed area</a> for a page. <code>fox:crop-offset</code> defines the outer edges of the area in which crop marks, registration marks, color bars and page information are placed. For details, please read on below.
+Those extensions have been implemented in the PDF and Java2D renderers only.</p>
+<h3 id="scale">fox:scale</h3>
+<p>Value: <number>{1,2}</p>
+<p>Initial: 1</p>
+<p>Applies to: fo:simple-page-master</p>
+<p>This property specifies a scale factor along resp. the x and y axes. If only one number is provided it is used for both the x and y scales. A scale factor smaller than 1 shrinks the page. A scale factor greater than 1 enlarges the page.</p>
+<h3 id="bleed">fox:bleed</h3>
+<p>Value: <length>{1,4}</p>
+<p>Initial: 0pt</p>
+<p>Applies to: fo:simple-page-master</p>
+<p>If there is only one value, it applies to all sides. If there are two values, the top and bottom bleed widths are set to the first value and the right and left bleed widths are set to the second. If there are three values, the top is set to the first value, the left and right are set to the second, and the bottom is set to the third. If there are four values, they apply to the top, right, bottom, and left, respectively. (Corresponds to <a href="http://www.w3.org/TR/xsl11/#padding">the definition of padding</a> ).</p>
+<p>This extension indirectly defines the BleedBox and is calculated by expanding the TrimBox by the bleed widths. The lengths must be non-negative.</p>
+<h3 id="cropOffset">fox:crop-offset</h3>
+<p>Value: <length>{1,4}</p>
+<p>Initial: bleed (see below)</p>
+<p>Applies to: fo:simple-page-master</p>
+<p>Same behaviour as with fox:bleed. The initial value is set to the same values as the fox:bleed property.</p>
+<p>This extension indirectly defines the MediaBox and is calculated by expanding the TrimBox by the crop offsets. The lengths must be non-negative.</p>
+<h3 id="cropBox">fox:crop-box</h3>
+<p>Value: [trim-box | bleed-box | media-box]</p>
+<p>Initial: media-box</p>
+<p>Applies to: fo:simple-page-master</p>
+<p>The crop box controls how Acrobat displays the page (CropBox in PDF) or how the Java2DRenderer sizes the output media. The PDF specification defines that the CropBox defaults to the MediaBox. This extension follows that definition. To simplify usage and cover most use cases, the three supported enumeration values "trim-box", "bleed-box" and "media-box" set the CropBox to one of those three other boxes.</p>
+<p>If requested in the future, we could offer to specify the CropBox in absolute coordinates rather than just by referencing another box.</p></div></div>
+      <div class="clear"></div>
+
+	  <div id="footer">
+		<a alt="Apache Software Foundation" href="http://www.apache.org">
+		  <img id="asf-logo" alt="Apache Software Foundation" src="/images/feather-small.gif"/ width="100">
+		</a>
+		<div class="copyright">
+		  <p>
+			Copyright &copy; 2011 The Apache Software Foundation, Licensed under
+			the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.
+			<br />
+			Apache, Apache XML Graphics, the Apache feather logo, and the Apache XML Graphics logos are
+			trademarks of <a href="http://www.apache.org">The Apache Software Foundation</a>. All other
+			marks mentioned may be trademarks or registered trademarks of their respective owners.
+			<br />
+		  </p>
+		</div> 
+	  </div>
+  </body>
+</html>

Added: websites/staging/xmlgraphics/trunk/content/fop/trunk/fonts.html
==============================================================================
--- websites/staging/xmlgraphics/trunk/content/fop/trunk/fonts.html (added)
+++ websites/staging/xmlgraphics/trunk/content/fop/trunk/fonts.html Sun Apr 15 05:39:50 2012
@@ -0,0 +1,473 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html lang="en">
+  <head>
+    <title>Apache™ FOP: Fonts</title>
+
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+    <meta property="og:image" content="http://www.apache.org/images/asf_logo.gif" />
+<!--
+    <link rel="stylesheet" type="text/css" media="screen" href="http://www.apache.org/css/style.css">
+    <link rel="stylesheet" type="text/css" media="screen" href="http://www.apache.org/css/code.css">
+-->
+    <link href="/css/xmlgraphics.css" rel="stylesheet" type="text/css">
+
+    </style>
+
+    
+
+    
+    
+  </head>
+
+  <body>
+	  <div id="banner">&nbsp;
+	  </div>
+
+	  <div id="navigation">
+	  <h1 id="xml-graphics">XML Graphics</h1>
+<ul>
+<li><a href="/">Overview</a></li>
+<li><a href="/team.html">Who We Are</a></li>
+<li><a href="/legal.html">Legal Stuff</a></li>
+<li><a href="/charter.html">Project Charter</a></li>
+<li><a href="/mail.html">Mailing Lists</a></li>
+<li><a href="/repo.html">Code Repositories</a></li>
+<li><a href="http://www.apache.org/foundation/sponsorship.html">ASF Sponsorship Program</a></li>
+<li><a href="http://www.apache.org/foundation/thanks.html">ASF Thanks</a></li>
+</ul>
+<h1 id="subprojects">Subprojects</h1>
+<ul>
+<li><a href="/batik/">Batik</a></li>
+<li><a href="/fop/">FOP</a></li>
+<li><a href="/commons/">Commons</a></li>
+</ul>
+<form name="search" id="search" action="http://www.google.com/search" method="get">
+  <input value="xmlgraphics.apache.org" name="sitesearch" type="hidden"/>
+  <input type="text" name="q" id="query" /><br />
+  <input type="submit" id="submit" value="Search" />
+</form>
+	  </div>
+	
+	  <div id="bannertext">
+        <a href="/"><img src="/images/apache-xml-graphics.gif" alt="The Apache XML Graphics Project" width="220" heigh="51" /></a>
+        <h1>Apache™ FOP: Fonts</h1>
+      </div>
+        <p><a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/fop/">Fop</a>&nbsp;&raquo&nbsp;<a href="/fop/trunk/">Trunk</a></p>
+      </div>
+      <div id="content" class="grid_16"><div class="section-content"><p><version>$Revision: 1298724 $</version><authors><person email="" name="Jeremias Märki"></person><person email="" name="Tore Engvig"></person><person email="" name="Adrian Cumiskey"></person><person email="" name="Max Berger"></person></authors></p>
+<h1 id="intro">Summary</h1>
+<p>The following table summarizes the font capabilities of the various Apache� FOP renderers:</p>
+<table>
+<thead>
+<tr>
+<th>Renderer</th>
+<th>Base-14</th>
+<th>AWT/OS</th>
+<th>Custom</th>
+<th>Custom Embedding</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>PDF</td>
+<td>yes</td>
+<td>no</td>
+<td>yes</td>
+<td>yes</td>
+</tr>
+<tr>
+<td>PostScript</td>
+<td>yes</td>
+<td>no</td>
+<td>yes</td>
+<td>yes</td>
+</tr>
+<tr>
+<td>PCL</td>
+<td>yes (modified)</td>
+<td>yes (painted as bitmaps)</td>
+<td>yes (painted as bitmaps)</td>
+<td>no</td>
+</tr>
+<tr>
+<td>AFP</td>
+<td>no</td>
+<td>no</td>
+<td>yes</td>
+<td>yes</td>
+</tr>
+<tr>
+<td>Java2D/AWT/Bitmap</td>
+<td>if available from OS</td>
+<td>yes</td>
+<td>yes</td>
+<td>n/a (display only)</td>
+</tr>
+<tr>
+<td>Print</td>
+<td>if available from OS</td>
+<td>yes</td>
+<td>yes</td>
+<td>controlled by OS printer driver</td>
+</tr>
+<tr>
+<td>RTF</td>
+<td>n/a (font metrics not needed)</td>
+<td>n/a</td>
+<td>n/a</td>
+<td>n/a</td>
+</tr>
+<tr>
+<td>TXT</td>
+<td>yes (used for layout but not for output)</td>
+<td>no</td>
+<td>yes (used for layout but not for output)</td>
+<td>no</td>
+</tr>
+<tr>
+<td>XML</td>
+<td>yes</td>
+<td>no</td>
+<td>yes</td>
+<td>n/a</td>
+</tr>
+</tbody>
+</table>
+<h1 id="base-14-fonts-base-14fonts">Base-14 Fonts # {#Base-14+Fonts}</h1>
+<p>The Adobe PostScript and PDF Specification specify a set of 14 fonts that must be available to every PostScript interpreter and PDF reader: Helvetica (normal, bold, italic, bold italic), Times (normal, bold, italic, bold italic), Courier (normal, bold, italic, bold italic), Symbol and ZapfDingbats.</p>
+<p>The following font family names are hard-coded into FOP for the Base-14 font set:</p>
+<table>
+<thead>
+<tr>
+<th>Base-14 font</th>
+<th>font families</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>Helvetica</td>
+<td>Helvetica, sans-serif, SansSerif</td>
+</tr>
+<tr>
+<td>Times</td>
+<td>Times, Times Roman, Times-Roman, serif, any</td>
+</tr>
+<tr>
+<td>Courier</td>
+<td>Courier, monospace, Monospaced</td>
+</tr>
+<tr>
+<td>Symbol</td>
+<td>Symbol</td>
+</tr>
+<tr>
+<td>ZapfDingbats</td>
+<td>ZapfDingbats</td>
+</tr>
+</tbody>
+</table>
+<p>Please note that recent versions of Adobe Acrobat Reader replace "Helvetica" with "Arial" and "Times" with "Times New Roman" internally. GhostScript replaces "Helvetica" with "Nimbus Sans L" and "Times" with "Nimbus Roman No9 L". Other document viewers may do similar font substitutions. If you need to make sure that there are no such substitutions, you need to specify an explicit font and embed it in the target document.</p>
+<h1 id="missing-fonts">Missing Fonts</h1>
+<p>When FOP does not have a specific font at its disposal (because it's not installed in the operating system or set up in FOP's configuration), the font is replaced with "any". "any" is internally mapped to the Base-14 font "Times" (see above).</p>
+<h1 id="missing-glyphs">Missing Glyphs</h1>
+<p>Every font contains a particular set of <a href="http://en.wikipedia.org/wiki/Glyph">glyphs</a> . If no glyph can be found for a given character, FOP will issue a warning and use the glpyh for "#" (if available) instead. Before it does that, it consults a (currently hard-coded) registry of glyph substitution groups (see Glyphs.java in Apache XML Graphics Commons). This registry can supply alternative glyphs in some cases (like using space when a no-break space is requested). But there's no guarantee that the result will be as expected (for example, in the case of hyphens and similar glyphs). A better way is to use a font that has all the necessary glyphs. This glyph substitution is only a last resort.</p>
+<h1 id="awt">Java2D/AWT/Operating System Fonts</h1>
+<p>The Java2D family of renderers (Java2D, AWT, Print, TIFF, PNG), use the Java AWT subsystem for font metric information. Through operating system registration, the AWT subsystem knows what fonts are available on the system, and the font metrics for each one.</p>
+<p>When working with one of these output formats and you're missing a font, just install it in your operating system and they should be available for these renderers. Please note that this is not true for other output formats such as PDF or PostScript.</p>
+<h1 id="custom">Custom Fonts</h1>
+<p>Support for custom fonts is highly output format dependent (see above table). This section shows how to add Type 1 and TrueType fonts to the PDF, PostScript and Java2D-based renderers. Other renderers (like AFP) support other font formats. Details in this case can be found on the page about <a href="output.html">output formats</a> .</p>
+<p>In earlier FOP versions, it was always necessary to create an XML font metrics file 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 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:</p>
+<ul>
+<li>
+<p><a href="http://partners.adobe.com/asn/developer/type/ftypes.html">Adobe font types</a> </p>
+</li>
+<li>
+<p><a href="http://partners.adobe.com/asn/developer/technotes/fonts.html">Adobe Font Technote</a> </p>
+</li>
+</ul>
+<h1 id="basics">Basic font configuration</h1>
+<p>If you want FOP to use custom fonts, you need to tell it where to find them. This is done in the configuration file and once per renderer (because each output format is a little different). In the basic form, you can either tell FOP to find your operating system fonts or you can specify directories that it will search for support fonts. These fonts will then automatically be registered.</p>
+<p><renderers>
+   <renderer mime="application/pdf">
+      <fonts>
+         <!-- register all the fonts found in a directory -->
+         <directory>C:\MyFonts1</directory></p>
+<div class="codehilite"><pre>     <span class="c">&lt;!-- register all the fonts found in a directory and all of its sub directories (use with care) --&gt;</span>
+     <span class="nt">&lt;directory</span> <span class="na">recursive=</span><span class="s">&quot;true&quot;</span><span class="nt">&gt;</span>C:\MyFonts2<span class="nt">&lt;/directory&gt;</span>
+
+     <span class="c">&lt;!-- automatically detect operating system installed fonts --&gt;</span>
+     <span class="nt">&lt;auto-detect/&gt;</span>  
+  <span class="nt">&lt;/fonts&gt;</span>
+</pre></div>
+
+
+<p></renderer>
+</renderers>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. It is currently not possible to easily configure fonts from Java code.</p>
+<h1 id="advanced">Advanced font configuration</h1>
+<p>The instructions found above should be sufficient for most users. Below are some additional instructions in case the basic font configuration doesn't lead to the desired results.</p>
+<h2 id="type1-metrics">Type 1 Font Metrics</h2>
+<p>FOP includes PFMReader, which reads the PFM file that normally comes with a Type 1 font, and generates an appropriate font metrics file for it. To use it, run the class org.apache.fop.fonts.apps.PFMReader:</p>
+<p>Windows:
+java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar
+          org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file
+Unix:
+java -cp build/fop.jar:lib/avalon-framework.jar:lib/commons-logging.jar:lib/commons-io.jar
+          org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file
+PFMReader [options]:</p>
+<ul>
+<li><strong>-fn <fontname></strong> By default, FOP uses the fontname from the .pfm file when embedding the font. Use the "-fn" option to override this name with one you have chosen. This may be useful in some cases to ensure that applications using the output document (Acrobat Reader for example) use the embedded font instead of a local font with the same name.
+The classpath in the above example has been simplified for readability. You will have to adjust the classpath to the names of the actual JAR files in the lib directory. xml-apis.jar, xercesImpl.jar, xalan.jar and serializer.jar are not necessary for JDK version 1.4 or later.The tool will construct some values (FontBBox, StemV and ItalicAngle) based on assumptions and calculations which are only an approximation to the real values. FontBBox and Italic Angle can be found in the human-readable part of the PFB file or in the AFM file. The PFMReader tool does not yet interpret PFB or AFM files, so if you want to be correct, you may have to adjust the values in the XML file manually. The constructed values however appear to have no visible influence.</li>
+</ul>
+<h2 id="truetype-metrics">TrueType Font Metrics</h2>
+<p>FOP includes TTFReader, which reads the TTF file and generates an appropriate font metrics file for it. Use it in a similar manner to PFMReader. For example, to create such a metrics file in Windows from the TrueType font at c:\myfonts\cmr10.ttf:
+java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar
+          org.apache.fop.fonts.apps.TTFReader [options]
+          C:\myfonts\cmr10.ttf ttfcm.xml
+TTFReader [options]:</p>
+<ul>
+<li>
+<p><strong>-d <DEBUG | INFO ></strong> Sets the debug level (default is INFO).</p>
+</li>
+<li>
+<p><strong>-fn <fontname></strong> Same as for PFMReader.</p>
+</li>
+<li>
+<p><strong>-ttcname <fontname></strong> If you're reading data from a TrueType Collection (.ttc file) you must specify which font from the collection you will read metrics from. If you read from a .ttc file without this option, the fontnames will be listed for you.</p>
+</li>
+<li>
+<p><strong>-enc ansi</strong> Creates a WinAnsi-encoded font metrics file. Without this option, a CID-keyed font metrics file is created. The table below summarizes the differences between these two encoding options as currently used within FOP. Please note that this information only applies to TrueType fonts and TrueType collections:</p>
+</li>
+</ul>
+<table>
+<thead>
+<tr>
+<th>Issue</th>
+<th>WinAnsi</th>
+<th>CID-keyed</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>Usable Character Set</td>
+<td>Limited to WinAnsi character set, which is roughly equivalent to iso-8889-1.</td>
+<td>Limited only by the characters in the font itself.</td>
+</tr>
+<tr>
+<td>Embedding the Font</td>
+<td>Optional.</td>
+<td>Mandatory. Not embedding the font produces invalid PDF documents.</td>
+</tr>
+<tr>
+<td><warning>You may experience failures with certain TrueType fonts, especially if they don't contain the so-called Unicode "cmap" table. TTFReader can currently not deal with font like this.</warning></td>
+<td></td>
+<td></td>
+</tr>
+<tr>
+<td id="truetype-collections-metrics">## TrueType Collections</td>
+<td></td>
+<td></td>
+</tr>
+</tbody>
+</table>
+<p>TrueType collections (.ttc files) contain more than one font. To create metrics files for these fonts, you must specify which font in the collection should be generated, by using the "-ttcname" option with the TTFReader.</p>
+<p>To get a list of the fonts in a collection, just start the TTFReader as if it were a normal TrueType file (without the -ttcname option). It will display all of the font names and exit with an Exception.</p>
+<p>Here is an example of generating a metrics file for a .ttc file:
+java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar
+          org.apache.fop.fonts.apps.TTFReader -ttcname "MS Mincho"
+          msmincho.ttc msminch.xml
+Alternatively, the individual sub-fonts of a TrueType Collections can be selected using the "sub-font" attribute on the "font" element. That means that generating an XML font metrics file for TrueType collections is not necessary anymore. Example:
+<font embed-url="gulim.ttc" sub-font="GulimChe">
+  <font-triplet name="GulimChe" style="normal" weight="normal"/>
+</font></p>
+<h2 id="register">Register Fonts with FOP</h2>
+<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>
+<p><renderers>
+   <renderer mime="application/pdf">
+      <fonts>
+         <!-- register a particular font -->
+         <font metrics-url="file:///C:/myfonts/FTL_____.xml" kerning="yes"
+           embed-url="file:///C:/myfonts/FTL_____.pfb"
+           encoding-mode="single-byte">
+            <font-triplet name="FrutigerLight" style="normal" weight="normal"/>
+         </font></p>
+<div class="codehilite"><pre>     <span class="c">&lt;!-- register all the fonts found in a directory --&gt;</span>
+     <span class="nt">&lt;directory&gt;</span>C:\MyFonts1<span class="nt">&lt;/directory&gt;</span>
+
+     <span class="c">&lt;!-- register all the fonts found in a directory and all of its sub directories (use with care) --&gt;</span>
+     <span class="nt">&lt;directory</span> <span class="na">recursive=</span><span class="s">&quot;true&quot;</span><span class="nt">&gt;</span>C:\MyFonts2<span class="nt">&lt;/directory&gt;</span>
+
+     <span class="c">&lt;!-- automatically detect operating system installed fonts --&gt;</span>
+     <span class="nt">&lt;auto-detect/&gt;</span>  
+  <span class="nt">&lt;/fonts&gt;</span>
+</pre></div>
+
+
+<p></renderer>
+</renderers></p>
+<ul>
+<li>
+<p>URLs are used to access the font metric and font files. 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.</p>
+</li>
+<li>
+<p>The "metrics-url" attribute is generally not necessary except if you run into problems with certain fonts.</p>
+</li>
+<li>
+<p>Either an "embed-url" or a "metrics-url" must be specified for font tag configurations.</p>
+</li>
+<li>
+<p>The font "kerning" attribute is optional. Default is "true".</p>
+</li>
+<li>
+<p>If embedding is off (i.e. embed-url is not set), 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.</p>
+</li>
+<li>
+<p>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.</p>
+</li>
+<li>
+<p>The attribute "encoding-mode" is optional an may have the following values:</p>
+<ul>
+<li>
+<p>auto: default font encoding mode ("cid" for Truetype, "single-byte" for Type 1)</p>
+</li>
+<li>
+<p>single-byte: use single-byte encodings in the target format (if applicable)</p>
+</li>
+<li>
+<p>cid: encode as CID-keyed font (currently only supported for PDF output with TrueType fonts)</p>
+</li>
+</ul>
+</li>
+<li>
+<p>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.</p>
+</li>
+<li>
+<p>The fonts "auto-detect" tag can be used to automatically register fonts that are found to be installed on the native operating system.</p>
+</li>
+<li>
+<p>Fonts registered with "font" tag configurations override fonts found by means of "directory" tag definitions.</p>
+</li>
+<li>
+<p>Fonts found as a result of a "directory" tag configuration override fonts found as a result of the "auto-detect" tag being specified.</p>
+</li>
+<li>
+<p>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 relative to the base directory.</p>
+</li>
+</ul>
+<h2 id="autodetect">Auto-Detect and auto-embed feature</h2>
+<p>When the "auto-detect" flag is set in the configuration, FOP will automatically search for fonts in the default paths for your operating system.</p>
+<p>FOP will also auto-detect fonts which are available in the classpath, if they are described as "application/x-font" in the MANIFEST.MF file. For example, if your .jar file contains font/myfont.ttf:
+Manifest-Version: 1.0</p>
+<div class="codehilite"><pre>      <span class="n">Name:</span> <span class="n">font</span><span class="o">/</span><span class="n">myfont</span><span class="o">.</span><span class="n">ttf</span>
+      <span class="n">Content</span><span class="o">-</span><span class="n">Type:</span> <span class="n">application</span><span class="o">/</span><span class="n">x</span><span class="o">-</span><span class="n">font</span>
+</pre></div>
+
+
+<p>This feature allows you to create JAR files containing fonts. The JAR files can be added to fop by providem them in the classpath, e.g. copying them into the lib/ directory.</p>
+<h3 id="font-cache">The font cache</h3>
+<p>Apache FOP maintains a cache file that is used to speed up auto-detection. This file is usually found in the ".fop" directory under the user's home directory. It's called "fop-fonts.cache". When the user's home directory is not writable, the font cache file is put in the directory for temporary files.</p>
+<p>If there was a problem loading a particular font, it is flagged in the cache file so it is not loaded anymore. So, if a font is actually around but is still not found by Apache FOP, it's worth a try to delete the font cache file which forces Apache FOP to reparse all fonts.</p>
+<h2 id="embedding">Embedding</h2>
+<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>
+<p>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.</p>
+</li>
+<li>
+<p>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:</p>
+</li>
+</ol>
+<p><fop version="1.0">
+   <fonts>
+      <referenced-fonts>
+        <match font-family="Helvetica"/>
+        <match font-family="DejaVu.*"/>
+      </referenced-fonts>
+   </fonts>
+</fop>
+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">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>The <code>referenced-fonts</code> element can be placed either inside the general <code>fonts</code> element (right under the root) or in the <code>fonts</code> element under the renderer configuration. In the first case, matches apply to all renderers. In the second case, matches only apply to the renderer where the element was specified. Both cases can be used at the same time.</p>
+<p>Various notes related to embedded fonts:</p>
+<ul>
+<li>
+<p>The PostScript renderer does not yet support TrueType fonts, but can embed Type 1 fonts.</p>
+</li>
+<li>
+<p>The font is simply embedded into the PDF file, it is not converted.</p>
+</li>
+<li>
+<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>
+</li>
+<li>
+<p>When embedding PostScript fonts, the entire font is always embedded.</p>
+</li>
+<li>
+<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. That's the default, but if you specify encoding-mode="single-byte" (see above), the complete font is embedded.</p>
+</li>
+</ul>
+<h2 id="substitution">Substitution</h2>
+<p>When a <substitutions/> section is defined in the configuration, FOP will re-map any font-family references found in your FO input to a given substitution font.</p>
+<ul>
+<li>
+<p>If a <substitution/> is declared, it is mandatory that both a <from/> and <to/> child element is declared with a font-family attribute.</p>
+</li>
+<li>
+<p>Both font-weight and font-style are optional attributes, if they are provided then a value of 'normal' is assumed.</p>
+</li>
+</ul>
+<p>For example you could make all FO font-family references to 'Arial' with weights between 700 and 900 reference the normal 'Arial Black' font.</p>
+<p><fop version="1.0">
+   <fonts>
+      <substitutions>
+         <substitution>
+            <from font-family="Arial" font-weight="700..900"/>
+            <to font-family="Arial Black"/>
+         </substitution>
+         <substitution>
+            <from font-family="FrutigerLight"/>
+            <to font-family="Times" font-weight="bold" font-style="italic"/>
+         </substitution>
+      </substitutions>
+   </fonts>
+</fop></p>
+<h1 id="selection">Font Selection Strategies</h1>
+<p>There are two font selection strategies: character-by-character or auto. The default is auto.</p>
+<p>Auto selected the first font from the list which is able to display the most characters in a given word. This means (assume font A has characters for abclmn, font B for lnmxyz, fontlist is A,B):</p>
+<ul>
+<li>
+<p>aaa lll xxx would be displayed in fonts A A B</p>
+</li>
+<li>
+<p>aaaxx would be displayed in font A</p>
+</li>
+<li>
+<p>aaaxxx would be displayed in font A</p>
+</li>
+<li>
+<p>aaaxxxx would be displayed in font B</p>
+</li>
+</ul>
+<p>Character-by-Character is NOT yet supported!</p>
+<h1 id="font-list">Font List Command-Line Tool</h1>
+<p>FOP contains a small command-line tool that lets you generate a list of all configured fonts. Its class name is: <code>org.apache.fop.tools.fontlist.FontListMain</code> . Run it with the "-?" parameter to get help for the various options.</p></div></div>
+      <div class="clear"></div>
+
+	  <div id="footer">
+		<a alt="Apache Software Foundation" href="http://www.apache.org">
+		  <img id="asf-logo" alt="Apache Software Foundation" src="/images/feather-small.gif"/ width="100">
+		</a>
+		<div class="copyright">
+		  <p>
+			Copyright &copy; 2011 The Apache Software Foundation, Licensed under
+			the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.
+			<br />
+			Apache, Apache XML Graphics, the Apache feather logo, and the Apache XML Graphics logos are
+			trademarks of <a href="http://www.apache.org">The Apache Software Foundation</a>. All other
+			marks mentioned may be trademarks or registered trademarks of their respective owners.
+			<br />
+		  </p>
+		</div> 
+	  </div>
+  </body>
+</html>



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