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 me...@apache.org on 2012/07/25 14:32:38 UTC

svn commit: r1365555 - in /xmlgraphics/fop/trunk: ./ src/java/org/apache/fop/afp/ src/java/org/apache/fop/afp/fonts/ src/java/org/apache/fop/render/afp/

Author: mehdi
Date: Wed Jul 25 12:32:38 2012
New Revision: 1365555

URL: http://svn.apache.org/viewvc?rev=1365555&view=rev
Log:
Bugzilla#53600: Added an event if a glyph and its metric information does not exist in the character set

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/AFPEventProducer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/AFPEventProducer.xml
    xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/OutlineFont.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPFontConfig.java
    xmlgraphics/fop/trunk/status.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/AFPEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/AFPEventProducer.java?rev=1365555&r1=1365554&r2=1365555&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/AFPEventProducer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/AFPEventProducer.java Wed Jul 25 12:32:38 2012
@@ -113,4 +113,13 @@ public interface AFPEventProducer extend
      * @event.severity ERROR
      */
     void invalidConfiguration(Object source, Exception e);
+
+    /**
+     * The characterset is missing metric information for the specified character
+     * @param source the event source
+     * @param character the character with missing metric information.
+     * @param charSet the character set containing missing metric information
+     * @event.severity WARN
+     */
+    void charactersetMissingMetrics(Object source, char character, String charSet);
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/AFPEventProducer.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/AFPEventProducer.xml?rev=1365555&r1=1365554&r2=1365555&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/AFPEventProducer.xml (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/AFPEventProducer.xml Wed Jul 25 12:32:38 2012
@@ -8,4 +8,5 @@
   <message key="fontConfigMissing">The mandatory configuation node: '{missingConfig}' was not found at {location}.</message>
   <message key="characterSetNameInvalid">The character set given has an invalid name. [ Reason: {msg} ]</message>
   <message key="codePageNotFound">The code page for an AFP font cannot be found.[ Reason: {e}]</message>
+  <message key="charactersetMissingMetrics">Metric information is missing for the glyph `{character}` in the characterset `{charSet}`. Using space increment width.</message>
 </catalogue>

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java?rev=1365555&r1=1365554&r2=1365555&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java Wed Jul 25 12:32:38 2012
@@ -19,6 +19,8 @@
 
 package org.apache.fop.afp.fonts;
 
+import org.apache.fop.afp.AFPEventProducer;
+
 /**
  * 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
@@ -29,16 +31,25 @@ public abstract class AbstractOutlineFon
     /** The character set for this font */
     protected CharacterSet charSet = null;
 
+    private final AFPEventProducer eventProducer;
+
     /**
      * Constructor for an outline font.
      *
      * @param name the name of the font
      * @param embeddable sets whether or not this font is to be embedded
      * @param charSet the chracter set
+     * @param eventProducer The object to handle any events which occur from the object.
      */
-    public AbstractOutlineFont(String name, boolean embeddable, CharacterSet charSet) {
+    public AbstractOutlineFont(String name, boolean embeddable, CharacterSet charSet,
+            AFPEventProducer eventProducer) {
         super(name, embeddable);
         this.charSet = charSet;
+        this.eventProducer = eventProducer;
+    }
+
+    AFPEventProducer getAFPEventProducer() {
+        return eventProducer;
     }
 
     /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java?rev=1365555&r1=1365554&r2=1365555&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java Wed Jul 25 12:32:38 2012
@@ -23,6 +23,11 @@ import java.lang.Character.UnicodeBlock;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.afp.AFPEventProducer;
+
 /**
  * Implementation of AbstractOutlineFont that supports double-byte fonts (CID Keyed font (Type 0)).
  * The width of characters that are not prescribed a width metrics in the font resource use
@@ -31,7 +36,9 @@ import java.util.Set;
  */
 public class DoubleByteFont extends AbstractOutlineFont {
 
-    //private static final Log LOG = LogFactory.getLog(DoubleByteFont.class);
+    private static final Log log = LogFactory.getLog(DoubleByteFont.class);
+
+    private final Set<Integer> charsProcessed;
 
     //See also http://unicode.org/reports/tr11/ which we've not closely looked at, yet
     //TODO the Unicode block listed here is probably not complete (ex. Hiragana, Katakana etc.)
@@ -49,9 +56,12 @@ public class DoubleByteFont extends Abst
      * @param name the name of the font
      * @param embeddable whether or not this font is embeddable
      * @param charSet the character set
+     * @param eventProducer Handles any AFP related events
      */
-    public DoubleByteFont(String name, boolean embeddable, CharacterSet charSet) {
-        super(name, embeddable, charSet);
+    public DoubleByteFont(String name, boolean embeddable, CharacterSet charSet,
+            AFPEventProducer eventProducer) {
+        super(name, embeddable, charSet, eventProducer);
+        charsProcessed = new HashSet<Integer>();
     }
 
     /** {@inheritDoc} */
@@ -60,6 +70,11 @@ public class DoubleByteFont extends Abst
         try {
             charWidth = charSet.getWidth(toUnicodeCodepoint(character));
         } catch (IllegalArgumentException e) {
+            if (!charsProcessed.contains(character)) {
+                charsProcessed.add(character);
+                getAFPEventProducer().charactersetMissingMetrics(this, (char)character,
+                        charSet.getName().trim());
+            }
             //  We shall try and handle characters that have no mapped width metric in font resource
             charWidth = -1;
         }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/OutlineFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/OutlineFont.java?rev=1365555&r1=1365554&r2=1365555&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/OutlineFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/fonts/OutlineFont.java Wed Jul 25 12:32:38 2012
@@ -19,6 +19,8 @@
 
 package org.apache.fop.afp.fonts;
 
+import org.apache.fop.afp.AFPEventProducer;
+
 /**
  * Default implementation of AbstractOutlineFont.
  */
@@ -29,9 +31,11 @@ public class OutlineFont extends Abstrac
      * @param name font's name
      * @param embeddable whether or not this font is embeddable
      * @param charSet font's character set
+     * @param eventProducer Handles any AFP related events
      */
-    public OutlineFont(String name, boolean embeddable, CharacterSet charSet) {
-        super(name, embeddable, charSet);
+    public OutlineFont(String name, boolean embeddable, CharacterSet charSet,
+            AFPEventProducer eventProducer) {
+        super(name, embeddable, charSet, eventProducer);
     }
 
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPFontConfig.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPFontConfig.java?rev=1365555&r1=1365554&r2=1365555&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPFontConfig.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPFontConfig.java Wed Jul 25 12:32:38 2012
@@ -329,8 +329,8 @@ public final class AFPFontConfig impleme
             AFPResourceAccessor accessor = getAccessor(resourceResolver);
             CharacterSet characterSet = CharacterSetBuilder.getDoubleByteInstance().buildDBCS(
                     characterset, super.codePage, super.encoding, charsetType, accessor, eventProducer);
-            return getFontInfo(new DoubleByteFont(super.codePage, super.embeddable, characterSet),
-                    this);
+            return getFontInfo(new DoubleByteFont(super.codePage, super.embeddable, characterSet,
+                    eventProducer), this);
         }
     }
 
@@ -365,7 +365,8 @@ public final class AFPFontConfig impleme
                 characterSet = CharacterSetBuilder.getSingleByteInstance().buildSBCS(
                         characterset, super.codePage, super.encoding, accessor, eventProducer);
             }
-            return getFontInfo(new OutlineFont(super.name, super.embeddable, characterSet), this);
+            return getFontInfo(new OutlineFont(super.name, super.embeddable, characterSet,
+                    eventProducer), this);
         }
     }
 

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1365555&r1=1365554&r2=1365555&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Wed Jul 25 12:32:38 2012
@@ -62,6 +62,9 @@
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Fonts" dev="MH" type="add" fixes-bug="53600" due-to="Robert Meyer">
+        Added an event if a glyph and its metric information does not exist in the character set
+      </action>
       <action context="Renderers" dev="VH" type="add" fixes-bug="53596">
         When PDF accessibility is enabled, the structure tree must contain information about the 
         number of columns or rows spanned by a table cell.



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