diff options
author | Mehdi Houshmand <mehdi@apache.org> | 2012-07-25 12:32:38 +0000 |
---|---|---|
committer | Mehdi Houshmand <mehdi@apache.org> | 2012-07-25 12:32:38 +0000 |
commit | 91b509858a1e73588bca498c85a78086f7315b42 (patch) | |
tree | f12c488cdc927def37edfc4022b628b4fa01555a /src/java | |
parent | b1e574f3518f450378c579f32f0ee1d0a87518c2 (diff) | |
download | xmlgraphics-fop-91b509858a1e73588bca498c85a78086f7315b42.tar.gz xmlgraphics-fop-91b509858a1e73588bca498c85a78086f7315b42.zip |
Bugzilla#53600: Added an event if a glyph and its metric information does not exist in the character set
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1365555 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
6 files changed, 50 insertions, 9 deletions
diff --git a/src/java/org/apache/fop/afp/AFPEventProducer.java b/src/java/org/apache/fop/afp/AFPEventProducer.java index 93eb9c042..01d5c4ad7 100644 --- a/src/java/org/apache/fop/afp/AFPEventProducer.java +++ b/src/java/org/apache/fop/afp/AFPEventProducer.java @@ -113,4 +113,13 @@ public interface AFPEventProducer extends EventProducer { * @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); } diff --git a/src/java/org/apache/fop/afp/AFPEventProducer.xml b/src/java/org/apache/fop/afp/AFPEventProducer.xml index 042eb5ed8..e17a4ea40 100644 --- a/src/java/org/apache/fop/afp/AFPEventProducer.xml +++ b/src/java/org/apache/fop/afp/AFPEventProducer.xml @@ -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> diff --git a/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java b/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java index 1a2611d8d..7b57a2b8c 100644 --- a/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java +++ b/src/java/org/apache/fop/afp/fonts/AbstractOutlineFont.java @@ -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 AbstractOutlineFont extends AFPFont { /** 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; } /** diff --git a/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java b/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java index a81805bc5..0e6cc20c2 100644 --- a/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java +++ b/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java @@ -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 AbstractOutlineFont { * @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 AbstractOutlineFont { 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; } diff --git a/src/java/org/apache/fop/afp/fonts/OutlineFont.java b/src/java/org/apache/fop/afp/fonts/OutlineFont.java index 103d96eca..e9cdf5ba4 100644 --- a/src/java/org/apache/fop/afp/fonts/OutlineFont.java +++ b/src/java/org/apache/fop/afp/fonts/OutlineFont.java @@ -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 AbstractOutlineFont { * @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); } } diff --git a/src/java/org/apache/fop/render/afp/AFPFontConfig.java b/src/java/org/apache/fop/render/afp/AFPFontConfig.java index eca76078f..aef0b666c 100644 --- a/src/java/org/apache/fop/render/afp/AFPFontConfig.java +++ b/src/java/org/apache/fop/render/afp/AFPFontConfig.java @@ -329,8 +329,8 @@ public final class AFPFontConfig implements FontConfig { 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 implements FontConfig { 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); } } |