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 ma...@apache.org on 2006/04/27 17:08:24 UTC

svn commit: r397562 [2/6] - in /xmlgraphics/fop/trunk/src/sandbox: META-INF/services/ org/apache/fop/render/afp/ org/apache/fop/render/afp/apps/ org/apache/fop/render/afp/exceptions/ org/apache/fop/render/afp/extensions/ org/apache/fop/render/afp/fonts...

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.exceptions;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * Handy class for wrapping runtime Exceptions with a root cause.
+ * This technique is no longer necessary in Java 1.4, which provides
+ * built-in support for exception nesting. Thus exceptions in applications
+ * written to use Java 1.4 need not extend this class.
+ *
+ */
+public abstract class NestedRuntimeException extends RuntimeException {
+
+	/** Root cause of this nested exception */
+	private Throwable _underlyingException;
+
+	/**
+	 * Construct a <code>NestedRuntimeException</code> with the specified detail message.
+	 * @param msg The detail message.
+	 */
+	public NestedRuntimeException(String msg) {
+		super(msg);
+	}
+
+	/**
+	 * Construct a <code>NestedRuntimeException</code> with the specified
+	 * detail message and nested exception.
+	 * @param msg The detail message.
+	 * @param t The nested exception.
+	 */
+	public NestedRuntimeException(String msg, Throwable t) {
+		super(msg);
+		_underlyingException = t;
+
+	}
+
+	/**
+	 * Gets the original triggering exception
+	 * @return The original exception as a throwable.
+	 */
+	public Throwable getUnderlyingException() {
+
+		return _underlyingException;
+
+	}
+
+	/**
+	 * Return the detail message, including the message from the nested
+	 * exception if there is one.
+	 * @return The detail message.
+	 */
+	public String getMessage() {
+
+		if (_underlyingException == null) {
+			return super.getMessage();
+		} else {
+			return super.getMessage()
+				+ "; nested exception is "
+				+ _underlyingException.getClass().getName();
+		}
+
+	}
+
+	/**
+	 * Print the composite message and the embedded stack trace to the specified stream.
+	 * @param ps the print stream
+	 */
+	public void printStackTrace(PrintStream ps) {
+		if (_underlyingException == null) {
+			super.printStackTrace(ps);
+		} else {
+			ps.println(this);
+			_underlyingException.printStackTrace(ps);
+		}
+	}
+
+	/**
+	 * Print the composite message and the embedded stack trace to the specified writer.
+	 * @param pw the print writer
+	 */
+	public void printStackTrace(PrintWriter pw) {
+		if (_underlyingException == null) {
+			super.printStackTrace(pw);
+		} else {
+			pw.println(this);
+			_underlyingException.printStackTrace(pw);
+		}
+	}
+
+}

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/exceptions/NestedRuntimeException.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.exceptions;
+
+/**
+ * A runtime exception for handling fatal errors in rendering.
+ * <p/>
+ */
+public class RendererRuntimeException extends NestedRuntimeException {
+
+	/**
+	 * Constructs a RendererRuntimeException with the specified message.
+	 * @param msg the exception mesaage
+	 */
+	public RendererRuntimeException(String msg) {
+		super(msg);
+	}
+
+	/**
+	 * Constructs a RendererRuntimeException with the specified message
+	 * wrapping the underlying exception.
+	 * @param msg the exception mesaage
+	 * @param t the underlying exception
+	 */
+	public RendererRuntimeException(String msg, Throwable t) {
+		super(msg, t);
+	}
+
+}

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/exceptions/RendererRuntimeException.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPAttribute.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPAttribute.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPAttribute.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPAttribute.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.extensions;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.properties.Property;
+import org.apache.fop.fo.properties.StringProperty;
+
+/**
+ * This class extends the org.apache.fop.fo.StringProperty.Maker inner class
+ * in order to provide a static property maker. The object faciliates
+ * extraction of attributes from formatted objects based on the static list
+ * as defined in the AFPElementMapping implementation.
+ * <p/>
+ */
+public class AFPAttribute extends StringProperty.Maker {
+
+    /**
+     * The attribute property.
+     */
+    private Property _property;
+
+    /**
+     * Constructor for the AFPAttribute.
+     * @param name The attribute name
+     */
+    protected AFPAttribute(String name) {
+        super(0);
+        _property = null;
+    }
+
+    /**
+     * Overide the make method to return the property object
+     * @return property The property object.
+     */
+    public Property make(PropertyList propertyList) {
+        if (_property == null) {
+            _property = make(propertyList, "", propertyList.getParentFObj());
+        }
+        return _property;
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPAttribute.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPAttribute.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPElementMapping.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPElementMapping.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPElementMapping.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPElementMapping.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.extensions;
+
+import java.util.HashMap;
+
+import org.apache.fop.fo.ElementMapping;
+import org.apache.fop.fo.FONode;
+
+
+/**
+ * AFPElementMapping object provides the ability to extract information
+ * from the formatted object that reside in the afp namespace. This is used
+ * for custom AFP extensions not supported by the FO schema. Examples include
+ * adding overlays or indexing a document using the tag logical element
+ * structured field.
+ * <p/>
+ */
+public class AFPElementMapping extends ElementMapping {
+
+    public static final String PAGE = "page";
+
+    public static final String PAGE_GROUP = "page-group";
+
+    public static final String TAG_LOGICAL_ELEMENT = "tag-logical-element";
+
+    public static final String INCLUDE_PAGE_OVERLAY = "include-page-overlay";
+
+    public static final String INCLUDE_PAGE_SEGMENT = "include-page-segment";
+
+    /**
+     * The namespace used for AFP extensions
+     */
+    public static final String NAMESPACE = "http://org.apache.fop/extensions/afp";
+
+    /**
+     * The usual namespace prefix used for AFP extensions
+     */
+    public static final String NAMESPACE_PREFIX = "afp";
+
+    /** Main constructor */
+    public AFPElementMapping() {
+        this.namespaceURI = NAMESPACE;
+    }
+
+    /**
+     * Private static synchronized method to set up the element and atribute
+     * HashMaps, this defines what elements and attributes are extracted.
+     */
+    protected void initialize() {
+
+        if (foObjs == null) {
+            foObjs = new HashMap();
+            foObjs.put(PAGE, new AFPPageSetupMaker());
+            // foObjs.put(PAGE_GROUP, new AFPMaker());
+            foObjs.put(
+                TAG_LOGICAL_ELEMENT,
+                new AFPTagLogicalElementMaker());
+            foObjs.put(
+                INCLUDE_PAGE_SEGMENT,
+                new AFPIncludePageSegmentMaker());
+            foObjs.put(
+                INCLUDE_PAGE_OVERLAY,
+                new AFPIncludePageOverlayMaker());
+        }
+
+    }
+
+    static class AFPPageSetupMaker extends ElementMapping.Maker {
+        public FONode make(FONode parent) {
+            return new AFPPageSetupElement(parent);
+        }
+    }
+
+    static class AFPIncludePageOverlayMaker extends ElementMapping.Maker {
+        public FONode make(FONode parent) {
+            return new AFPElement(parent, INCLUDE_PAGE_OVERLAY);
+        }
+    }
+
+    static class AFPIncludePageSegmentMaker extends ElementMapping.Maker {
+        public FONode make(FONode parent) {
+            return new AFPElement(parent, INCLUDE_PAGE_SEGMENT);
+        }
+    }
+
+    static class AFPTagLogicalElementMaker extends ElementMapping.Maker {
+        public FONode make(FONode parent) {
+            return new AFPElement(parent, TAG_LOGICAL_ELEMENT);
+        }
+    }
+
+}

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPElementMapping.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPElementMapping.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPElementMapping.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetup.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetup.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetup.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetup.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.extensions;
+
+import java.io.Serializable;
+
+import org.apache.fop.fo.extensions.ExtensionAttachment;
+
+/**
+ * This is the pass-through value object for the PostScript extension.
+ */
+public class AFPPageSetup implements ExtensionAttachment, Serializable {
+
+    /** The category URI for this extension attachment. */
+    public static final String CATEGORY = "apache:fop:extensions:afp";
+
+    private String elementName;
+
+    private String name;
+
+    private String value;
+
+    /**
+     * Default constructor.
+     * @param name the name of the setup code object, may be null
+     */
+    public AFPPageSetup(String name) {
+        this.elementName = name;
+    }
+
+    /** @return the name */
+    public String getElementName() {
+        return elementName;
+    }
+
+    /** @return the name */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Sets the name of the setup code object.
+     * @param name The name to set.
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * @return the value 
+     */
+    public String getValue() {
+        return value;
+    }
+
+    /**
+     * Sets the value
+     * @param value The value name to set.
+     */
+    public void setValue(String source) {
+        this.value = source;
+    }
+
+    /** @see org.apache.fop.fo.extensions.ExtensionAttachment#getCategory() */
+    public String getCategory() {
+        return CATEGORY;
+    }
+
+    /** @see java.lang.Object#toString() */
+    public String toString() {
+        return "AFPPageSetup(element-name=" + getElementName() + " name=" + getName() + ")";
+    }
+
+}

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetup.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.extensions;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.ValidationException;
+
+/**
+ * Extension element for fox:ps-page-setup-code.
+ */
+public class AFPPageSetupElement extends AbstractAFPExtensionObject {
+
+    /**
+     * Main constructor
+     * @param parent parent FO node
+     */
+    public AFPPageSetupElement(FONode parent) {
+        super(parent, "page");
+    }
+
+    /** @see org.apache.fop.fo.FONode#startOfNode() */
+    protected void startOfNode() throws FOPException {
+        super.startOfNode();
+        if (parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) {
+            throw new ValidationException(getName() + " must be a child of fo:simple-page-master.");
+        }
+    }
+
+}

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.extensions;
+
+// FOP
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fo.extensions.ExtensionAttachment;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
+/**
+ * Base class for the AFP-specific extension elements.
+ */
+public abstract class AbstractAFPExtensionObject extends FONode {
+
+    private AFPPageSetup setupCode = null;
+
+    private String _name = null;
+    
+    /**
+     * @see org.apache.fop.fo.FONode#FONode(FONode)
+     * @param parent the parent formatting object
+     * @param name the name of the afp element
+     */
+    public AbstractAFPExtensionObject(FONode parent, String name) {
+        super(parent);
+        _name = name;
+        setupCode = new AFPPageSetup(name);
+    }
+
+    /**
+     * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+     * here, blocks XSL FO's from having non-FO parents.
+     */
+    protected void validateChildNode(Locator loc, String nsURI, String localName)
+                throws ValidationException {
+        if (FO_URI.equals(nsURI)) {
+            invalidChildError(loc, nsURI, localName);
+        }
+    }
+
+    /** @see org.apache.fop.fo.FONode */
+    protected void addCharacters(char[] data, int start, int length,
+                                 PropertyList pList, Locator locator) {
+    }
+
+    /** @see org.apache.fop.fo.FONode#getNamespaceURI() */
+    public String getNamespaceURI() {
+        return AFPElementMapping.NAMESPACE;
+    }
+
+    /**@see org.apache.fop.fo.FONode#getNormalNamespacePrefix() */
+    public String getNormalNamespacePrefix() {
+        return AFPElementMapping.NAMESPACE_PREFIX;
+    }
+
+    /** @see org.apache.fop.fo.FONode#processNode */
+    public void processNode(String elementName, Locator locator,
+                            Attributes attlist, PropertyList propertyList)
+                                throws FOPException {
+        String name = attlist.getValue("name");
+        if (name != null && name.length() > 0) {
+            setupCode.setName(name);
+        } else {
+            throw new FOPException(elementName + " must have a name attribute.");
+        }
+        if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(elementName)) {
+            name = attlist.getValue("src");
+            if (name != null && name.length() > 0) {
+                setupCode.setValue(name);
+            } else {
+                throw new FOPException(elementName + " must have a src attribute.");
+            }
+        }
+        if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(elementName)) {
+            name = attlist.getValue("value");
+            if (name != null && name.length() > 0) {
+                setupCode.setValue(name);
+            } else {
+                throw new FOPException(elementName + " must have a value attribute.");
+            }
+        }
+    }
+
+    /** @see org.apache.fop.fo.FONode#endOfNode() */
+    protected void endOfNode() throws FOPException {
+        super.endOfNode();
+    }
+
+    /** @see org.apache.fop.fo.FONode#getExtensionAttachment() */
+    public ExtensionAttachment getExtensionAttachment() {
+        return this.setupCode;
+    }
+
+    /** @see org.apache.fop.fo.FONode#getLocalName() */
+    public String getLocalName() {
+        return _name;
+    }
+
+}
+

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFont.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFont.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFont.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFont.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.fonts;
+import java.util.Map;
+import org.apache.fop.fonts.FontType;
+import org.apache.fop.fonts.Typeface;
+
+
+/**
+ * All implemenations of AFP fonts should extend this base class,
+ * the object implements the FontMetrics information.
+ * <p/>
+ */
+public abstract class AFPFont extends Typeface {
+
+    /** The font name */
+    protected String _name;
+
+    /**
+     * Constructor for the base font requires the name.
+     * @param name the name of the font
+     */
+    public AFPFont(String name) {
+
+        _name = name;
+
+    }
+
+    /**
+     * @return the name of the font.
+     */
+    public String getFontName() {
+        return _name;
+    }
+
+    /**
+     * Returns the type of the font.
+     * @return the font type
+     */
+    public FontType getFontType() {
+        return FontType.OTHER;
+    }
+
+    /**
+     * Indicates if the font has kering information.
+     * @return True, if kerning is available.
+     */
+    public boolean hasKerningInfo() {
+        return false;
+    }
+
+    /**
+     * Returns the kerning map for the font.
+     * @return the kerning map
+     */
+    public Map getKerningInfo() {
+        return null;
+    }
+
+    /**
+     * Returns the character set for a given size
+     * @param size the font size
+     */
+    public abstract CharacterSet getCharacterSet(int size);
+
+     /**
+     * Determines whether this font contains a particular character/glyph.
+     * @param c character to check
+     * @return True if the character is supported, Falso otherwise
+     */
+    public boolean hasChar(char c) {
+        return true;
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFont.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFont.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFontInfo.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFontInfo.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFontInfo.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFontInfo.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.fonts;
+
+import java.util.List;
+
+/**
+ * FontInfo contains meta information on fonts
+ */
+public class AFPFontInfo {
+
+    private AFPFont font;
+    private List fontTriplets;
+
+    /**
+     * Main constructor
+     * @param afpFont The AFP Font
+     * @param fontTriplets List of font triplets to associate with this font
+     */
+    public AFPFontInfo(AFPFont afpFont, List fontTriplets) {
+        this.font = afpFont;
+        this.fontTriplets = fontTriplets;
+    }
+
+    /**
+     * Returns the afp font
+     * @return the afp font
+     */
+    public AFPFont getAFPFont() {
+        return font;
+    }
+
+    /**
+     * Returns the list of font triplets associated with this font.
+     * @return List of font triplets
+     */
+    public List getFontTriplets() {
+        return fontTriplets;
+    }
+
+}
+

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFontInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFontInfo.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFontReader.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFontReader.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFontReader.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFontReader.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,608 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.fonts;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.render.afp.exceptions.FontRuntimeException;
+import org.apache.fop.render.afp.modca.AFPConstants;
+import org.apache.fop.render.afp.tools.StructuredFieldReader;
+
+/**
+ * The AFPFontReader is responsible for reading the font attributes from binary
+ * code page files and the character set metric files. In IBM font structure, a
+ * code page maps each character of text to the characters in a character set.
+ * Each character is translated into a code point. When the character is
+ * printed, each code point is matched to a character ID on the code page
+ * specified. The character ID is then matched to the image (raster pattern or
+ * outline pattern) of the character in the character set specified. The image
+ * in the character set is the image that is printed in the document. To be a
+ * valid code page for a particular character set, all character IDs in the code
+ * page must be included in that character set. <p/>This class will read the
+ * font information from the binary code page files and character set metric
+ * files in order to determine the correct metrics to use when rendering the
+ * formatted object. <p/>
+ *
+ * @author <a href="mailto:pete@townsend.uk.com">Pete Townsend </a>
+ */
+public final class AFPFontReader {
+
+    /**
+     * Static logging instance
+     */
+    protected static final Log log = LogFactory.getLog("org.apache.fop.render.afp.fonts");
+
+    /**
+     * Template used to convert lists to arrays.
+     */
+    private static final CharacterSetOrientation[] EMPTY_CSO_ARRAY = new CharacterSetOrientation[0];
+
+    /** Codepage MO:DCA structured field. */
+    private static final byte[] CODEPAGE_SF = new byte[] { (byte) 0xD3,
+        (byte) 0xA8, (byte) 0x87 };
+
+    /** Character table MO:DCA structured field. */
+    private static final byte[] CHARACTER_TABLE_SF = new byte[] { (byte) 0xD3,
+        (byte) 0x8C, (byte) 0x87 };
+
+    /** Font control MO:DCA structured field. */
+    private static final byte[] FONT_CONTROL_SF = new byte[] { (byte) 0xD3,
+        (byte) 0xA7, (byte) 0x89 };
+
+    /** Font orientation MO:DCA structured field. */
+    private static final byte[] FONT_ORIENTATION_SF = new byte[] { (byte) 0xD3,
+        (byte) 0xAE, (byte) 0x89 };
+
+    /** Font position MO:DCA structured field. */
+    private static final byte[] FONT_POSITION_SF = new byte[] { (byte) 0xD3,
+        (byte) 0xAC, (byte) 0x89 };
+
+    /** Font index MO:DCA structured field. */
+    private static final byte[] FONT_INDEX_SF = new byte[] { (byte) 0xD3,
+        (byte) 0x8C, (byte) 0x89 };
+
+    /**
+     * The conversion factor to millipoints for 240 dpi
+     */
+    private static final int FOP_100_DPI_FACTOR = 1;
+
+    /**
+     * The conversion factor to millipoints for 240 dpi
+     */
+    private static final int FOP_240_DPI_FACTOR = 300000;
+
+    /**
+     * The conversion factor to millipoints for 300 dpi
+     */
+    private static final int FOP_300_DPI_FACTOR = 240000;
+
+    /**
+     * The encoding to use to convert from EBCIDIC to ASCII
+     */
+    private static final String ASCII_ENCODING = "UTF8";
+
+    /**
+     * The collection of code pages
+     */
+    private static HashMap _codePages = new HashMap();
+
+    /**
+     * Load the font details and metrics into the CharacterSetMetric object,
+     * this will use the actual afp code page and character set files to load
+     * the object with the necessary metrics.
+     *
+     * @param characterSet the CharacterSetMetric object to populate
+     */
+    public static void loadCharacterSetMetric(CharacterSet characterSet) {
+
+        InputStream inputStream = null;
+
+        try {
+
+            /**
+             * Get the code page which contains the character mapping
+             * information to map the unicode character id to the graphic
+             * chracter global identifier.
+             */
+            String cp = new String(characterSet.getCodePage());
+            String path = characterSet.getPath();
+
+            HashMap codepage = (HashMap) _codePages.get(cp);
+
+            if (codepage == null) {
+                codepage = loadCodePage(cp, characterSet.getEncoding(), path);
+                _codePages.put(cp, codepage);
+            }
+
+            /**
+             * Load the character set metric information, no need to cache this
+             * information as it should be cached by the objects that wish to
+             * load character set metric information.
+             */
+            final String characterset = characterSet.getName();
+
+            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+            if (classLoader == null) {
+                classLoader = AFPFontReader.class.getClassLoader();
+            }
+
+            URL url = classLoader.getResource(path);
+            if (url == null) {
+                try {
+                    File file = new File(path);
+                    url = file.toURL();
+                    if (url == null) {
+                        String msg = "CharacterSet file not found for "
+                            + characterset + " in classpath: " + path;
+                        log.error(msg);
+                        throw new FileNotFoundException(msg);
+                    }
+                } catch (MalformedURLException ex) {
+                    String msg = "CharacterSet file not found for "
+                        + characterset + " in classpath: " + path;
+                    log.error(msg);
+                    throw new FileNotFoundException(msg);
+                }
+
+            }
+
+            File directory = new File(url.getPath());
+
+            final String filterpattern = characterset.trim();
+            FilenameFilter filter = new FilenameFilter() {
+                public boolean accept(File dir, String name) {
+                    return name.startsWith(filterpattern);
+                }
+            };
+
+            File[] csfont = directory.listFiles(filter);
+            if (csfont.length < 1) {
+                String msg = "CharacterSet file search for " + characterset
+                    + " located " + csfont.length + " files";
+                log.error(msg);
+                throw new FileNotFoundException(msg);
+            } else if (csfont.length > 1) {
+                String msg = "CharacterSet file search for " + characterset
+                    + " located " + csfont.length + " files";
+                log.warn(msg);
+            }
+
+            inputStream = inputStream = csfont[0].toURL().openStream();
+            if (inputStream == null) {
+                String msg = "Failed to open character set resource "
+                    + characterset;
+                log.error(msg);
+                throw new FileNotFoundException(msg);
+            }
+
+            StructuredFieldReader sfr = new StructuredFieldReader(inputStream);
+
+            // Process D3A789 Font Control
+            FontControl fnc = processFontControl(sfr);
+
+            //process D3AE89 Font Orientation
+            CharacterSetOrientation[] csoArray = processFontOrientation(sfr);
+
+            //process D3AC89 Font Position
+            processFontPosition(sfr, csoArray, fnc.getDpi());
+
+            //process D38C89 Font Index (per orientation)
+            for (int i = 0; i < csoArray.length; i++) {
+                processFontIndex(sfr, csoArray[i], codepage, fnc.getDpi());
+                characterSet.addCharacterSetOrientation(csoArray[i]);
+            }
+
+        } catch (Exception ex) {
+            throw new FontRuntimeException(
+                "Failed to load the character set metrics for code page "
+                + characterSet.getCodePage(), ex);
+        } finally {
+            try {
+                inputStream.close();
+            } catch (Exception ex) {
+                // Ignore
+            }
+        }
+
+    }
+
+    /**
+     * Load the code page information from the appropriate file. The file name
+     * to load is determined by the code page name and the file extension 'CDP'.
+     *
+     * @param codePage
+     *            the code page identifier
+     * @param encoding
+     *            the encoding to use for the character decoding
+     */
+    private static HashMap loadCodePage(String codePage, String encoding,
+        String path) throws IOException, FileNotFoundException {
+
+        // Create the HashMap to store code page information
+        HashMap codepages = new HashMap();
+
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        if (classLoader == null) {
+            classLoader = AFPFontReader.class.getClassLoader();
+        }
+
+        URL url = classLoader.getResource(path);
+
+        if (url == null) {
+            try {
+                File file = new File(path);
+                url = file.toURL();
+                if (url == null) {
+                    String msg = "CodePage file not found for " + codePage
+                        + " in classpath: " + path;
+                    log.error(msg);
+                    throw new FileNotFoundException(msg);
+                }
+            } catch (MalformedURLException ex) {
+                String msg = "CodePage file not found for " + codePage
+                    + " in classpath: " + path;
+                log.error(msg);
+                throw new FileNotFoundException(msg);
+            }
+
+        }
+
+        File directory = new File(url.getPath());
+
+        final String filterpattern = codePage.trim();
+        FilenameFilter filter = new FilenameFilter() {
+            public boolean accept(File dir, String name) {
+                return name.startsWith(filterpattern);
+            }
+        };
+
+        File[] codepage = directory.listFiles(filter);
+
+        if (codepage.length < 1) {
+            String msg = "CodePage file search for " + codePage + " located "
+                + codepage.length + " files";
+            log.error(msg);
+            throw new FileNotFoundException(msg);
+        } else if (codepage.length > 1) {
+            String msg = "CodePage file search for " + codePage + " located "
+                + codepage.length + " files";
+            log.warn(msg);
+        }
+
+        InputStream is = codepage[0].toURL().openStream();
+
+        if (is == null) {
+            String msg = "AFPFontReader:: loadCodePage(String):: code page file not found for "
+                + codePage;
+            log.error(msg);
+            throw new FileNotFoundException(msg);
+        }
+
+        StructuredFieldReader sfr = new StructuredFieldReader(is);
+        byte[] data = sfr.getNext(CHARACTER_TABLE_SF);
+
+        int position = 0;
+        byte[] gcgiBytes = new byte[8];
+        byte[] charBytes = new byte[1];
+
+        // Read data, ignoring bytes 0 - 2
+        for (int index = 3; index < data.length; index++) {
+            if (position < 8) {
+                // Build the graphic character global identifier key
+                gcgiBytes[position] = data[index];
+                position++;
+            } else if (position == 9) {
+                position = 0;
+                // Set the character
+                charBytes[0] = data[index];
+                String gcgiString = new String(gcgiBytes,
+                    AFPConstants.EBCIDIC_ENCODING);
+                String charString = new String(charBytes, encoding);
+                int value = charString.charAt(0);
+                codepages.put(gcgiString, charString);
+            } else {
+                position++;
+            }
+        }
+
+        try {
+            is.close();
+        } catch (Exception ex) {
+            // Ignore
+        }
+
+        return codepages;
+
+    }
+
+    /**
+     * Process the font control details using the structured field reader.
+     *
+     * @param sfr
+     *            the structured field reader
+     */
+    private static FontControl processFontControl(StructuredFieldReader sfr)
+    throws IOException {
+
+        byte[] fncData = sfr.getNext(FONT_CONTROL_SF);
+
+        int position = 0;
+
+        FontControl fontControl = new AFPFontReader().new FontControl();
+
+        if (fncData[7] == (byte) 0x02) {
+            fontControl.setRelative(true);
+        }
+
+        int dpi = (((fncData[9] & 0xFF) << 8) + (fncData[10] & 0xFF)) / 10;
+
+        fontControl.setDpi(dpi);
+
+        return fontControl;
+
+    }
+
+    /**
+     * Process the font orientation details from using the structured field
+     * reader.
+     *
+     * @param sfr
+     *            the structured field reader
+     */
+    private static CharacterSetOrientation[] processFontOrientation(
+        StructuredFieldReader sfr) throws IOException {
+
+        byte[] data = sfr.getNext(FONT_ORIENTATION_SF);
+
+        int position = 0;
+        byte[] fnoData = new byte[26];
+
+        ArrayList orientations = new ArrayList();
+
+        // Read data, ignoring bytes 0 - 2
+        for (int index = 3; index < data.length; index++) {
+            // Build the font orientation record
+            fnoData[position] = data[index];
+            position++;
+
+            if (position == 26) {
+
+                position = 0;
+
+                int orientation = 0;
+
+                switch (fnoData[2]) {
+                    case 0x00:
+                        orientation = 0;
+                        break;
+                    case 0x2D:
+                        orientation = 90;
+                        break;
+                    case 0x5A:
+                        orientation = 180;
+                        break;
+                    case (byte) 0x87:
+                        orientation = 270;
+                        break;
+                    default:
+                        System.out.println("ERROR: Oriantation");
+                }
+
+                CharacterSetOrientation cso = new CharacterSetOrientation(
+                    orientation);
+                orientations.add(cso);
+
+            }
+        }
+
+        return (CharacterSetOrientation[]) orientations
+            .toArray(EMPTY_CSO_ARRAY);
+    }
+
+    /**
+     * Populate the CharacterSetOrientation object in the suplied array with the
+     * font position details using the supplied structured field reader.
+     *
+     * @param sfr
+     *            the structured field reader
+     * @param csoArray
+     *            the array of CharacterSetOrientation objects
+     */
+    private static void processFontPosition(StructuredFieldReader sfr,
+        CharacterSetOrientation[] csoArray, int dpi) throws IOException {
+
+        byte[] data = sfr.getNext(FONT_POSITION_SF);
+
+        int position = 0;
+        byte[] fpData = new byte[26];
+
+        int csoIndex = 0;
+        int fopFactor = 0;
+
+        switch (dpi) {
+            case 100:
+                fopFactor = FOP_100_DPI_FACTOR;
+                break;
+            case 240:
+                fopFactor = FOP_240_DPI_FACTOR;
+                break;
+            case 300:
+                fopFactor = FOP_300_DPI_FACTOR;
+                break;
+            default:
+                String msg = "Unsupported font resolution of " + dpi + " dpi.";
+                log.error(msg);
+                throw new IOException(msg);
+        }
+
+        // Read data, ignoring bytes 0 - 2
+        for (int index = 3; index < data.length; index++) {
+            if (position < 22) {
+                // Build the font orientation record
+                fpData[position] = data[index];
+            } else if (position == 22) {
+
+                position = 0;
+
+                CharacterSetOrientation cso = csoArray[csoIndex];
+
+                int xHeight = ((fpData[2] & 0xFF) << 8) + (fpData[3] & 0xFF);
+                int capHeight = ((fpData[4] & 0xFF) << 8) + (fpData[5] & 0xFF);
+                int ascHeight = ((fpData[6] & 0xFF) << 8) + (fpData[7] & 0xFF);
+                int dscHeight = ((fpData[8] & 0xFF) << 8) + (fpData[9] & 0xFF);
+
+                dscHeight = dscHeight * -1;
+
+                cso.setXHeight(xHeight * fopFactor);
+                cso.setCapHeight(capHeight * fopFactor);
+                cso.setAscender(ascHeight * fopFactor);
+                cso.setDescender(dscHeight * fopFactor);
+
+                csoIndex++;
+
+                fpData[position] = data[index];
+
+            }
+
+            position++;
+        }
+
+    }
+
+    /**
+     * Process the font index details for the character set orientation.
+     *
+     * @param sfr
+     *            the structured field reader
+     * @param cso
+     *            the CharacterSetOrientation object to populate
+     * @param codepage
+     *            the map of code pages
+     */
+    private static void processFontIndex(StructuredFieldReader sfr,
+        CharacterSetOrientation cso, HashMap codepage, int dpi)
+        throws IOException {
+
+        byte[] data = sfr.getNext(FONT_INDEX_SF);
+
+        int fopFactor = 0;
+
+        switch (dpi) {
+            case 100:
+                fopFactor = FOP_100_DPI_FACTOR;
+                break;
+            case 240:
+                fopFactor = FOP_240_DPI_FACTOR;
+                break;
+            case 300:
+                fopFactor = FOP_300_DPI_FACTOR;
+                break;
+            default:
+                String msg = "Unsupported font resolution of " + dpi + " dpi.";
+                log.error(msg);
+                throw new IOException(msg);
+        }
+
+        int position = 0;
+
+        byte[] gcgid = new byte[8];
+        byte[] fiData = new byte[20];
+
+        int lowest = 255;
+        int highest = 0;
+
+        // Read data, ignoring bytes 0 - 2
+        for (int index = 3; index < data.length; index++) {
+            if (position < 8) {
+                gcgid[position] = (byte) data[index];
+                position++;
+            } else if (position < 27) {
+                fiData[position - 8] = (byte) data[index];
+                position++;
+            } else if (position == 27) {
+
+                fiData[position - 8] = (byte) data[index];
+
+                position = 0;
+
+                String gcgiString = new String(gcgid, AFPConstants.EBCIDIC_ENCODING);
+
+                String idx = (String) codepage.get(gcgiString);
+
+                if (idx != null) {
+
+                    int cidx = idx.charAt(0);
+                    int width = ((fiData[0] & 0xFF) << 8) + (fiData[1] & 0xFF);
+
+                    if (cidx < lowest) {
+                        lowest = cidx;
+                    }
+
+                    if (cidx > highest) {
+                        highest = cidx;
+                    }
+
+                    int a = (width * fopFactor);
+
+                    cso.setWidth(cidx, a);
+
+                }
+
+            }
+        }
+
+        cso.setFirstChar(lowest);
+        cso.setLastChar(highest);
+
+    }
+
+    private class FontControl {
+
+        private int _dpi;
+
+        private boolean isRelative = false;
+
+        public int getDpi() {
+            return _dpi;
+        }
+
+        public void setDpi(int i) {
+            _dpi = i;
+        }
+
+        public boolean isRelative() {
+            return isRelative;
+        }
+
+        public void setRelative(boolean b) {
+            isRelative = b;
+        }
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFontReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/AFPFontReader.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSet.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSet.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSet.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSet.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,322 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.fonts;
+
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.render.afp.modca.AFPConstants;
+import org.apache.fop.render.afp.tools.StringUtils;
+
+/**
+ * The IBM Font Object Content Architecture (FOCA) supports presentation
+ * of character shapes by defining their characteristics, which include
+ * font description information for identifying the characters, font metric
+ * information for positioning the characters, and character shape information
+ * for presenting the character images.
+ * <p/>
+ * Presenting a graphic character on a presentation surface requires
+ * information on the rotation and position of character on the physical
+ * or logical page.
+ * <p/>
+ * This class proivdes font metric information for a particular font
+ * as identified by the character set name. This information is obtained
+ * directly from the AFP font files which must be installed in the path
+ * specified in the afp-fonts xml definition file.
+ * <p/>
+ */
+public class CharacterSet {
+
+    /**
+     * Static logging instance
+     */
+    protected static final Log log = LogFactory.getLog(CharacterSet.class.getName());
+
+    /**
+     * The code page to which the character set relates
+     */
+    protected String _codePage;
+
+    /**
+     * The encoding used for the code page
+     */
+    protected String _encoding;
+
+    /**
+     * The character set relating to the font
+     */
+    protected String _name;
+
+    /**
+     * The name of the character set as EBCIDIC bytes
+     */
+    private byte[] _nameBytes;
+
+    /**
+     * The path to the installed fonts
+     */
+    protected String _path;
+
+    /**
+     * Indicator as to whether to metrics have been loaded
+     */
+    private boolean _isMetricsLoaded = false;
+
+    /**
+     * The current orientation (currently only 0 is suppoted by FOP)
+     */
+    private String _currentOrientation = "0";
+
+    /**
+     * The collection of objects for each orientation
+     */
+    private HashMap _characterSetOrientations;
+
+    /**
+     * Constructor for the CharacterSetMetric object, the character set is used
+     * to load the font information from the actual AFP font.
+     * @param codePage the code page identifier
+     * @param encoding the encoding of the font
+     * @param name the character set name
+     * @param path the path to the installed afp fonts
+     */
+    public CharacterSet(
+        String codePage,
+        String encoding,
+        String name,
+        String path) {
+
+        if (name.length() > 8) {
+            String msg = "Character set name must be a maximum of 8 characters " + name;
+            log.error("Constructor:: " + msg);
+            throw new IllegalArgumentException(msg);
+        }
+
+        if (name.length() < 8) {
+            _name = StringUtils.rpad(name, ' ', 8);
+        } else {
+            _name = name;
+        }
+
+        try {
+
+            _nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
+
+        } catch (UnsupportedEncodingException usee) {
+
+            _nameBytes = name.getBytes();
+            log.warn(
+                "Constructor:: UnsupportedEncodingException translating the name "
+                + name);
+
+        }
+
+        _codePage = codePage;
+        _encoding = encoding;
+        _path = path;
+        _characterSetOrientations = new HashMap(4);
+
+    }
+
+    /**
+     * Add character set metric information for the different orientations
+     * @param cso the metrics for the orientation
+     */
+    public void addCharacterSetOrientation(CharacterSetOrientation cso) {
+
+        _characterSetOrientations.put(
+            String.valueOf(cso.getOrientation()),
+            cso);
+
+    }
+
+    /**
+     * Ascender height is the distance from the character baseline to the
+     * top of the character box. A negative ascender height signifies that
+     * all of the graphic character is below the character baseline. For
+     * a character rotation other than 0, ascender height loses its
+     * meaning when the character is lying on its side or is upside down
+     * with respect to normal viewing orientation. For the general case,
+     * Ascender Height is the character�s most positive y-axis value.
+     * For bounded character boxes, for a given character having an
+     * ascender, ascender height and baseline offset are equal.
+     * @return the ascender value in millipoints
+     */
+    public int getAscender() {
+        load();
+        return getCharacterSetOrientation().getAscender();
+    }
+
+    /**
+     * Cap height is the average height of the uppercase characters in
+     * a font. This value is specified by the designer of a font and is
+     * usually the height of the uppercase M.
+     * @return the cap height value in millipoints
+     */
+    public int getCapHeight() {
+        load();
+        return getCharacterSetOrientation().getCapHeight();
+    }
+
+    /**
+     * Descender depth is the distance from the character baseline to
+     * the bottom of a character box. A negative descender depth signifies
+     * that all of the graphic character is above the character baseline.
+     * @return the descender value in millipoints
+     */
+    public int getDescender() {
+        load();
+        return getCharacterSetOrientation().getDescender();
+    }
+
+    /**
+     * The first character in the character set
+     * @return the first character
+     */
+    public int getFirstChar() {
+        load();
+        return getCharacterSetOrientation().getFirstChar();
+    }
+
+    /**
+     * The last character in the character set
+     * @return the last character
+     */
+    public int getLastChar() {
+        load();
+        return getCharacterSetOrientation().getLastChar();
+    }
+
+    /**
+     * @return the path where the font resources are installed
+     */
+    public String getPath() {
+        return _path;
+    }
+
+    /**
+     * Get the width (in 1/1000ths of a point size) of all characters
+     * @return the widths of all characters
+     */
+    public int[] getWidths() {
+        load();
+        return getCharacterSetOrientation().getWidths();
+    }
+
+    /**
+     * XHeight refers to the height of the lower case letters above the baseline.
+     * @return the typical height of characters
+     */
+    public int getXHeight() {
+        load();
+        return getCharacterSetOrientation().getXHeight();
+    }
+
+    /**
+     * Get the width (in 1/1000ths of a point size) of the character
+     * identified by the parameter passed.
+     * @param character the character from which the width will be calculated
+     * @return the width of the character
+     */
+    public int width(int character) {
+        load();
+        return getCharacterSetOrientation().width(character);
+    }
+
+    /**
+     * Lazy creation of the character metrics, the afp font file will only
+     * be processed on a method call requiring the metric information.
+     */
+    private void load() {
+
+        if (!_isMetricsLoaded) {
+
+            AFPFontReader.loadCharacterSetMetric(this);
+            _isMetricsLoaded = true;
+
+        }
+
+    }
+
+    /**
+     * Returns the AFP character set identifier
+     * @return String
+     */
+    public String getName() {
+        return _name;
+    }
+
+    /**
+     * Returns the AFP character set identifier
+     * @return byte[]
+     */
+    public byte[] getNameBytes() {
+        return _nameBytes;
+    }
+
+    /**
+     * Returns the AFP code page identifier
+     * @return String
+     */
+    public String getCodePage() {
+        return _codePage;
+    }
+
+    /**
+     * Returns the AFP code page encoding
+     * @return String
+     */
+    public String getEncoding() {
+        return _encoding;
+    }
+
+    /**
+     * Helper method to return the current CharacterSetOrientation, note
+     * that FOP does not yet implement the "reference-orientation"
+     * attribute therefore we always use the orientation zero degrees,
+     * Other orientation information is captured for use by a future
+     * implementation (whenever FOP implement the mechanism). This is also
+     * the case for landscape prints which use an orientation of 270 degrees,
+     * in 99.9% of cases the font metrics will be the same as the 0 degrees
+     * therefore the implementation currely will always use 0 degrees.
+     * @return characterSetOrentation The current orientation metrics.
+     */
+    private CharacterSetOrientation getCharacterSetOrientation() {
+
+        CharacterSetOrientation c =
+            (CharacterSetOrientation) _characterSetOrientations.get(
+            _currentOrientation);
+        return c;
+
+    }
+
+    /**
+     * Map a Unicode character to a code point in the font.
+     * The code tables are already converted to Unicode therefore
+     * we can use the identity mapping.
+     * @param c character to map
+     * @return the mapped character
+     */
+    public char mapChar(char c) {
+        return c;
+    }
+
+}

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSet.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,275 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.fonts;
+
+
+/**
+ * The IBM Font Object Content Architecture (FOCA) supports presentation
+ * of character shapes by defining their characteristics, which include
+ * Font-Description information for identifying the characters, Font-Metric
+ * information for positioning the characters, and Character-Shape
+ * information for presenting the character images.
+ *
+ * Presenting a graphic character on a presentation surface requires
+ * that you communicate this information clearly to rotate and position
+ * characters correctly on the physical or logical page.
+ *
+ * This class proivdes font metric information for a particular font
+ * as by the orientation.
+ *
+ * This informtaion is obtained directly from the AFP font files which must
+ * be installed in the classpath under in the location specified by the path
+ * attribute in the afp-font.xml file.
+ * <p/>
+ */
+public class CharacterSetOrientation {
+
+    /**
+     * The code page to which the character set relates
+     */
+    private String _codePage;
+
+    /**
+     * The encoding used for the code page
+     */
+    private String _encoding;
+
+    /**
+     * The ascender height for the character set
+     */
+    private int _ascender;
+
+    /**
+     * The descender depth for the character set
+     */
+    private int _descender;
+
+    /**
+     * The height of capital letters
+     */
+    private int _capHeight;
+
+    /**
+     * The characters in the charcater set
+     */
+    private int[] _characters = new int[256];
+
+    /**
+     * The height of lowercase letters
+     */
+    private int _xHeight;
+
+    /**
+     * The first character
+     */
+    private int _firstCharacter;
+
+    /**
+     * The last character
+     */
+    private int _lastCharacter;
+
+
+    /**
+     * The character set orientation
+     */
+    private int _orientation = 0;
+
+    /**
+     * Constructor for the CharacterSetOrientation, the orientation is
+     * expressed as the degrees rotation (i.e 0, 90, 180, 270)
+     * @param orientation the character set orientation
+     */
+    public CharacterSetOrientation(int orientation) {
+
+        _orientation = orientation;
+
+    }
+
+    /**
+     * Ascender height is the distance from the character baseline to the
+     * top of the character box. A negative ascender height signifies that
+     * all of the graphic character is below the character baseline. For
+     * a character rotation other than 0, ascender height loses its
+     * meaning when the character is lying on its side or is upside down
+     * with respect to normal viewing orientation. For the general case,
+     * Ascender Height is the character�s most positive y-axis value.
+     * For bounded character boxes, for a given character having an
+     * ascender, ascender height and baseline offset are equal.
+     * @return the ascender value in millipoints
+     */
+    public int getAscender() {
+        return _ascender;
+    }
+
+    /**
+     * Cap height is the average height of the uppercase characters in
+     * a font. This value is specified by the designer of a font and is
+     * usually the height of the uppercase M.
+     * @return the cap height value in millipoints
+     */
+    public int getCapHeight() {
+        return _capHeight;
+    }
+
+    /**
+     * Descender depth is the distance from the character baseline to
+     * the bottom of a character box. A negative descender depth signifies
+     * that all of the graphic character is above the character baseline.
+     * @return the descender value in millipoints
+     */
+    public int getDescender() {
+        return _descender;
+    }
+
+    /**
+     * The first character in the character set
+     * @return the first character
+     */
+    public int getFirstChar() {
+        return _firstCharacter;
+    }
+
+    /**
+     * The last character in the character set
+     * @return the last character
+     */
+    public int getLastChar() {
+        return _lastCharacter;
+    }
+
+    /**
+     * The orientation for these metrics in the character set
+     * @return the orientation
+     */
+    public int getOrientation() {
+        return _orientation;
+    }
+
+    /**
+     * Get the width (in 1/1000ths of a point size) of all characters
+     * in this character set.
+     * @return the widths of all characters
+     */
+    public int[] getWidths() {
+
+        int arr[] = new int[(getLastChar() - getFirstChar()) + 1];
+        System.arraycopy(_characters, getFirstChar(), arr, 0, (getLastChar() - getFirstChar()) + 1);
+        return arr;
+
+    }
+
+    /**
+     * XHeight refers to the height of the lower case letters above
+     * the baseline.
+     * @return heightX	the typical height of characters
+     */
+    public int getXHeight() {
+        return _xHeight;
+    }
+
+    /**
+     * Get the width (in 1/1000ths of a point size) of the character
+     * identified by the parameter passed.
+     * @param character the character to evaluate
+     * @return the widths of the character
+     */
+    public int width(int character) {
+        return _characters[character];
+    }
+
+    /**
+     * Ascender height is the distance from the character baseline to the
+     * top of the character box. A negative ascender height signifies that
+     * all of the graphic character is below the character baseline. For
+     * a character rotation other than 0, ascender height loses its
+     * meaning when the character is lying on its side or is upside down
+     * with respect to normal viewing orientation. For the general case,
+     * Ascender Height is the character�s most positive y-axis value.
+     * For bounded character boxes, for a given character having an
+     * ascender, ascender height and baseline offset are equal.
+     * @param ascender the ascender to set
+     */
+    public void setAscender(int ascender) {
+        _ascender = ascender;
+    }
+
+    /**
+     * Cap height is the average height of the uppercase characters in
+     * a font. This value is specified by the designer of a font and is
+     * usually the height of the uppercase M.
+     * @param capHeight the cap height to set
+     */
+    public void setCapHeight(int capHeight) {
+        _capHeight = capHeight;
+    }
+
+    /**
+     * Descender depth is the distance from the character baseline to
+     * the bottom of a character box. A negative descender depth signifies
+     * that all of the graphic character is above the character baseline.
+     * @param descender	the descender value in millipoints
+     */
+    public void setDescender(int descender) {
+        _descender = descender;
+    }
+
+    /**
+     * The first character in the character set
+     * @param firstCharacter the first character
+     */
+    public void setFirstChar(int firstCharacter) {
+        _firstCharacter = firstCharacter;
+    }
+
+    /**
+     * The last character in the character set
+     * @param lastCharacter the last character
+     */
+    public void setLastChar(int lastCharacter) {
+        _lastCharacter = lastCharacter;
+    }
+
+    /**
+     * Set the width (in 1/1000ths of a point size) of the character
+     * identified by the parameter passed.
+     * @param character the character for which the width is being set
+     * @param width	the widths of the character
+     */
+    public void setWidth(int character, int width) {
+
+        if (character >= _characters.length) {
+            // Increase the size of the array if necessary
+            int arr[] = new int[(character - _firstCharacter) + 1];
+            System.arraycopy(_characters, 0, arr, 0, _characters.length);
+            _characters = arr;
+        }
+        _characters[character] = width;
+
+    }
+
+    /**
+     * XHeight refers to the height of the lower case letters above
+     * the baseline.
+     * @param xHeight the typical height of characters
+     */
+    public void setXHeight(int xHeight) {
+        _xHeight = xHeight;
+    }
+}

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/FopCharacterSet.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/FopCharacterSet.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/FopCharacterSet.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/FopCharacterSet.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.fonts;
+
+import org.apache.fop.fonts.Typeface;
+
+/**
+ * A Character set for a normal FOP font<p/>
+ */
+public class FopCharacterSet extends CharacterSet {
+
+    /** The character set for this font */
+    private Typeface _characterSet = null;
+    private int _size = 0;
+
+    /**
+     * Constructor for the CharacterSetMetric object, the character set is used
+     * to load the font information from the actual AFP font.
+     * @param codePage the code page identifier
+     * @param encoding the encoding of the font
+     * @param name the character set name
+     * @param size the font size
+     * @param Typeface the fop character set
+     */
+    public FopCharacterSet(
+        String codePage,
+        String encoding,
+        String name,
+        int size,
+        Typeface characterSet) {
+        super(codePage, encoding, name, null);
+        _characterSet = characterSet;
+        _size = size * 1000;
+    }
+
+    /**
+     * Ascender height is the distance from the character baseline to the
+     * top of the character box. A negative ascender height signifies that
+     * all of the graphic character is below the character baseline. For
+     * a character rotation other than 0, ascender height loses its
+     * meaning when the character is lying on its side or is upside down
+     * with respect to normal viewing orientation. For the general case,
+     * Ascender Height is the character�s most positive y-axis value.
+     * For bounded character boxes, for a given character having an
+     * ascender, ascender height and baseline offset are equal.
+     * @return the ascender value in millipoints
+     */
+    public int getAscender() {
+        return _characterSet.getAscender(_size);
+    }
+
+    /**
+     * Cap height is the average height of the uppercase characters in
+     * a font. This value is specified by the designer of a font and is
+     * usually the height of the uppercase M.
+     * @return the cap height value in millipoints
+     */
+    public int getCapHeight() {
+        return _characterSet.getCapHeight(_size);
+    }
+
+    /**
+     * Descender depth is the distance from the character baseline to
+     * the bottom of a character box. A negative descender depth signifies
+     * that all of the graphic character is above the character baseline.
+     * @return the descender value in millipoints
+     */
+    public int getDescender() {
+        return _characterSet.getDescender(_size);
+    }
+
+    /**
+     * The first character in the character set
+     * @return the first character
+     */
+    public int getFirstChar() {
+        return 0;
+    }
+
+    /**
+     * The last character in the character set
+     * @return the last character
+     */
+    public int getLastChar() {
+        return 0;
+    }
+
+    /**
+     * Get the width (in 1/1000ths of a point size) of all characters
+     * @return the widths of all characters
+     */
+    public int[] getWidths() {
+        return _characterSet.getWidths();
+    }
+
+    /**
+     * XHeight refers to the height of the lower case letters above the baseline.
+     * @return the typical height of characters
+     */
+    public int getXHeight() {
+        return _characterSet.getXHeight(_size);
+    }
+
+    /**
+     * Get the width (in 1/1000ths of a point size) of the character
+     * identified by the parameter passed.
+     * @param character the character from which the width will be calculated
+     * @return the width of the character
+     */
+    public int width(int character) {
+        return _characterSet.getWidth(character, _size);
+    }
+
+    /**
+     * Map a Unicode character to a code point in the font.
+     * @param c character to map
+     * @return the mapped character
+     */
+    public char mapChar(char c) {
+        return _characterSet.mapChar(c);
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/FopCharacterSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/FopCharacterSet.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/OutlineFont.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/OutlineFont.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/OutlineFont.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/OutlineFont.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.render.afp.fonts;
+
+
+/**
+ * A font defined as a set of lines and curves as opposed to a bitmap font. An
+ * outline font can be scaled to any size and otherwise transformed more easily
+ * than a bitmap font, and with more attractive results. <p/>
+ *
+ */
+public class OutlineFont extends AFPFont {
+
+    /** The character set for this font */
+    private CharacterSet _characterSet = null;
+
+    /**
+     * Constructor for an outline font.
+     *
+     * @param name
+     *            the name of the font
+     * @param characterSet
+     *            the chracter set
+     */
+    public OutlineFont(String name, CharacterSet characterSet) {
+        super(name);
+        _characterSet = characterSet;
+    }
+
+    /**
+     * Get the character set metrics.
+     *
+     * @return the character set
+     */
+    public CharacterSet getCharacterSet() {
+
+        return _characterSet;
+
+    }
+
+    /**
+     * Get the character set metrics.
+     * @param size ignored
+     * @return the character set
+     */
+    public CharacterSet getCharacterSet(int size) {
+
+        return _characterSet;
+
+    }
+
+    /**
+     * Get the first character in this font.
+     */
+    public int getFirstChar() {
+
+        return _characterSet.getFirstChar();
+
+    }
+
+    /**
+     * Get the last character in this font.
+     */
+    public int getLastChar() {
+
+        return _characterSet.getLastChar();
+
+    }
+
+    /**
+     * The ascender is the part of a lowercase letter that extends above the
+     * "x-height" (the height of the letter "x"), such as "d", "t", or "h". Also
+     * used to denote the part of the letter extending above the x-height.
+     *
+     * @param size
+     *            the point size
+     */
+    public int getAscender(int size) {
+
+        return _characterSet.getAscender() / 1000 * size;
+
+    }
+
+    /**
+     * Obtains the height of capital letters for the specified point size.
+     *
+     * @param size
+     *            the point size
+     */
+    public int getCapHeight(int size) {
+
+        return _characterSet.getCapHeight() / 1000 * size;
+
+    }
+
+    /**
+     * The descender is the part of a lowercase letter that extends below the
+     * base line, such as "g", "j", or "p". Also used to denote the part of the
+     * letter extending below the base line.
+     *
+     * @param size
+     *            the point size
+     */
+    public int getDescender(int size) {
+
+        return _characterSet.getDescender() / 1000 * size;
+
+    }
+
+    /**
+     * The "x-height" (the height of the letter "x").
+     *
+     * @param size
+     *            the point size
+     */
+    public int getXHeight(int size) {
+
+        return _characterSet.getXHeight() / 1000 * size;
+
+    }
+
+    /**
+     * Obtain the width of the character for the specified point size.
+     */
+    public int getWidth(int character, int size) {
+
+        return _characterSet.width(character) / 1000 * size;
+
+    }
+
+    /**
+     * Get the getWidth (in 1/1000ths of a point size) of all characters in this
+     * character set.
+     *
+     * @param size
+     *            the point size
+     * @return the widths of all characters
+     */
+    public int[] getWidths(int size) {
+
+        int[] widths =  _characterSet.getWidths();
+        for (int i = 0 ; i < widths.length; i++) {
+            widths[i] = widths[i] / 1000 * size;
+        }
+        return widths;
+
+    }
+
+    /**
+     * Get the getWidth (in 1/1000ths of a point size) of all characters in this
+     * character set.
+     *
+     * @return the widths of all characters
+     */
+    public int[] getWidths() {
+
+        return getWidths(1000);
+
+    }
+
+    /**
+     * Map a Unicode character to a code point in the font.
+     * @param c character to map
+     * @return the mapped character
+     */
+    public char mapChar(char c) {
+        return _characterSet.mapChar(c);
+    }
+
+    /**
+     * Get the encoding of the font.
+     * @return the encoding
+     */
+    public String getEncoding() {
+        return _characterSet.getEncoding();
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/OutlineFont.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/fonts/OutlineFont.java
------------------------------------------------------------------------------
    svn:keywords = Id



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


Re: svn commit: r397562 [2/6] - in /xmlgraphics/fop/trunk/src/sandbox: META-INF/services/ org/apache/fop/render/afp/ org/apache/fop/render/afp/apps/ org/apache/fop/render/afp/exceptions/ org/apache/fop/render/afp/extensions/ org/apache/fop/render/afp/fonts...

Posted by "J.Pietschmann" <j3...@yahoo.de>.
manuel@apache.org wrote:
> Added: .../fop/render/afp/exceptions/NestedRuntimeException.java
                                        ^^^^^^^^^^^^^^^^^^^^^^
Ow. Don't we have that already somewhere else in the code?

J.Pietschmann