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/09/19 17:00:20 UTC
svn commit: r1387628 [2/3] - in
/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution: ./ lib/
src/documentation/content/xdocs/ src/documentation/content/xdocs/dev/
src/documentation/content/xdocs/trunk/
src/java/org/apache/fop/accessibility/fo/ src/java/o...
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/CIDFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/CIDFont.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/CIDFont.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/CIDFont.java Wed Sep 19 15:00:15 2012
@@ -29,7 +29,7 @@ import org.apache.fop.apps.io.InternalRe
public abstract class CIDFont extends CustomFont {
/** Contains the character widths for all characters in the font */
- protected int[] width = null;
+ protected int[] width;
/**
* @param resourceResolver the URI resolver for controlling file access
@@ -69,7 +69,7 @@ public abstract class CIDFont extends Cu
* Returns the subset information for this font.
* @return the subset information
*/
- public abstract CIDSubset getCIDSubset();
+ public abstract CIDSet getCIDSet();
// ---- Optional ----
/**
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/CIDSubset.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/CIDSubset.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/CIDSubset.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/CIDSubset.java Wed Sep 19 15:00:15 2012
@@ -26,18 +26,16 @@ import java.util.Map;
import org.apache.fop.util.CharUtilities;
-//Naming:
-//glyph index: original index of the glyph in the non-subset font (!= unicode index)
-//character selector: index into a set of glyphs. For subset CID fonts, this starts at 0. For
-// non-subset fonts, this is the same as the glyph index.
-//Unicode index: The Unicode codepoint of a character.
-//Glyph name: the Adobe glyph name (as found in Glyphs.java)
-
/**
- * Keeps track of the glyphs used in a document. This information is later used to build
- * a subset of a font.
+ * Provides methods to get font information.
+ * Naming:
+ * glyph index: original index of the glyph in the non-subset font (!= unicode index)
+ * character selector: index into a set of glyphs. For subset CID fonts, this starts at 0. For non-subset
+ * fonts, this is the same as the glyph index.
+ * Unicode index: The Unicode codepoint of a character.
+ * Glyph name: the Adobe glyph name (as found in Glyphs.java)
*/
-public class CIDSubset {
+public class CIDSubset implements CIDSet {
/**
* usedGlyphs contains orginal, new glyph index (glyph index -> char selector)
@@ -48,51 +46,36 @@ public class CIDSubset {
* usedGlyphsIndex contains new glyph, original index (char selector -> glyph index)
*/
private Map<Integer, Integer> usedGlyphsIndex = new HashMap<Integer, Integer>();
- private int usedGlyphsCount = 0;
+ private int usedGlyphsCount;
/**
* usedCharsIndex contains new glyph, original char (char selector -> Unicode)
*/
private Map<Integer, Character> usedCharsIndex = new HashMap<Integer, Character>();
- /**
- * Default constructor.
- */
- public CIDSubset() {
- }
+ private final MultiByteFont font;
- /**
- * Adds the first glyph which is reserved for .notdef for all CID subsets.
- */
- public void setupFirstGlyph() {
- usedGlyphs.put(Integer.valueOf(0), Integer.valueOf(0));
- usedGlyphsIndex.put(Integer.valueOf(0), Integer.valueOf(0));
+ public CIDSubset(MultiByteFont mbf) {
+ font = mbf;
+ // The zeroth value is reserved for .notdef
+ usedGlyphs.put(0, 0);
+ usedGlyphsIndex.put(0, 0);
usedGlyphsCount++;
}
- /**
- * Returns the original index of the glyph inside the (non-subset) font's glyph list. This
- * index can be used to access the character width information, for example.
- * @param subsetIndex the subset index (character selector) to access the glyph
- * @return the original index (or -1 if no glyph index is available for the subset index)
- */
- public int getGlyphIndexForSubsetIndex(int subsetIndex) {
- Integer glyphIndex = usedGlyphsIndex.get(Integer.valueOf(subsetIndex));
+ /** {@inheritDoc} */
+ public int getOriginalGlyphIndex(int index) {
+ Integer glyphIndex = usedGlyphsIndex.get(index);
if (glyphIndex != null) {
- return glyphIndex.intValue();
+ return glyphIndex;
} else {
return -1;
}
}
- /**
- * Returns the Unicode value for a subset index (character selector). If there's no such
- * Unicode value, the "NOT A CHARACTER" (0xFFFF) is returned.
- * @param subsetIndex the subset index (character selector)
- * @return the Unicode value or "NOT A CHARACTER" (0xFFFF)
- */
- public char getUnicodeForSubsetIndex(int subsetIndex) {
- Character mapValue = usedCharsIndex.get(Integer.valueOf(subsetIndex));
+ /** {@inheritDoc} */
+ public char getUnicode(int index) {
+ Character mapValue = usedCharsIndex.get(index);
if (mapValue != null) {
return mapValue.charValue();
} else {
@@ -100,72 +83,60 @@ public class CIDSubset {
}
}
- /**
- * Maps a character to a character selector for a font subset. If the character isn't in the
- * subset, yet, it is added and a new character selector returned. Otherwise, the already
- * allocated character selector is returned from the existing map/subset.
- * @param glyphIndex the glyph index of the character
- * @param unicode the Unicode index of the character
- * @return the subset index
- */
- public int mapSubsetChar(int glyphIndex, char unicode) {
+ /** {@inheritDoc} */
+ public int mapChar(int glyphIndex, char unicode) {
// Reencode to a new subset font or get the reencoded value
// IOW, accumulate the accessed characters and build a character map for them
- Integer subsetCharSelector = usedGlyphs.get(Integer.valueOf(glyphIndex));
+ Integer subsetCharSelector = usedGlyphs.get(glyphIndex);
if (subsetCharSelector == null) {
int selector = usedGlyphsCount;
- usedGlyphs.put(Integer.valueOf(glyphIndex),
- Integer.valueOf(selector));
- usedGlyphsIndex.put(Integer.valueOf(selector),
- Integer.valueOf(glyphIndex));
- usedCharsIndex.put(Integer.valueOf(selector),
- Character.valueOf(unicode));
+ usedGlyphs.put(glyphIndex, selector);
+ usedGlyphsIndex.put(selector, glyphIndex);
+ usedCharsIndex.put(selector, unicode);
usedGlyphsCount++;
return selector;
} else {
- return subsetCharSelector.intValue();
+ return subsetCharSelector;
}
}
- /**
- * Returns an unmodifiable Map of the font subset. It maps from glyph index to
- * character selector (i.e. the subset index in this case).
- * @return Map Map<Integer, Integer> of the font subset
- */
- public Map<Integer, Integer> getSubsetGlyphs() {
+ /** {@inheritDoc} */
+ public Map<Integer, Integer> getGlyphs() {
return Collections.unmodifiableMap(this.usedGlyphs);
}
- /**
- * Returns a char array containing all Unicode characters that are in the subset.
- * @return a char array with all used Unicode characters
- */
- public char[] getSubsetChars() {
+ /** {@inheritDoc} */
+ public char[] getChars() {
char[] charArray = new char[usedGlyphsCount];
for (int i = 0; i < usedGlyphsCount; i++) {
- charArray[i] = getUnicodeForSubsetIndex(i);
+ charArray[i] = getUnicode(i);
}
return charArray;
}
- /**
- * Returns the number of glyphs in the subset.
- * @return the number of glyphs in the subset
- */
- public int getSubsetSize() {
+ /** {@inheritDoc} */
+ public int getNumberOfGlyphs() {
return this.usedGlyphsCount;
}
- /**
- * Returns a BitSet with bits set for each available glyph index in the subset.
- * @return a BitSet indicating available glyph indices
- */
- public BitSet getGlyphIndexBitSet() {
+ /** {@inheritDoc} */
+ public BitSet getGlyphIndices() {
BitSet bitset = new BitSet();
for (Integer cid : usedGlyphs.keySet()) {
- bitset.set(cid.intValue());
+ bitset.set(cid);
}
return bitset;
}
+ /** {@inheritDoc} */
+ public int[] getWidths() {
+ int[] widths = font.getWidths();
+ int[] tmpWidth = new int[getNumberOfGlyphs()];
+ for (int i = 0, c = getNumberOfGlyphs(); i < c; i++) {
+ int nwx = Math.max(0, getOriginalGlyphIndex(i));
+ tmpWidth[i] = widths[nwx];
+ }
+ return tmpWidth;
+ }
+
}
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/DefaultFontConfig.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/DefaultFontConfig.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/DefaultFontConfig.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/DefaultFontConfig.java Wed Sep 19 15:00:15 2012
@@ -89,7 +89,7 @@ public final class DefaultFontConfig imp
} else {
this.strict = strict;
this.fontInfoCfg = cfg.getChild("fonts", false);
- instance = new DefaultFontConfig(cfg.getChild("auto-detect", false) != null);
+ instance = new DefaultFontConfig(fontInfoCfg.getChild("auto-detect", false) != null);
parse();
}
}
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontCache.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontCache.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontCache.java Wed Sep 19 15:00:15 2012
@@ -53,7 +53,7 @@ public final class FontCache implements
* Serialization Version UID. Change this value if you want to make sure the
* user's cache file is purged after an update.
*/
- private static final long serialVersionUID = 605232520271754719L;
+ private static final long serialVersionUID = 9129238336422194339L;
/** logging instance */
private static Log log = LogFactory.getLog(FontCache.class);
@@ -65,7 +65,7 @@ public final class FontCache implements
private static final String DEFAULT_CACHE_FILENAME = "fop-fonts.cache";
/** has this cache been changed since it was last read? */
- private transient boolean changed = false;
+ private transient boolean changed;
/** change lock */
private final boolean[] changeLock = new boolean[1];
@@ -73,12 +73,14 @@ public final class FontCache implements
/**
* master mapping of font url -> font info. This needs to be a list, since a
* TTC file may contain more than 1 font.
+ * @serial
*/
private Map<String, CachedFontFile> fontfileMap = null;
/**
* mapping of font url -> file modified date (for all fonts that have failed
* to load)
+ * @serial
*/
private Map<String, Long> failedFontMap = null;
@@ -139,6 +141,7 @@ public final class FontCache implements
*
* @return the font cache deserialized from the file (or null if no cache
* file exists or if it could not be read)
+ * @deprecated use {@link #loadFrom(File)} instead
*/
public static FontCache load() {
return loadFrom(getDefaultCacheFile(false));
@@ -190,8 +193,8 @@ public final class FontCache implements
/**
* Writes the font cache to disk.
*
- * @throws FOPException
- * fop exception
+ * @throws FOPException fop exception
+ * @deprecated use {@link #saveTo(File)} instead
*/
public void save() throws FOPException {
saveTo(getDefaultCacheFile(true));
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontCacheManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontCacheManager.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontCacheManager.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontCacheManager.java Wed Sep 19 15:00:15 2012
@@ -19,7 +19,7 @@
package org.apache.fop.fonts;
-import java.io.File;
+import java.net.URI;
import org.apache.fop.apps.FOPException;
@@ -30,24 +30,26 @@ import org.apache.fop.apps.FOPException;
public interface FontCacheManager {
/**
+ * Sets the font cache file given the URI pointing to the file.
+ * @param fontCacheURI the font cache URI
+ */
+ void setCacheFile(URI fontCacheURI);
+
+ /**
* Loads the font cache into memory from the given file.
- * @param file the serialized font cache
* @return the de-serialized font cache
*/
- FontCache load(File file);
+ FontCache load();
/**
* Serializes the font cache to file.
- * @param file the file to serialize the font cache to
* @throws FOPException if an error occurs serializing the font cache
*/
- void save(File file) throws FOPException;
+ void save() throws FOPException;
/**
* Deletes the font cache from the file-system.
- * @param file delete the serialized font cache
* @throws FOPException if an error occurs deleting the font cache
*/
- void delete(File file) throws FOPException;
-
+ void delete() throws FOPException;
}
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontCacheManagerFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontCacheManagerFactory.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontCacheManagerFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontCacheManagerFactory.java Wed Sep 19 15:00:15 2012
@@ -20,6 +20,7 @@
package org.apache.fop.fonts;
import java.io.File;
+import java.net.URI;
import org.apache.fop.apps.FOPException;
@@ -50,11 +51,14 @@ public final class FontCacheManagerFacto
private static final class FontCacheManagerImpl implements FontCacheManager {
+ /** Provides a font cache file path **/
+ private File cacheFile;
+
private FontCache fontCache;
- public FontCache load(File cacheFile) {
+ public FontCache load() {
if (fontCache == null) {
- fontCache = FontCache.loadFrom(cacheFile);
+ fontCache = FontCache.loadFrom(getCacheFile(false));
if (fontCache == null) {
fontCache = new FontCache();
}
@@ -62,31 +66,46 @@ public final class FontCacheManagerFacto
return fontCache;
}
- public void save(File cacheFile) throws FOPException {
+ public void save() throws FOPException {
if (fontCache != null && fontCache.hasChanged()) {
- fontCache.saveTo(cacheFile);
+ fontCache.saveTo(getCacheFile(true));
}
}
- public void delete(File cacheFile) throws FOPException {
- if (!cacheFile.delete()) {
+ public void delete() throws FOPException {
+ if (!getCacheFile(true).delete()) {
throw new FOPException("Failed to flush the font cache file '" + cacheFile + "'.");
}
}
+
+ private File getCacheFile(boolean forWriting) {
+ if (cacheFile != null) {
+ return cacheFile;
+ }
+ return FontCache.getDefaultCacheFile(forWriting);
+ }
+
+ public void setCacheFile(URI fontCacheURI) {
+ cacheFile = new File(fontCacheURI);
+ }
}
private static final class DisabledFontCacheManager implements FontCacheManager {
- public FontCache load(File cacheFile) {
+ public FontCache load() {
return null;
}
- public void save(File cacheFile) throws FOPException {
+ public void save() throws FOPException {
// nop
}
- public void delete(File cacheFile) throws FOPException {
+ public void delete() throws FOPException {
throw new FOPException("Font Cache disabled");
}
+
+ public void setCacheFile(URI fontCacheURI) {
+ // nop
+ }
}
}
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontManager.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontManager.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontManager.java Wed Sep 19 15:00:15 2012
@@ -19,7 +19,7 @@
package org.apache.fop.fonts;
-import java.io.File;
+import java.net.URI;
import java.util.List;
import org.apache.fop.apps.FOPException;
@@ -52,9 +52,6 @@ public class FontManager {
/** FontTriplet matcher for fonts that shall be referenced rather than embedded. */
private FontTriplet.Matcher referencedFontsMatcher;
- /** Provides a font cache file path **/
- private File cacheFile;
-
/**
* Main constructor
*
@@ -115,25 +112,10 @@ public class FontManager {
/**
* Sets the font cache file
- * @param cacheFile the font cache file
- */
- public void setCacheFile(File cacheFile) {
- this.cacheFile = cacheFile;
- }
-
- /**
- * Returns the font cache file
- * @return the font cache file
+ * @param cacheFileURI the URI of the font cache file
*/
- public File getCacheFile() {
- return getCacheFile(false);
- }
-
- private File getCacheFile(boolean writable) {
- if (cacheFile != null) {
- return cacheFile;
- }
- return FontCache.getDefaultCacheFile(writable);
+ public void setCacheFile(URI cacheFileURI) {
+ fontCacheManager.setCacheFile(resourceResolver.resolveFromBase(cacheFileURI));
}
/**
@@ -148,7 +130,7 @@ public class FontManager {
* @return the font cache
*/
public FontCache getFontCache() {
- return fontCacheManager.load(getCacheFile());
+ return fontCacheManager.load();
}
/**
@@ -157,7 +139,7 @@ public class FontManager {
* @throws FOPException fop exception
*/
public void saveCache() throws FOPException {
- fontCacheManager.save(getCacheFile());
+ fontCacheManager.save();
}
/**
@@ -165,7 +147,7 @@ public class FontManager {
* @throws FOPException if an error was thrown while deleting the cache
*/
public void deleteCache() throws FOPException {
- fontCacheManager.delete(getCacheFile(true));
+ fontCacheManager.delete();
}
/**
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontManagerConfigurator.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontManagerConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontManagerConfigurator.java Wed Sep 19 15:00:15 2012
@@ -19,7 +19,6 @@
package org.apache.fop.fonts;
-import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
@@ -72,6 +71,19 @@ public class FontManagerConfigurator {
* @throws FOPException if an exception occurs while processing the configuration
*/
public void configure(FontManager fontManager, boolean strict) throws FOPException {
+ if (cfg.getChild("font-base", false) != null) {
+ try {
+ URI fontBase = InternalResourceResolver.getBaseURI(cfg.getChild("font-base")
+ .getValue(null));
+ fontManager.setResourceResolver(ResourceResolverFactory.createInternalResourceResolver(
+ defaultBaseUri.resolve(fontBase), resourceResolver));
+ } catch (URISyntaxException use) {
+ LogUtil.handleException(log, use, true);
+ }
+ } else {
+ fontManager.setResourceResolver(ResourceResolverFactory.createInternalResourceResolver(
+ defaultBaseUri, resourceResolver));
+ }
// caching (fonts)
if (cfg.getChild("use-cache", false) != null) {
try {
@@ -79,27 +91,14 @@ public class FontManagerConfigurator {
fontManager.disableFontCache();
} else {
if (cfg.getChild("cache-file", false) != null) {
- fontManager.setCacheFile(new File(cfg.getChild("cache-file").getValue()));
+
+ fontManager.setCacheFile(URI.create(cfg.getChild("cache-file").getValue()));
}
}
} catch (ConfigurationException mfue) {
LogUtil.handleException(log, mfue, true);
}
}
- if (cfg.getChild("font-base", false) != null) {
- try {
- URI fontBase = InternalResourceResolver.getBaseURI(cfg.getChild("font-base").getValue(
- null));
- fontManager.setResourceResolver(ResourceResolverFactory.createInternalResourceResolver(
- defaultBaseUri.resolve(fontBase), resourceResolver));
- } catch (URISyntaxException use) {
- LogUtil.handleException(log, use, true);
- }
- } else {
- fontManager.setResourceResolver(ResourceResolverFactory.createInternalResourceResolver(
- defaultBaseUri, resourceResolver));
- }
-
// [GA] permit configuration control over base14 kerning; without this,
// there is no way for a user to enable base14 kerning other than by
// programmatic API;
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontReader.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontReader.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/FontReader.java Wed Sep 19 15:00:15 2012
@@ -157,7 +157,7 @@ public class FontReader extends DefaultH
throws SAXException {
if (localName.equals("font-metrics")) {
if ("TYPE0".equals(attributes.getValue("type"))) {
- multiFont = new MultiByteFont(resourceResolver);
+ multiFont = new MultiByteFont(resourceResolver, EmbeddingMode.AUTO);
returnFont = multiFont;
isCID = true;
TTFReader.checkMetricsVersion(attributes);
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/LazyFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/LazyFont.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/LazyFont.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/LazyFont.java Wed Sep 19 15:00:15 2012
@@ -438,6 +438,9 @@ public class LazyFont extends Typeface i
*/
public boolean isSubsetEmbedded() {
load(true);
+ if (realFont.isMultiByte() && this.embeddingMode == EmbeddingMode.FULL) {
+ return false;
+ }
return realFont.isMultiByte();
}
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/MultiByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/MultiByteFont.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/MultiByteFont.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/MultiByteFont.java Wed Sep 19 15:00:15 2012
@@ -21,6 +21,7 @@ package org.apache.fop.fonts;
import java.nio.CharBuffer;
import java.nio.IntBuffer;
+import java.util.BitSet;
import java.util.Map;
import org.apache.commons.logging.Log;
@@ -44,13 +45,13 @@ public class MultiByteFont extends CIDFo
private static final Log log // CSOK: ConstantNameCheck
= LogFactory.getLog(MultiByteFont.class);
- private String ttcName = null;
+ private String ttcName;
private String encoding = "Identity-H";
- private int defaultWidth = 0;
+ private int defaultWidth;
private CIDFontType cidType = CIDFontType.CIDTYPE2;
- private CIDSubset subset = new CIDSubset();
+ private final CIDSet cidSet;
/* advanced typographic support */
private GlyphDefinitionTable gdef;
@@ -69,10 +70,15 @@ public class MultiByteFont extends CIDFo
/**
* Default constructor
*/
- public MultiByteFont(InternalResourceResolver resourceResolver) {
+ public MultiByteFont(InternalResourceResolver resourceResolver, EmbeddingMode embeddingMode) {
super(resourceResolver);
- subset.setupFirstGlyph();
setFontType(FontType.TYPE0);
+ setEmbeddingMode(embeddingMode);
+ if (embeddingMode != EmbeddingMode.FULL) {
+ cidSet = new CIDSubset(this);
+ } else {
+ cidSet = new CIDFull(this);
+ }
}
/** {@inheritDoc} */
@@ -129,13 +135,16 @@ public class MultiByteFont extends CIDFo
}
public boolean isSubsetEmbedded() {
+ if (getEmbeddingMode() == EmbeddingMode.FULL) {
+ return false;
+ }
return true;
}
/** {@inheritDoc} */
@Override
- public CIDSubset getCIDSubset() {
- return this.subset;
+ public CIDSet getCIDSet() {
+ return this.cidSet;
}
/** {@inheritDoc} */
@@ -147,7 +156,7 @@ public class MultiByteFont extends CIDFo
/** {@inheritDoc} */
public int getWidth(int i, int size) {
if (isEmbeddable()) {
- int glyphIndex = subset.getGlyphIndexForSubsetIndex(i);
+ int glyphIndex = cidSet.getOriginalGlyphIndex(i);
return size * width[glyphIndex];
} else {
return size * width[i];
@@ -283,9 +292,39 @@ public class MultiByteFont extends CIDFo
glyphIndex = findGlyphIndex(Typeface.NOT_FOUND);
}
if (isEmbeddable()) {
- glyphIndex = subset.mapSubsetChar(glyphIndex, c);
+ glyphIndex = cidSet.mapChar(glyphIndex, c);
+ }
+ return (char) glyphIndex;
+ }
+
+ protected BitSet getGlyphIndices() {
+ BitSet bitset = new BitSet();
+ bitset.set(0);
+ bitset.set(1);
+ bitset.set(2);
+ for (int i = 0; i < cmap.length; i++) {
+ int start = cmap[i].getUnicodeStart();
+ int end = cmap[i].getUnicodeEnd();
+ int glyphIndex = cmap[i].getGlyphStartIndex();
+ while (start++ < end + 1) {
+ bitset.set(glyphIndex++);
+ }
}
- return (char)glyphIndex;
+ return bitset;
+ }
+
+ protected char[] getChars() {
+ // the width array is set when the font is built
+ char[] chars = new char[width.length];
+ for (int i = 0; i < cmap.length; i++) {
+ int start = cmap[i].getUnicodeStart();
+ int end = cmap[i].getUnicodeEnd();
+ int glyphIndex = cmap[i].getGlyphStartIndex();
+ while (start < end + 1) {
+ chars[glyphIndex++] = (char) start++;
+ }
+ }
+ return chars;
}
/** {@inheritDoc} */
@@ -331,15 +370,7 @@ public class MultiByteFont extends CIDFo
* @return Map Map of used Glyphs
*/
public Map<Integer, Integer> getUsedGlyphs() {
- return subset.getSubsetGlyphs();
- }
-
- /** @return an array of the chars used */
- public char[] getCharsUsed() {
- if (!isEmbeddable()) {
- return null;
- }
- return subset.getSubsetChars();
+ return cidSet.getGlyphs();
}
/**
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java Wed Sep 19 15:00:15 2012
@@ -127,7 +127,7 @@ public class TTFFontLoader extends FontL
}
if (isCid) {
- multiFont = new MultiByteFont(resourceResolver);
+ multiFont = new MultiByteFont(resourceResolver, embeddingMode);
returnFont = multiFont;
multiFont.setTTCName(ttcFontName);
} else {
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/BreakElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/BreakElement.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/BreakElement.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/BreakElement.java Wed Sep 19 15:00:15 2012
@@ -21,6 +21,8 @@ package org.apache.fop.layoutmgr;
import java.util.List;
+import org.apache.fop.fo.Constants;
+
/**
* This class represents an unresolved break possibility.
*/
@@ -28,7 +30,7 @@ public class BreakElement extends Unreso
private int penaltyWidth;
private int penaltyValue;
- private int breakClass = -1;
+ private int breakClass;
private List pendingBeforeMarks;
private List pendingAfterMarks;
@@ -39,7 +41,7 @@ public class BreakElement extends Unreso
* @param context the layout context which contains the pending conditional elements
*/
public BreakElement(Position position, int penaltyValue, LayoutContext context) {
- this(position, penaltyValue, -1, context);
+ this(position, penaltyValue, Constants.EN_AUTO, context);
}
/**
@@ -80,7 +82,7 @@ public class BreakElement extends Unreso
super(position);
this.penaltyWidth = penaltyWidth;
this.penaltyValue = penaltyValue;
- this.breakClass = breakClass;
+ setBreakClass(breakClass);
this.pendingBeforeMarks = context.getPendingBeforeMarks();
this.pendingAfterMarks = context.getPendingAfterMarks();
}
@@ -142,13 +144,24 @@ public class BreakElement extends Unreso
*
* @param breakClass one of
* {@link org.apache.fop.fo.Constants#EN_AUTO},
+ * {@link org.apache.fop.fo.Constants#EN_LINE},
* {@link org.apache.fop.fo.Constants#EN_COLUMN},
* {@link org.apache.fop.fo.Constants#EN_PAGE},
* {@link org.apache.fop.fo.Constants#EN_EVEN_PAGE},
* {@link org.apache.fop.fo.Constants#EN_ODD_PAGE}.
*/
public void setBreakClass(int breakClass) {
- this.breakClass = breakClass;
+ switch (breakClass) {
+ case Constants.EN_AUTO:
+ case Constants.EN_LINE:
+ case Constants.EN_COLUMN:
+ case Constants.EN_PAGE:
+ case Constants.EN_EVEN_PAGE:
+ case Constants.EN_ODD_PAGE:
+ this.breakClass = breakClass;
+ break;
+ default: throw new IllegalArgumentException("Illegal value for break class: " + breakClass);
+ }
}
/** @return the pending border and padding elements at the before edge */
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/PageBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/PageBreaker.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/PageBreaker.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/PageBreaker.java Wed Sep 19 15:00:15 2012
@@ -95,8 +95,7 @@ public class PageBreaker extends Abstrac
return new PageBreakingLayoutListener() {
public void notifyOverflow(int part, int amount, FObj obj) {
- Page p = pageProvider.getPage(
- false, part, PageProvider.RELTO_CURRENT_ELEMENT_LIST);
+ Page p = pageProvider.getPageFromColumnIndex(part);
RegionBody body = (RegionBody)p.getSimplePageMaster().getRegion(
Region.FO_REGION_BODY);
BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/PageProvider.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/PageProvider.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/PageProvider.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/PageProvider.java Wed Sep 19 15:00:15 2012
@@ -151,18 +151,37 @@ public class PageProvider implements Con
return this.lastReportedBPD;
}
- // Wish there were a more elegant way to do this in Java
- private int[] getColIndexAndColCount(int index) {
+ private static class Column {
+
+ final Page page;
+
+ final int pageIndex;
+
+ final int colIndex;
+
+ final int columnCount;
+
+ Column(Page page, int pageIndex, int colIndex, int columnCount) {
+ this.page = page;
+ this.pageIndex = pageIndex;
+ this.colIndex = colIndex;
+ this.columnCount = columnCount;
+ }
+
+ }
+
+ private Column getColumn(int index) {
int columnCount = 0;
int colIndex = startColumnOfCurrentElementList + index;
int pageIndex = -1;
+ Page page;
do {
colIndex -= columnCount;
pageIndex++;
- Page page = getPage(false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
+ page = getPage(false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
columnCount = page.getPageViewport().getCurrentSpan().getColumnCount();
} while (colIndex >= columnCount);
- return new int[] {colIndex, columnCount};
+ return new Column(page, pageIndex, colIndex, columnCount);
}
/**
@@ -173,22 +192,13 @@ public class PageProvider implements Con
* than, equal to or greater than the IPD of the following part
*/
public int compareIPDs(int index) {
- int columnCount = 0;
- int colIndex = startColumnOfCurrentElementList + index;
- int pageIndex = -1;
- Page page;
- do {
- colIndex -= columnCount;
- pageIndex++;
- page = getPage(false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
- columnCount = page.getPageViewport().getCurrentSpan().getColumnCount();
- } while (colIndex >= columnCount);
- if (colIndex + 1 < columnCount) {
+ Column column = getColumn(index);
+ if (column.colIndex + 1 < column.columnCount) {
// Next part is a column on same page => same IPD
return 0;
} else {
- Page nextPage = getPage(false, pageIndex + 1, RELTO_CURRENT_ELEMENT_LIST);
- return page.getPageViewport().getBodyRegion().getIPD()
+ Page nextPage = getPage(false, column.pageIndex + 1, RELTO_CURRENT_ELEMENT_LIST);
+ return column.page.getPageViewport().getBodyRegion().getIPD()
- nextPage.getPageViewport().getBodyRegion().getIPD();
}
}
@@ -199,7 +209,7 @@ public class PageProvider implements Con
* @return {@code true} if the break starts a new page
*/
boolean startPage(int index) {
- return getColIndexAndColCount(index)[0] == 0;
+ return getColumn(index).colIndex == 0;
}
/**
@@ -208,8 +218,8 @@ public class PageProvider implements Con
* @return {@code true} if the break ends a page
*/
boolean endPage(int index) {
- int[] colIndexAndColCount = getColIndexAndColCount(index);
- return colIndexAndColCount[0] == colIndexAndColCount[1] - 1;
+ Column column = getColumn(index);
+ return column.colIndex == column.columnCount - 1;
}
/**
@@ -219,7 +229,7 @@ public class PageProvider implements Con
* @return the number of columns
*/
int getColumnCount(int index) {
- return getColIndexAndColCount(index)[1];
+ return getColumn(index).columnCount;
}
/**
@@ -229,24 +239,12 @@ public class PageProvider implements Con
* @return the requested part index
*/
public int getStartingPartIndexForLastPage(int partCount) {
- int result = 0;
- int idx = 0;
- int pageIndex = 0;
- int colIndex = startColumnOfCurrentElementList;
- Page page = getPage(
- false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
- while (idx < partCount) {
- if ((colIndex >= page.getPageViewport().getCurrentSpan().getColumnCount())) {
- colIndex = 0;
- pageIndex++;
- page = getPage(
- false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
- result = idx;
- }
- colIndex++;
- idx++;
- }
- return result;
+ int lastPartIndex = partCount - 1;
+ return lastPartIndex - getColumn(lastPartIndex).colIndex;
+ }
+
+ Page getPageFromColumnIndex(int columnIndex) {
+ return getColumn(columnIndex).page;
}
/**
@@ -291,7 +289,9 @@ public class PageProvider implements Con
log.trace("last page requested: " + index);
}
}
- while (intIndex >= cachedPages.size()) {
+ if (intIndex > cachedPages.size()) {
+ throw new UnsupportedOperationException("Cannot handle holes in page cache");
+ } else if (intIndex == cachedPages.size()) {
if (log.isTraceEnabled()) {
log.trace("Caching " + index);
}
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Wed Sep 19 15:00:15 2012
@@ -649,6 +649,10 @@ public class LineLayoutManager extends I
log.trace("Restarting line breaking from index " + restartPosition.getIndex());
int parIndex = restartPosition.getLeafPos();
KnuthSequence paragraph = knuthParagraphs.get(parIndex);
+ if (paragraph instanceof Paragraph) {
+ ((Paragraph) paragraph).ignoreAtStart = 0;
+ isFirstInBlock = false;
+ }
paragraph.subList(0, restartPosition.getIndex() + 1).clear();
Iterator<KnuthElement> iter = paragraph.iterator();
while (iter.hasNext() && !iter.next().isBox()) {
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java Wed Sep 19 15:00:15 2012
@@ -39,6 +39,7 @@ import org.apache.fop.fo.properties.Keep
import org.apache.fop.layoutmgr.BlockLevelEventProducer;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.BreakElement;
+import org.apache.fop.layoutmgr.BreakOpportunity;
import org.apache.fop.layoutmgr.ConditionalElementListener;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthGlue;
@@ -62,7 +63,7 @@ import org.apache.fop.util.BreakUtil;
* the render background.
*/
public class TableLayoutManager extends BlockStackingLayoutManager
- implements ConditionalElementListener {
+ implements ConditionalElementListener, BreakOpportunity {
/**
* logging instance
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFDocument.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFDocument.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFDocument.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFDocument.java Wed Sep 19 15:00:15 2012
@@ -37,6 +37,7 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.pdf.StandardStructureAttributes.Table.Scope;
import org.apache.fop.pdf.xref.CrossReferenceStream;
import org.apache.fop.pdf.xref.CrossReferenceTable;
import org.apache.fop.pdf.xref.TrailerDictionary;
@@ -354,19 +355,20 @@ public class PDFDocument {
}
/**
- * Creates and returns a structure element.
- *
- * @param structureType the structure type of the new element (value for the
- * S entry)
- * @param parent the parent of the new structure element in the structure
- * hierarchy
- * @return a dictionary of type StructElem
+ * Adds the given element to the structure tree.
*/
- public PDFStructElem makeStructureElement(PDFName structureType, PDFObject parent) {
- PDFStructElem structElem = new PDFStructElem(parent, structureType);
+ public void registerStructureElement(PDFStructElem structElem) {
assignObjectNumber(structElem);
structureTreeElements.add(structElem);
- return structElem;
+ }
+
+ /**
+ * Assigns the given scope to the given element and adds it to the structure tree. The
+ * scope may not be added if it's not compatible with this document's PDF version.
+ */
+ public void registerStructureElement(PDFStructElem structElem, Scope scope) {
+ registerStructureElement(structElem);
+ versionController.addTableHeaderScopeAttribute(structElem, scope);
}
/**
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFEncoding.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFEncoding.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFEncoding.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFEncoding.java Wed Sep 19 15:00:15 2012
@@ -23,6 +23,9 @@ package org.apache.fop.pdf;
import java.util.Collections;
import java.util.Set;
+import org.apache.fop.fonts.CodePointMapping;
+import org.apache.fop.fonts.SingleByteEncoding;
+
/**
* Class representing an /Encoding object.
*
@@ -74,6 +77,38 @@ public class PDFEncoding extends PDFDict
}
/**
+ * Creates a PDFEncoding instance from a CodePointMapping instance.
+ * @param encoding the code point mapping (encoding)
+ * @param fontName ...
+ * @return the PDF Encoding dictionary (or a String with the predefined encoding)
+ */
+ static Object createPDFEncoding(SingleByteEncoding encoding, String fontName) {
+ //If encoding type is null, return null which causes /Encoding to be omitted.
+ if (encoding == null) {
+ return null;
+ }
+ String encodingName = null;
+ SingleByteEncoding baseEncoding;
+ if (fontName.indexOf("Symbol") >= 0) {
+ baseEncoding = CodePointMapping.getMapping(CodePointMapping.SYMBOL_ENCODING);
+ encodingName = baseEncoding.getName();
+ } else {
+ baseEncoding = CodePointMapping.getMapping(CodePointMapping.STANDARD_ENCODING);
+ }
+ PDFEncoding pdfEncoding = new PDFEncoding(encodingName);
+ PDFEncoding.DifferencesBuilder builder = pdfEncoding.createDifferencesBuilder();
+ PDFArray differences = builder.buildDifferencesArray(baseEncoding, encoding);
+ // TODO This method should not be returning an Object with two different outcomes
+ // resulting in subsequent `if (X instanceof Y)` statements.
+ if (differences.length() > 0) {
+ pdfEncoding.setDifferences(differences);
+ return pdfEncoding;
+ } else {
+ return encodingName;
+ }
+ }
+
+ /**
* Indicates whether a given encoding is one of the predefined encodings.
* @param name the encoding name (ex. "StandardEncoding")
* @return true if it is a predefined encoding
@@ -83,6 +118,15 @@ public class PDFEncoding extends PDFDict
}
/**
+ * Indicates whether the given encoding type is that of standard encoding
+ * @param name The encoding name
+ * @return Returns true if it is of type standard encoding
+ */
+ static boolean hasStandardEncoding(String encodingName) {
+ return encodingName.equals(STANDARD_ENCODING);
+ }
+
+ /**
* Creates and returns a new DifferencesBuilder instance for constructing the Differences
* array.
* @return the DifferencesBuilder
@@ -104,18 +148,44 @@ public class PDFEncoding extends PDFDict
*/
public class DifferencesBuilder {
- private PDFArray differences = new PDFArray();
private int currentCode = -1;
/**
+ * Creates an array containing the differences between two single-byte.
+ * font encodings.
+ * @param encodingA The first single-byte encoding
+ * @param encodingB The second single-byte encoding
+ * @return The PDFArray of differences between encodings
+ */
+ public PDFArray buildDifferencesArray(SingleByteEncoding encodingA,
+ SingleByteEncoding encodingB) {
+ PDFArray differences = new PDFArray();
+ int start = -1;
+ String[] baseNames = encodingA.getCharNameMap();
+ String[] charNameMap = encodingB.getCharNameMap();
+ for (int i = 0, ci = charNameMap.length; i < ci; i++) {
+ String basec = baseNames[i];
+ String c = charNameMap[i];
+ if (!basec.equals(c)) {
+ if (start != i) {
+ addDifference(i, differences);
+ start = i;
+ }
+ addName(c, differences);
+ start++;
+ }
+ }
+ return differences;
+ }
+
+ /**
* Start a new difference.
* @param code the starting code index inside the encoding
* @return this builder instance
*/
- public DifferencesBuilder addDifference(int code) {
+ private void addDifference(int code, PDFArray differences) {
this.currentCode = code;
- this.differences.add(new Integer(code));
- return this;
+ differences.add(Integer.valueOf(code));
}
/**
@@ -123,28 +193,11 @@ public class PDFEncoding extends PDFDict
* @param name the character name
* @return this builder instance
*/
- public DifferencesBuilder addName(String name) {
+ private void addName(String name, PDFArray differences) {
if (this.currentCode < 0) {
throw new IllegalStateException("addDifference(int) must be called first");
}
- this.differences.add(new PDFName(name));
- return this;
- }
-
- /**
- * Indicates whether any differences have been recorded.
- * @return true if there are differences.
- */
- public boolean hasDifferences() {
- return (this.differences.length() > 0);
- }
-
- /**
- * Creates and returns the PDFArray representing the Differences entry.
- * @return the Differences entry
- */
- public PDFArray toPDFArray() {
- return this.differences;
+ differences.add(new PDFName(name));
}
}
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFFactory.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFFactory.java Wed Sep 19 15:00:15 2012
@@ -44,9 +44,9 @@ import org.apache.xmlgraphics.java2d.col
import org.apache.xmlgraphics.xmp.Metadata;
import org.apache.fop.fonts.CIDFont;
-import org.apache.fop.fonts.CIDSubset;
import org.apache.fop.fonts.CodePointMapping;
import org.apache.fop.fonts.CustomFont;
+import org.apache.fop.fonts.EmbeddingMode;
import org.apache.fop.fonts.FontDescriptor;
import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.fonts.FontType;
@@ -1369,23 +1369,14 @@ public class PDFFactory {
} else {
cidMetrics = (CIDFont)metrics;
}
- PDFCIDSystemInfo sysInfo
- = new PDFCIDSystemInfo(cidMetrics.getRegistry(),
- cidMetrics.getOrdering(),
- cidMetrics.getSupplement());
- PDFCIDFont cidFont = new PDFCIDFont(subsetFontName,
- cidMetrics.getCIDType(),
- cidMetrics.getDefaultWidth(),
- getSubsetWidths(cidMetrics), sysInfo,
- (PDFCIDFontDescriptor)pdfdesc);
+ PDFCIDSystemInfo sysInfo = new PDFCIDSystemInfo(cidMetrics.getRegistry(),
+ cidMetrics.getOrdering(), cidMetrics.getSupplement());
+ PDFCIDFont cidFont = new PDFCIDFont(subsetFontName, cidMetrics.getCIDType(),
+ cidMetrics.getDefaultWidth(), getFontWidths(cidMetrics), sysInfo,
+ (PDFCIDFontDescriptor) pdfdesc);
getDocument().registerObject(cidFont);
-
- PDFCMap cmap = new PDFToUnicodeCMap(
- cidMetrics.getCIDSubset().getSubsetChars(),
- "fop-ucs-H",
- new PDFCIDSystemInfo("Adobe",
- "Identity",
- 0), false);
+ PDFCMap cmap = new PDFToUnicodeCMap(cidMetrics.getCIDSet().getChars(), "fop-ucs-H",
+ new PDFCIDSystemInfo("Adobe", "Identity", 0), false);
getDocument().registerObject(cmap);
((PDFFontType0)font).setCMAP(cmap);
((PDFFontType0)font).setDescendantFonts(cidFont);
@@ -1469,61 +1460,18 @@ public class PDFFactory {
/**
* Creates a PDFEncoding instance from a CodePointMapping instance.
* @param encoding the code point mapping (encoding)
- * @param fontNameHint ...
+ * @param fontName ...
* @return the PDF Encoding dictionary (or a String with the predefined encoding)
*/
- public Object createPDFEncoding(SingleByteEncoding encoding, String fontNameHint) {
- SingleByteEncoding baseEncoding;
- if (fontNameHint.indexOf("Symbol") >= 0) {
- baseEncoding = CodePointMapping.getMapping(
- CodePointMapping.SYMBOL_ENCODING);
- } else {
- baseEncoding = CodePointMapping.getMapping(
- CodePointMapping.STANDARD_ENCODING);
- }
- PDFEncoding pdfEncoding = new PDFEncoding(baseEncoding.getName());
- PDFEncoding.DifferencesBuilder builder
- = pdfEncoding.createDifferencesBuilder();
- int start = -1;
- String[] baseNames = baseEncoding.getCharNameMap();
- String[] charNameMap = encoding.getCharNameMap();
- for (int i = 0, ci = charNameMap.length; i < ci; i++) {
- String basec = baseNames[i];
- String c = charNameMap[i];
- if (!basec.equals(c)) {
- if (start != i) {
- builder.addDifference(i);
- start = i;
- }
- builder.addName(c);
- start++;
- }
- }
- if (builder.hasDifferences()) {
- pdfEncoding.setDifferences(builder.toPDFArray());
- return pdfEncoding;
- } else {
- return baseEncoding.getName();
- }
+ public Object createPDFEncoding(SingleByteEncoding encoding, String fontName) {
+ return PDFEncoding.createPDFEncoding(encoding, fontName);
}
- /**
- * Creates and returns a width array with the widths of all the characters in the subset.
- * @param cidFont the font
- * @return the width array
- */
- public PDFWArray getSubsetWidths(CIDFont cidFont) {
+ private PDFWArray getFontWidths(CIDFont cidFont) {
// Create widths for reencoded chars
PDFWArray warray = new PDFWArray();
- int[] widths = cidFont.getWidths();
- CIDSubset subset = cidFont.getCIDSubset();
- int[] tmpWidth = new int[subset.getSubsetSize()];
-
- for (int i = 0, c = subset.getSubsetSize(); i < c; i++) {
- int nwx = Math.max(0, subset.getGlyphIndexForSubsetIndex(i));
- tmpWidth[i] = widths[nwx];
- }
- warray.addEntry(0, tmpWidth);
+ int[] widths = cidFont.getCIDSet().getWidths();
+ warray.addEntry(0, widths);
return warray;
}
@@ -1591,13 +1539,13 @@ public class PDFFactory {
}
private void buildCIDSet(PDFFontDescriptor descriptor, CIDFont cidFont) {
- BitSet cidSubset = cidFont.getCIDSubset().getGlyphIndexBitSet();
- PDFStream cidSet = makeStream(null, true);
- ByteArrayOutputStream baout = new ByteArrayOutputStream(cidSubset.length() / 8 + 1);
+ BitSet cidSet = cidFont.getCIDSet().getGlyphIndices();
+ PDFStream pdfStream = makeStream(null, true);
+ ByteArrayOutputStream baout = new ByteArrayOutputStream(cidSet.length() / 8 + 1);
int value = 0;
- for (int i = 0, c = cidSubset.length(); i < c; i++) {
+ for (int i = 0, c = cidSet.length(); i < c; i++) {
int shift = i % 8;
- boolean b = cidSubset.get(i);
+ boolean b = cidSet.get(i);
if (b) {
value |= 1 << 7 - shift;
}
@@ -1608,8 +1556,8 @@ public class PDFFactory {
}
baout.write(value);
try {
- cidSet.setData(baout.toByteArray());
- descriptor.setCIDSet(cidSet);
+ pdfStream.setData(baout.toByteArray());
+ descriptor.setCIDSet(pdfStream);
} catch (IOException ioe) {
log.error(
"Failed to write CIDSet [" + cidFont + "] "
@@ -1640,14 +1588,16 @@ public class PDFFactory {
if (desc.getFontType() == FontType.TYPE0) {
MultiByteFont mbfont = (MultiByteFont) font;
FontFileReader reader = new FontFileReader(in);
-
- TTFSubSetFile subset = new TTFSubSetFile();
- subset.readFont(reader, mbfont.getTTCName(), mbfont.getUsedGlyphs());
- byte[] subsetFont = subset.getFontSubset();
- // Only TrueType CID fonts are supported now
-
- embeddedFont = new PDFTTFStream(subsetFont.length);
- ((PDFTTFStream) embeddedFont).setData(subsetFont, subsetFont.length);
+ byte[] fontBytes;
+ if (font.getEmbeddingMode() == EmbeddingMode.FULL) {
+ fontBytes = reader.getAllBytes();
+ } else {
+ TTFSubSetFile ttfFile = new TTFSubSetFile();
+ ttfFile.readFont(reader, mbfont.getTTCName(), mbfont.getUsedGlyphs());
+ fontBytes = ttfFile.getFontSubset();
+ }
+ embeddedFont = new PDFTTFStream(fontBytes.length);
+ ((PDFTTFStream) embeddedFont).setData(fontBytes, fontBytes.length);
} else if (desc.getFontType() == FontType.TYPE1) {
PFBParser parser = new PFBParser();
PFBData pfb = parser.parsePFB(in);
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFFont.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFFont.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFFont.java Wed Sep 19 15:00:15 2012
@@ -70,7 +70,7 @@ public class PDFFont extends PDFDictiona
* @param encoding the encoding
*/
public void setEncoding(String encoding) {
- if (encoding != null) {
+ if (encoding != null && !PDFEncoding.hasStandardEncoding(encoding)) {
put("Encoding", new PDFName(encoding));
}
}
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFProfile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFProfile.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFProfile.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFProfile.java Wed Sep 19 15:00:15 2012
@@ -202,7 +202,8 @@ public class PDFProfile {
PDFDictionary markInfo = getDocument().getRoot().getMarkInfo();
if (markInfo == null) {
throw new PDFConformanceException(format(
- "{0} requires the MarkInfo dictionary to be present", getPDFAMode()));
+ "{0} requires that the accessibility option in the configuration file be enabled",
+ getPDFAMode()));
}
if (!Boolean.TRUE.equals(markInfo.get("Marked"))) {
throw new PDFConformanceException(format(err,
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFStructElem.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFStructElem.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFStructElem.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFStructElem.java Wed Sep 19 15:00:15 2012
@@ -26,14 +26,16 @@ import java.util.List;
import java.util.Locale;
import org.apache.fop.accessibility.StructureTreeElement;
+import org.apache.fop.pdf.StandardStructureAttributes.Table;
import org.apache.fop.util.LanguageTags;
/**
* Class representing a PDF Structure Element.
*/
-public class PDFStructElem extends PDFDictionary implements StructureTreeElement, CompressedObject {
+public class PDFStructElem extends StructureHierarchyMember
+ implements StructureTreeElement, CompressedObject {
- private static final PDFName TABLE = new PDFName("Table");
+ private StructureType structureType;
private PDFStructElem parentElement;
@@ -50,12 +52,17 @@ public class PDFStructElem extends PDFDi
* @param parent parent of this element
* @param structureType the structure type of this element
*/
- PDFStructElem(PDFObject parent, PDFName structureType) {
+ public PDFStructElem(PDFObject parent, StructureType structureType) {
+ this(parent);
+ this.structureType = structureType;
+ put("S", structureType.getName());
+ setParent(parent);
+ }
+
+ private PDFStructElem(PDFObject parent) {
if (parent instanceof PDFStructElem) {
parentElement = (PDFStructElem) parent;
}
- put("S", structureType);
- setParent(parent);
}
/**
@@ -80,6 +87,7 @@ public class PDFStructElem extends PDFDi
*
* @param kid element to be added
*/
+ @Override
public void addKid(PDFObject kid) {
if (kids == null) {
kids = new ArrayList<PDFObject>();
@@ -113,8 +121,8 @@ public class PDFStructElem extends PDFDi
*
* @return the value of the S entry
*/
- public PDFName getStructureType() {
- return (PDFName) get("S");
+ public StructureType getStructureType() {
+ return structureType;
}
/**
@@ -201,7 +209,7 @@ public class PDFStructElem extends PDFDi
private void setTableAttributeRowColumnSpan(String typeSpan, int span) {
PDFDictionary attribute = new PDFDictionary();
- attribute.put("O", TABLE);
+ attribute.put("O", Table.NAME);
attribute.put(typeSpan, span);
if (attributes == null) {
attributes = new ArrayList<PDFDictionary>(2);
@@ -228,13 +236,8 @@ public class PDFStructElem extends PDFDi
}
}
- /**
- * Constructor
- * @param parent -
- * @param name -
- */
- public Placeholder(PDFObject parent, String name) {
- super(parent, new PDFName(name));
+ public Placeholder(PDFObject parent) {
+ super(parent);
}
}
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFStructTreeRoot.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFStructTreeRoot.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFStructTreeRoot.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/PDFStructTreeRoot.java Wed Sep 19 15:00:15 2012
@@ -22,7 +22,7 @@ package org.apache.fop.pdf;
/**
* Class representing a PDF /StructTreeRoot dictionary.
*/
-public class PDFStructTreeRoot extends PDFDictionary {
+public class PDFStructTreeRoot extends StructureHierarchyMember {
/**
* Creates a new /StructTreeRoot dictionary.
@@ -49,6 +49,7 @@ public class PDFStructTreeRoot extends P
*
* @param kid an object to be added to the K entry
*/
+ @Override
public void addKid(PDFObject kid) {
getKids().add(kid);
}
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/VersionController.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/VersionController.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/VersionController.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/pdf/VersionController.java Wed Sep 19 15:00:15 2012
@@ -19,6 +19,8 @@
package org.apache.fop.pdf;
+import org.apache.fop.pdf.StandardStructureAttributes.Table.Scope;
+
/**
* An abstraction that controls the mutability of the PDF version for a document.
*/
@@ -47,6 +49,8 @@ public abstract class VersionController
*/
public abstract void setPDFVersion(Version version);
+ abstract void addTableHeaderScopeAttribute(PDFStructElem th, Scope scope);
+
@Override
public String toString() {
return version.toString();
@@ -67,6 +71,13 @@ public abstract class VersionController
public void setPDFVersion(Version version) {
throw new IllegalStateException("Cannot change the version of this PDF document.");
}
+
+ @Override
+ void addTableHeaderScopeAttribute(PDFStructElem th, Scope scope) {
+ if (super.version.compareTo(Version.V1_4) > 0) {
+ Scope.addScopeAttribute(th, scope);
+ }
+ }
}
/**
@@ -91,6 +102,12 @@ public abstract class VersionController
doc.getRoot().setVersion(version);
}
}
+
+ @Override
+ void addTableHeaderScopeAttribute(PDFStructElem th, Scope scope) {
+ setPDFVersion(Version.V1_5);
+ Scope.addScopeAttribute(th, scope);
+ }
}
/**
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java Wed Sep 19 15:00:15 2012
@@ -318,7 +318,8 @@ public class AFPDocumentHandler extends
case IN_PAGE_HEADER:
String name = aps.getName();
String value = aps.getValue();
- dataStream.createTagLogicalElement(name, value);
+ int encoding = aps.getEncoding();
+ dataStream.createTagLogicalElement(name, value, encoding);
break;
default:
throw new IFException(
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/AFPFontConfig.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/AFPFontConfig.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/AFPFontConfig.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/AFPFontConfig.java Wed Sep 19 15:00:15 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/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java Wed Sep 19 15:00:15 2012
@@ -144,6 +144,12 @@ public class AFPExtensionHandler extends
if (placement != null && placement.length() > 0) {
pageSetupExtn.setPlacement(ExtensionPlacement.fromXMLValue(placement));
}
+
+ String encoding = lastAttributes.getValue("encoding");
+ if (encoding != null && pageSetupExtn != null) {
+ pageSetupExtn.setEncoding(Integer.parseInt(encoding));
+ }
+
if (content.length() > 0 && pageSetupExtn != null) {
pageSetupExtn.setContent(content.toString());
content.setLength(0); //Reset text buffer (see characters())
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java Wed Sep 19 15:00:15 2012
@@ -23,6 +23,8 @@ import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
+import org.apache.fop.afp.modca.TagLogicalElement;
+
/**
* This is the pass-through value object for the AFP extension.
*/
@@ -48,6 +50,27 @@ public class AFPPageSetup extends AFPExt
protected ExtensionPlacement placement = ExtensionPlacement.DEFAULT;
/**
+ * the CCSID character set encoding
+ */
+ protected int encoding = TagLogicalElement.State.ENCODING_NONE;
+
+ /**
+ *
+ * @return CCSID character set encoding
+ */
+ public int getEncoding() {
+ return encoding;
+ }
+
+ /**
+ *
+ * @param encoding CCSID character set encoding
+ */
+ public void setEncoding(int encoding) {
+ this.encoding = encoding;
+ }
+
+ /**
* Default constructor.
*
* @param elementName the name of the setup code object, may be null
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java Wed Sep 19 15:00:15 2012
@@ -35,6 +35,7 @@ import org.apache.fop.fo.extensions.Exte
*/
public class AFPPageSetupElement extends AbstractAFPExtensionObject {
+ private static final String ATT_ENCODING = "encoding";
private static final String ATT_SRC = "src";
/**
@@ -105,6 +106,16 @@ public class AFPPageSetupElement extends
} else {
missingPropertyError(AFPPageSetup.ATT_VALUE);
}
+ attr = attlist.getValue(ATT_ENCODING);
+ if (attr != null) {
+ try {
+ pageSetup.setEncoding(Integer.parseInt(attr));
+ } catch (NumberFormatException nfe) {
+ invalidPropertyValueError(ATT_ENCODING, attr, nfe);
+ }
+
+ }
+
}
String placement = attlist.getValue(AFPPageSetup.ATT_PLACEMENT);
if (placement != null && placement.length() > 0) {
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java Wed Sep 19 15:00:15 2012
@@ -84,7 +84,7 @@ public abstract class AbstractBitmapDocu
super(context);
//Set target resolution
int dpi = Math.round(context.getUserAgent().getTargetResolution());
- getSettings().getWriterParams().setResolution(dpi);
+ getSettings().setResolution(dpi);
Map renderingOptions = getUserAgent().getRendererOptions();
setTargetBitmapSize((Dimension)renderingOptions.get(TARGET_BITMAP_SIZE));
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/BitmapRenderingSettings.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/BitmapRenderingSettings.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/BitmapRenderingSettings.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/BitmapRenderingSettings.java Wed Sep 19 15:00:15 2012
@@ -107,4 +107,27 @@ public class BitmapRenderingSettings ext
return this.qualityRendering;
}
+ /**
+ * Sets the compression method for the image writer.
+ * @param compressionMethod the compression method name
+ */
+ public void setCompressionMethod(String compressionMethod) {
+ writerParams.setCompressionMethod(compressionMethod);
+ }
+
+ /**
+ * Returns the compression method being used by the image writer.
+ * @return the compression method in use
+ */
+ public String getCompressionMethod() {
+ return writerParams.getCompressionMethod();
+ }
+
+ /**
+ * Sets the resolution of the output image.
+ * @param dpi the dots-per-inch of the image
+ */
+ public void setResolution(int dpi) {
+ writerParams.setResolution(dpi);
+ }
}
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java Wed Sep 19 15:00:15 2012
@@ -19,6 +19,8 @@
package org.apache.fop.render.bitmap;
+import org.apache.xmlgraphics.image.writer.ResolutionUnit;
+
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererConfigParser;
import org.apache.fop.render.intermediate.IFContext;
@@ -32,6 +34,7 @@ public class TIFFDocumentHandler extends
TIFFDocumentHandler(IFContext context) {
super(context);
+ getSettings().getWriterParams().setResolutionUnit(ResolutionUnit.CENTIMETER);
}
/** {@inheritDoc} */
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java Wed Sep 19 15:00:15 2012
@@ -38,7 +38,6 @@ import org.apache.commons.logging.Log;
import org.apache.xmlgraphics.image.GraphicsUtil;
import org.apache.xmlgraphics.image.rendered.FormatRed;
import org.apache.xmlgraphics.image.writer.ImageWriter;
-import org.apache.xmlgraphics.image.writer.ImageWriterParams;
import org.apache.xmlgraphics.image.writer.ImageWriterRegistry;
import org.apache.xmlgraphics.image.writer.MultiImageWriter;
@@ -47,9 +46,9 @@ import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.render.java2d.Java2DRenderer;
-import static org.apache.fop.render.bitmap.TIFFCompressionValues.CCITT_T4;
-import static org.apache.fop.render.bitmap.TIFFCompressionValues.CCITT_T6;
-import static org.apache.fop.render.bitmap.TIFFCompressionValues.PACKBITS;
+import static org.apache.fop.render.bitmap.TIFFCompressionValue.CCITT_T4;
+import static org.apache.fop.render.bitmap.TIFFCompressionValue.CCITT_T6;
+import static org.apache.fop.render.bitmap.TIFFCompressionValue.PACKBITS;
/**
* <p>
@@ -74,11 +73,7 @@ import static org.apache.fop.render.bitm
*/
public class TIFFRenderer extends Java2DRenderer {
- /** ImageWriter parameters */
- private ImageWriterParams writerParams;
-
- /** Image Type as parameter for the BufferedImage constructor (see BufferedImage.TYPE_*) */
- private int bufferedImageType = BufferedImage.TYPE_INT_ARGB;
+ private BitmapRenderingSettings imageSettings;
private OutputStream outputStream;
@@ -94,11 +89,11 @@ public class TIFFRenderer extends Java2D
*/
public TIFFRenderer(FOUserAgent userAgent) {
super(userAgent);
- writerParams = new ImageWriterParams();
- writerParams.setCompressionMethod(PACKBITS.getName());
-
+ imageSettings = new BitmapRenderingSettings();
+ imageSettings.setCompressionMethod(PACKBITS.getName());
+ imageSettings.setBufferedImageType(BufferedImage.TYPE_INT_ARGB);
int dpi = Math.round(userAgent.getTargetResolution());
- writerParams.setResolution(dpi);
+ imageSettings.setResolution(dpi);
}
/** {@inheritDoc} */
@@ -129,7 +124,7 @@ public class TIFFRenderer extends Java2D
// Write all pages/images
while (pageImagesItr.hasNext()) {
RenderedImage img = (RenderedImage) pageImagesItr.next();
- multiWriter.writeImage(img, writerParams);
+ multiWriter.writeImage(img, imageSettings.getWriterParams());
}
} finally {
multiWriter.close();
@@ -139,7 +134,7 @@ public class TIFFRenderer extends Java2D
if (pageImagesItr.hasNext()) {
renderedImage = (RenderedImage) pageImagesItr.next();
}
- writer.writeImage(renderedImage, outputStream, writerParams);
+ writer.writeImage(renderedImage, outputStream, imageSettings.getWriterParams());
if (pageImagesItr.hasNext()) {
BitmapRendererEventProducer eventProducer
= BitmapRendererEventProducer.Provider.get(
@@ -156,7 +151,7 @@ public class TIFFRenderer extends Java2D
/** {@inheritDoc} */
protected BufferedImage getBufferedImage(int bitmapWidth, int bitmapHeight) {
- return new BufferedImage(bitmapWidth, bitmapHeight, bufferedImageType);
+ return new BufferedImage(bitmapWidth, bitmapHeight, imageSettings.getBufferedImageType());
}
/** Private inner class to lazy page rendering. */
@@ -195,7 +190,7 @@ public class TIFFRenderer extends Java2D
throw new NoSuchElementException(e.getMessage());
}
- TIFFCompressionValues compression = TIFFCompressionValues.getValue(writerParams.getCompressionMethod());
+ TIFFCompressionValue compression = TIFFCompressionValue.getType(imageSettings.getCompressionMethod());
if (compression == CCITT_T4 || compression == CCITT_T6) {
return pageImage;
} else {
@@ -226,11 +221,14 @@ public class TIFFRenderer extends Java2D
/** @param bufferedImageType an image type */
public void setBufferedImageType(int bufferedImageType) {
- this.bufferedImageType = bufferedImageType;
+ imageSettings.setBufferedImageType(bufferedImageType);
}
- /** @return image writer parameters */
- public ImageWriterParams getWriterParams() {
- return writerParams;
+ /**
+ * Returns the settings for the image rendering.
+ * @return the image rendering settings
+ */
+ public BitmapRenderingSettings getRenderingSettings() {
+ return imageSettings;
}
}
Modified: xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java?rev=1387628&r1=1387627&r2=1387628&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java (original)
+++ xmlgraphics/fop/branches/Temp_XGC_URI_Resolution/src/java/org/apache/fop/render/bitmap/TIFFRendererConfig.java Wed Sep 19 15:00:15 2012
@@ -23,21 +23,24 @@ import java.util.EnumMap;
import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.xmlgraphics.util.MimeConstants;
-
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.MimeConstants;
import org.apache.fop.fonts.DefaultFontConfig;
import org.apache.fop.fonts.DefaultFontConfig.DefaultFontConfigParser;
import org.apache.fop.render.RendererConfigOption;
+import static org.apache.fop.render.bitmap.TIFFCompressionValue.PACKBITS;
+
/**
* The renderer configuration object for the TIFF renderer.
*/
public final class TIFFRendererConfig extends BitmapRendererConfig {
public enum TIFFRendererOption implements RendererConfigOption {
- COMPRESSION("compression", TIFFCompressionValues.PACKBITS);
+ COMPRESSION("compression", PACKBITS),
+ /** option to encode one row per strip or a all rows in a single strip*/
+ SINGLE_STRIP("single-strip", Boolean.FALSE);
private final String name;
private final Object defaultValue;
@@ -63,8 +66,16 @@ public final class TIFFRendererConfig ex
super(fontConfig);
}
- public TIFFCompressionValues getCompressionType() {
- return (TIFFCompressionValues) params.get(TIFFRendererOption.COMPRESSION);
+ public TIFFCompressionValue getCompressionType() {
+ return (TIFFCompressionValue) params.get(TIFFRendererOption.COMPRESSION);
+ }
+
+ /**
+ * @return True if all rows are contained in a single strip, False each strip contains one row or null
+ * if not set.
+ */
+ public Boolean isSingleStrip() {
+ return (Boolean) params.get(TIFFRendererOption.SINGLE_STRIP);
}
/**
@@ -92,9 +103,10 @@ public final class TIFFRendererConfig ex
.parse(cfg, userAgent.validateStrictly()));
super.build(config, userAgent, cfg);
if (cfg != null) {
- setParam(TIFFRendererOption.COMPRESSION,
- TIFFCompressionValues.getValue(getValue(cfg,
- TIFFRendererOption.COMPRESSION)));
+ setParam(TIFFRendererOption.COMPRESSION,
+ TIFFCompressionValue.getType(getValue(cfg, TIFFRendererOption.COMPRESSION)));
+ setParam(TIFFRendererOption.SINGLE_STRIP, Boolean.valueOf(getValue(cfg,
+ TIFFRendererOption.SINGLE_STRIP)));
}
return config;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org