aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2009-02-09 09:21:09 +0000
committerJeremias Maerki <jeremias@apache.org>2009-02-09 09:21:09 +0000
commitb8219e854ffc86e6911474762ab6a7c9535b9950 (patch)
tree607b7cfbd97cc72e7c2cd16dcd1c53b86a4088f6 /src/java/org/apache
parent879e33c0429f91fd9d6734b7d00410b71afbfa1d (diff)
downloadxmlgraphics-fop-b8219e854ffc86e6911474762ab6a7c9535b9950.tar.gz
xmlgraphics-fop-b8219e854ffc86e6911474762ab6a7c9535b9950.zip
Bugfix: restored support for characters not in a font's standard encoding when PostScript is generated with resource optimization turned off.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@742346 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/fonts/SingleByteFont.java20
-rw-r--r--src/java/org/apache/fop/render/ps/PSFontUtils.java31
2 files changed, 48 insertions, 3 deletions
diff --git a/src/java/org/apache/fop/fonts/SingleByteFont.java b/src/java/org/apache/fop/fonts/SingleByteFont.java
index 92e7c0547..3892e87e6 100644
--- a/src/java/org/apache/fop/fonts/SingleByteFont.java
+++ b/src/java/org/apache/fop/fonts/SingleByteFont.java
@@ -19,8 +19,10 @@
package org.apache.fop.fonts;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -219,6 +221,24 @@ public class SingleByteFont extends CustomFont {
}
/**
+ * Makes all unencoded characters available through additional encodings. This method
+ * is used in cases where the fonts need to be encoded in the target format before
+ * all text of the document is processed (for example in PostScript when resource optimization
+ * is disabled).
+ */
+ public void encodeAllUnencodedCharacters() {
+ if (this.unencodedCharacters != null) {
+ Set sortedKeys = new java.util.TreeSet(this.unencodedCharacters.keySet());
+ Iterator iter = sortedKeys.iterator();
+ while (iter.hasNext()) {
+ Character ch = (Character)iter.next();
+ char mapped = mapChar(ch.charValue());
+ assert mapped != Typeface.NOT_FOUND;
+ }
+ }
+ }
+
+ /**
* Indicates whether the encoding has additional encodings besides the primary encoding.
* @return true if there are additional encodings.
*/
diff --git a/src/java/org/apache/fop/render/ps/PSFontUtils.java b/src/java/org/apache/fop/render/ps/PSFontUtils.java
index 6bb1f294b..c18e794e2 100644
--- a/src/java/org/apache/fop/render/ps/PSFontUtils.java
+++ b/src/java/org/apache/fop/render/ps/PSFontUtils.java
@@ -57,7 +57,9 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
protected static Log log = LogFactory.getLog(PSFontUtils.class);
/**
- * Generates the PostScript code for the font dictionary.
+ * Generates the PostScript code for the font dictionary. This method should only be
+ * used if no "resource optimization" is performed, i.e. when the fonts are not embedded
+ * in a second pass.
* @param gen PostScript generator to use for output
* @param fontInfo available fonts
* @return a Map of PSResource instances representing all defined fonts (key: font key)
@@ -65,11 +67,13 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
*/
public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo)
throws IOException {
- return writeFontDict(gen, fontInfo, fontInfo.getFonts());
+ return writeFontDict(gen, fontInfo, fontInfo.getFonts(), true);
}
/**
- * Generates the PostScript code for the font dictionary.
+ * Generates the PostScript code for the font dictionary. This method assumes all used
+ * fonts and characters are known, i.e. when PostScript is generated with resource
+ * optimization turned on.
* @param gen PostScript generator to use for output
* @param fontInfo available fonts
* @param fonts the set of fonts to work with
@@ -78,6 +82,21 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
*/
public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map fonts)
throws IOException {
+ return writeFontDict(gen, fontInfo, fonts, false);
+ }
+
+ /**
+ * Generates the PostScript code for the font dictionary.
+ * @param gen PostScript generator to use for output
+ * @param fontInfo available fonts
+ * @param fonts the set of fonts to work with
+ * @param encodeAllCharacters true if all characters shall be encoded using additional,
+ * generated encodings.
+ * @return a Map of PSResource instances representing all defined fonts (key: font key)
+ * @throws IOException in case of an I/O problem
+ */
+ private static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map fonts,
+ boolean encodeAllCharacters) throws IOException {
gen.commentln("%FOPBeginFontDict");
Map fontResources = new java.util.HashMap();
@@ -91,6 +110,11 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
if (tf instanceof SingleByteFont) {
SingleByteFont sbf = (SingleByteFont)tf;
+
+ if (encodeAllCharacters) {
+ sbf.encodeAllUnencodedCharacters();
+ }
+
for (int i = 0, c = sbf.getAdditionalEncodingCount(); i < c; i++) {
SingleByteEncoding encoding = sbf.getAdditionalEncoding(i);
defineEncoding(gen, encoding);
@@ -110,6 +134,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
ResourceTracker tracker = gen.getResourceTracker();
if (!tracker.isResourceSupplied(WINANSI_ENCODING_RESOURCE)) {
+ //Only out Base 14 fonts still use that
defineWinAnsiEncoding(gen);
}
gen.commentln("%FOPBeginFontReencode");