}
/**
- * Returns the destination file path of the external resource group file
+ * Returns the URI of the external resource group.
*
- * @return the destination file path of the external resource group file
+ * @return the destination URI of the external resource group
*/
- public URI getExternalUri() {
+ public URI getExternalURI() {
return this.extUri;
}
/**
- * Sets the external destination of the resource
+ * Sets the URI of the external resource group.
*
- * @param filePath the external resource group file
+ * @param filePath the URI of the external resource group
*/
public void setExternalUri(URI uri) {
this.extUri = uri;
import org.apache.fop.afp.modca.ResourceGroup;
import org.apache.fop.afp.modca.StreamedResourceGroup;
-import org.apache.fop.apps.io.TempResourceURIGenerator;
import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.TempResourceURIGenerator;
/**
* Manages the streaming of the AFP output
return null;
}
if (level.isExternal()) {
- URI uri = level.getExternalUri();
+ URI uri = level.getExternalURI();
if (uri == null) {
LOG.warn("No file path provided for external resource, using default.");
uri = defaultResourceGroupUri;
}
this.codePage = codePage;
this.encoding = encoding;
- this.encoder = CharactersetEncoder.newInstance(encoding, charsetType);
+ this.encoder = charsetType.getEncoder(encoding);
this.accessor = accessor;
this.characterSetOrientations = new HashMap<String, CharacterSetOrientation>(4);
import org.apache.fop.afp.AFPEventProducer;
import org.apache.fop.afp.util.AFPResourceAccessor;
import org.apache.fop.afp.util.StructuredFieldReader;
+import org.apache.fop.apps.io.InternalResourceResolver;
import org.apache.fop.fonts.Typeface;
/**
throws IOException {
URI uri;
try {
- uri = new URI(uriStr.trim());
+ uri = InternalResourceResolver.cleanURI(uriStr.trim());
} catch (URISyntaxException e) {
throw new MalformedURLException("Invalid uri: " + uriStr + " (" + e.getMessage() + ")");
}
package org.apache.fop.afp.fonts;
+import org.apache.fop.afp.fonts.CharactersetEncoder.DefaultEncoder;
+import org.apache.fop.afp.fonts.CharactersetEncoder.EbcdicDoubleByteLineDataEncoder;
+
/**
* An enumeration of AFP characterset types.
*/
public enum CharacterSetType {
/** Double byte character sets; these do NOT have the shift-in;shift-out operators */
- DOUBLE_BYTE,
+ DOUBLE_BYTE {
+ @Override
+ CharactersetEncoder getEncoder(String encoding) {
+ return new DefaultEncoder(encoding, true);
+ }
+ },
/** Double byte character sets; these can have the shift-in;shift-out operators */
- DOUBLE_BYTE_LINE_DATA,
- SINGLE_BYTE;
+ DOUBLE_BYTE_LINE_DATA {
+ @Override
+ CharactersetEncoder getEncoder(String encoding) {
+ return new EbcdicDoubleByteLineDataEncoder(encoding);
+ }
+ },
+ SINGLE_BYTE {
+ @Override
+ CharactersetEncoder getEncoder(String encoding) {
+ return new DefaultEncoder(encoding, false);
+ }
+ };
+
+ /**
+ * Returns the character-set encoder
+ *
+ * @param encoding
+ * @return
+ */
+ abstract CharactersetEncoder getEncoder(String encoding);
}
*/
public static EncodedChars encodeSBCS(CharSequence chars, String encoding)
throws CharacterCodingException {
- CharactersetEncoder encoder = newInstance(encoding, CharacterSetType.SINGLE_BYTE);
+ CharactersetEncoder encoder = CharacterSetType.SINGLE_BYTE.getEncoder(encoding);
return encoder.encode(chars);
}
* sequence it will return its EBCDIC code-point, however, the "Shift In - Shift Out" operators
* are removed from the sequence of bytes. These are only used in Line Data.
*/
- private static final class EbcdicDoubleByteLineDataEncoder extends CharactersetEncoder {
- private EbcdicDoubleByteLineDataEncoder(String encoding) {
+ static final class EbcdicDoubleByteLineDataEncoder extends CharactersetEncoder {
+ EbcdicDoubleByteLineDataEncoder(String encoding) {
super(encoding);
}
@Override
* the primary format for most Latin character sets. This can also be used for Unicode double-
* byte character sets (DBCS).
*/
- private static final class DefaultEncoder extends CharactersetEncoder {
+ static final class DefaultEncoder extends CharactersetEncoder {
private final boolean isDBCS;
- private DefaultEncoder(String encoding, boolean isDBCS) {
+ DefaultEncoder(String encoding, boolean isDBCS) {
super(encoding);
this.isDBCS = isDBCS;
}
}
}
- /**
- * Returns an new instance of a {@link CharactersetEncoder}.
- *
- * @param encoding the encoding for the underlying character encoder
- * @param isEbcdicDBCS whether or not this wraps a double-byte EBCDIC code page.
- * @return the CharactersetEncoder
- */
- static CharactersetEncoder newInstance(String encoding, CharacterSetType charsetType) {
- switch (charsetType) {
- case DOUBLE_BYTE_LINE_DATA:
- return new EbcdicDoubleByteLineDataEncoder(encoding);
- case DOUBLE_BYTE:
- return new DefaultEncoder(encoding, true);
- default:
- return new DefaultEncoder(encoding, false);
- }
- }
-
/**
* A container for encoded character bytes
*/
import java.net.URI;
-import org.apache.fop.apps.io.ResourceResolver;
import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.ResourceResolver;
+import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.FontCacheManager;
import org.apache.fop.fonts.FontCacheManagerFactory;
import org.apache.fop.fonts.FontDetector;
private static FontManager createFontManager(URI defaultBaseUri, ResourceResolver resourceResolver,
FontDetector fontDetector, FontCacheManager fontCacheManager) {
- return new FontManager(new InternalResourceResolver(defaultBaseUri, resourceResolver), fontDetector,
- fontCacheManager);
+ InternalResourceResolver internalResolver = ResourceResolverFactory.createInternalResourceResolver(
+ defaultBaseUri, resourceResolver);
+ return new FontManager(internalResolver, fontDetector, fontCacheManager);
}
}
* @return A {@link javax.xml.transform.Source} object, or null if the URI
* cannot be resolved.
*/
- public Source resolveURI(String uri) {
- // TODO: What do we want to do when resources aren't found???
+ public StreamSource resolveURI(String uri) {
+ // TODO: What do we want to do when resources aren't found??? We also need to remove this
+ // method entirely
try {
// Have to do this so we can resolve data URIs
- Source src = new StreamSource(resourceResolver.getResource(uri));
+ StreamSource src = new StreamSource(resourceResolver.getResource(uri));
src.setSystemId(uri);
return src;
} catch (URISyntaxException use) {
import org.apache.xmlgraphics.util.UnitConv;
import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.ElementMappingRegistry;
import org.apache.fop.fonts.FontManager;
private FopFactory(FopFactoryConfig config) {
this.config = config;
- this.resolver = new InternalResourceResolver(config.getBaseURI(), config.getResourceResolver());
+ this.resolver = ResourceResolverFactory.createInternalResourceResolver(config.getBaseURI(),
+ config.getResourceResolver());
this.elementMappingRegistry = new ElementMappingRegistry(this);
this.colorSpaceCache = new ColorSpaceCache(resolver);
this.rendererFactory = new RendererFactory(config.preferRenderer());
*/
public class InternalResourceResolver {
private final URI baseUri;
- private final ResourceResolver uriResolver;
+ private final ResourceResolver resourceResolver;
private final DataURIResolver dataSchemeResolver = new DataURIResolver();
/**
* @param baseUri the base URI from which to resolve relative URIs
- * @param uriResolver the resolver to delegate to
+ * @param resourceResolver the resolver to delegate to
*/
- public InternalResourceResolver(URI baseUri, ResourceResolver uriResolver) {
+ InternalResourceResolver(URI baseUri, ResourceResolver resourceResolver) {
this.baseUri = baseUri;
- this.uriResolver = uriResolver;
+ this.resourceResolver = resourceResolver;
}
/**
if (uri.getScheme() != null && uri.getScheme().startsWith("data")) {
return new Resource(resolveDataURI(uri.toASCIIString()));
}
- return uriResolver.getResource(resolveFromBase(uri));
+ return resourceResolver.getResource(resolveFromBase(uri));
}
/**
* @throws IOException if an I/O error occurrred
*/
public OutputStream getOutputStream(URI uri) throws IOException {
- return uriResolver.getOutputStream(resolveFromBase(uri));
+ return resourceResolver.getOutputStream(resolveFromBase(uri));
}
/**
import java.io.OutputStream;
import java.net.URI;
+/**
+ * Implementations of this resource resolver allow FOP users to control the URI resolution
+ * mechanism. All resource and output stream acquisition goes through this when its implementation
+ * is given to the {@link org.apache.fop.apps.EnvironmentProfile}.
+ */
public interface ResourceResolver {
+ /**
+ * Get a resource given the URI pointing to said resource.
+ *
+ * @param uri the resource URI
+ * @return the resource
+ * @throws IOException if an I/O error occured during resource acquisition
+ */
Resource getResource(URI uri) throws IOException;
+ /**
+ * Gets an output stream of a given URI.
+ *
+ * @param uri the output stream URI
+ * @return the output stream
+ * @throws IOException if an I/O error occured while creating an output stream
+ */
OutputStream getOutputStream(URI uri) throws IOException;
}
import java.util.HashMap;
import java.util.Map;
+/**
+ * A factory class for {@link ResourceResolver}s.
+ */
public final class ResourceResolverFactory {
private ResourceResolverFactory() {
}
+ /**
+ * Returns the default resource resolver, this is most basic resolver which can be used when
+ * no there are no I/O or file access restrictions.
+ *
+ * @return the default resource resolver
+ */
public static ResourceResolver createDefaultResourceResolver() {
return DefaultResourceResolver.INSTANCE;
}
- public static ResourceResolver createTempAwareResourceResolver(TempResourceResolver tempResourceResolver,
- ResourceResolver defaultResourceResolver) {
- return new TempAwareResourceResolver(tempResourceResolver, defaultResourceResolver);
+ /**
+ * A helper merthod that creates an internal resource resolver using the default resover:
+ * {@link ResourceResolverFactory#createDefaultResourceResolver()}.
+ *
+ * @param baseURI the base URI from which to resolve URIs
+ * @return the default internal resource resolver
+ */
+ public static InternalResourceResolver createDefaultInternalResourceResolver(URI baseURI) {
+ return new InternalResourceResolver(baseURI, createDefaultResourceResolver());
}
- public static InternalResourceResolver createDefaultWrapper() {
- // Not sure if this is the right place for this, but I don't have any better ideas as of yet
- URI thisUri = new File(".").getAbsoluteFile().toURI();
- return new InternalResourceResolver(thisUri, new DefaultResourceResolver());
+ /**
+ * Creates an interal resource resolver given a base URI and a resource resolver.
+ *
+ * @param baseURI the base URI from which to resolve URIs
+ * @param resolver the resource resolver
+ * @return the internal resource resolver
+ */
+ public static InternalResourceResolver createInternalResourceResolver(URI baseURI,
+ ResourceResolver resolver) {
+ return new InternalResourceResolver(baseURI, resolver);
+ }
+
+ /**
+ * Creates a temporary-resource-schema aware resource resolver. Temporary resource URIs are
+ * created by {@link TempResourceURIGenerator}.
+ *
+ * @param tempResourceResolver the temporary-resource-schema resolver to use
+ * @param defaultResourceResolver the default resource resolver to use
+ * @return the ressource resolver
+ */
+ public static ResourceResolver createTempAwareResourceResolver(
+ TempResourceResolver tempResourceResolver,
+ ResourceResolver defaultResourceResolver) {
+ return new TempAwareResourceResolver(tempResourceResolver, defaultResourceResolver);
}
public static SchemaAwareResourceResolverBuilder createSchemaAwareResourceResolverBuilder(
return new SchemaAwareResourceResolverBuilderImpl(defaultResolver);
}
-
-
private static final class DefaultResourceResolver implements ResourceResolver {
private static final ResourceResolver INSTANCE = new DefaultResourceResolver();
private final TempAwareResourceResolver delegate;
- private DefaultResourceResolver() {
- delegate = new TempAwareResourceResolver(new DefaultTempResourceResolver(),
+ private DefaultResourceResolver() {
+ delegate = new TempAwareResourceResolver(new DefaultTempResourceResolver(),
new NormalResourceResolver());
}
public OutputStream getOutputStream(String id) throws IOException {
File file = getTempFile(id);
- // TODO handle error
file.createNewFile();
return new FileOutputStream(file);
}
private final ResourceResolver defaultResolver;
- private SchemaAwareResourceResolver(Map<String, ResourceResolver> schemaHandlingResourceResolvers,
+ private SchemaAwareResourceResolver(
+ Map<String, ResourceResolver> schemaHandlingResourceResolvers,
ResourceResolver defaultResolver) {
this.schemaHandlingResourceResolvers = schemaHandlingResourceResolvers;
this.defaultResolver = defaultResolver;
}
private static final class CompletedSchemaAwareResourceResolverBuilder
- implements SchemaAwareResourceResolverBuilder {
+ implements SchemaAwareResourceResolverBuilder {
private static final SchemaAwareResourceResolverBuilder INSTANCE
= new CompletedSchemaAwareResourceResolverBuilder();
}
private static final class ActiveSchemaAwareResourceResolverBuilder
- implements SchemaAwareResourceResolverBuilder {
+ implements SchemaAwareResourceResolverBuilder {
private final Map<String, ResourceResolver> schemaHandlingResourceResolvers
= new HashMap<String, ResourceResolver>();
this.defaultResolver = defaultResolver;
}
- public void registerResourceResolverForSchema(String schema, ResourceResolver resourceResolver) {
+ public void registerResourceResolverForSchema(String schema,
+ ResourceResolver resourceResolver) {
schemaHandlingResourceResolvers.put(schema, resourceResolver);
}
}
private static final class SchemaAwareResourceResolverBuilderImpl
- implements SchemaAwareResourceResolverBuilder {
+ implements SchemaAwareResourceResolverBuilder {
private SchemaAwareResourceResolverBuilder delegate;
this.delegate = new ActiveSchemaAwareResourceResolverBuilder(defaultResolver);
}
- public void registerResourceResolverForSchema(String schema, ResourceResolver resourceResolver) {
+ public void registerResourceResolverForSchema(String schema,
+ ResourceResolver resourceResolver) {
delegate.registerResourceResolverForSchema(schema, resourceResolver);
}
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.io.InternalResourceResolver;
import org.apache.fop.apps.io.ResourceResolver;
+import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.substitute.FontSubstitutions;
import org.apache.fop.fonts.substitute.FontSubstitutionsConfigurator;
import org.apache.fop.util.LogUtil;
try {
URI fontBase = InternalResourceResolver.getBaseURI(cfg.getChild("font-base").getValue(
null));
- fontManager.setResourceResolver(new InternalResourceResolver(
+ fontManager.setResourceResolver(ResourceResolverFactory.createInternalResourceResolver(
defaultBaseUri.resolve(fontBase), resourceResolver));
} catch (URISyntaxException use) {
LogUtil.handleException(log, use, true);
}
} else {
- fontManager.setResourceResolver(new InternalResourceResolver(defaultBaseUri, resourceResolver));
+ fontManager.setResourceResolver(ResourceResolverFactory.createInternalResourceResolver(
+ defaultBaseUri, resourceResolver));
}
// [GA] permit configuration control over base14 kerning; without this,
package org.apache.fop.render.pdf;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.apps.io.InternalResourceResolver;
import org.apache.fop.fonts.DefaultFontConfig;
import org.apache.fop.fonts.DefaultFontConfig.DefaultFontConfigParser;
import org.apache.fop.pdf.PDFAMode;
return (PDFEncryptionParams) configOptions.get(ENCRYPTION_PARAMS);
}
- public String getOutputProfileURI() {
- return (String) configOptions.get(OUTPUT_PROFILE);
+ public URI getOutputProfileURI() {
+ return (URI) configOptions.get(OUTPUT_PROFILE);
}
public Boolean getDisableSRGBColorSpace() {
}
put(ENCRYPTION_PARAMS, encryptionConfig);
}
- // TODO: Check this, I'm pretty sure the getChild(Str, bool) should be false!!!
- put(OUTPUT_PROFILE, parseConfig(cfg, OUTPUT_PROFILE));
+ put(OUTPUT_PROFILE, InternalResourceResolver.cleanURI(parseConfig(cfg, OUTPUT_PROFILE)));
put(DISABLE_SRGB_COLORSPACE, Boolean.valueOf(parseConfig(cfg, DISABLE_SRGB_COLORSPACE)));
put(VERSION, getPDFDocVersion(cfg));
} catch (ConfigurationException e) {
LogUtil.handleException(LOG, e, strict);
+ } catch (URISyntaxException use) {
+ LogUtil.handleException(LOG, use, strict);
}
}
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Map;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.xmlgraphics.image.loader.util.ImageUtil;
import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil;
import org.apache.xmlgraphics.xmp.Metadata;
import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter;
import org.apache.fop.accessibility.Accessibility;
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.io.InternalResourceResolver;
import org.apache.fop.fo.extensions.xmp.XMPMetadata;
import org.apache.fop.pdf.PDFAMode;
import org.apache.fop.pdf.PDFArray;
private boolean disableSRGBColorSpace = false;
/** Optional URI to an output profile to be used. */
- private String outputProfileURI;
+ private URI outputProfileURI;
private Version maxPDFVersion;
}
s = (String) userAgent.getRendererOption(OUTPUT_PROFILE);
if (s != null) {
- this.outputProfileURI = s;
+ this.outputProfileURI = URI.create(s);
}
Object disableSRGBColorSpace = userAgent.getRendererOption(DISABLE_SRGB_COLORSPACE);
if (disableSRGBColorSpace != null) {
* Sets the output color profile for the PDF renderer.
* @param outputProfileURI the URI to the output color profile
*/
- public void setOutputProfileURI(String outputProfileURI) {
+ public void setOutputProfileURI(URI outputProfileURI) {
this.outputProfileURI = outputProfileURI;
}
InputStream in = null;
if (this.outputProfileURI != null) {
this.outputProfile = pdfDoc.getFactory().makePDFICCStream();
- Source src = getUserAgent().resolveURI(this.outputProfileURI);
- if (src == null) {
- throw new IOException("Output profile not found: " + this.outputProfileURI);
- }
- if (src instanceof StreamSource) {
- in = ((StreamSource)src).getInputStream();
- } else {
- in = new URL(src.getSystemId()).openStream();
- }
+ in = getUserAgent().getResourceResolver().getResource(outputProfileURI);
try {
profile = ColorProfileUtil.getICC_Profile(in);
} finally {
//Create embedded file
PDFEmbeddedFile file = new PDFEmbeddedFile();
this.pdfDoc.registerObject(file);
- Source src = getUserAgent().resolveURI(embeddedFile.getSrc());
- InputStream in = ImageUtil.getInputStream(src);
+ URI srcURI;
+ try {
+ srcURI = InternalResourceResolver.cleanURI(embeddedFile.getSrc());
+ } catch (URISyntaxException use) {
+ throw new RuntimeException(use);
+ }
+ InputStream in = getUserAgent().getResourceResolver().getResource(srcURI);
if (in == null) {
throw new FileNotFoundException(embeddedFile.getSrc());
}
package org.apache.fop.svg;
+import java.io.File;
+import java.net.URI;
import java.util.List;
import org.apache.avalon.framework.configuration.Configuration;
FontInfo fontInfo = new FontInfo();
final boolean strict = false;
if (cfg != null) {
- InternalResourceResolver resourceResolver = ResourceResolverFactory.createDefaultWrapper();
+ URI thisUri = new File(".").getAbsoluteFile().toURI();
+ InternalResourceResolver resourceResolver = ResourceResolverFactory.createDefaultInternalResourceResolver(thisUri);
//TODO The following could be optimized by retaining the FontManager somewhere
FontManager fontManager = new FontManager(resourceResolver, FontDetectorFactory.createDefault(),
FontCacheManagerFactory.createDefault());
package org.apache.fop;
import org.apache.batik.transcoder.Transcoder;
+
import org.apache.fop.svg.PDFTranscoder;
/**
package org.apache.fop.afp;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.IOException;
import org.junit.Before;
@Before
public void setUp() throws IOException {
- sut = new AFPResourceManager(ResourceResolverFactory.createDefaultWrapper());
+ sut = new AFPResourceManager(ResourceResolverFactory.createDefaultInternalResourceResolver(
+ new File(".").toURI()));
AFPPaintingState paintingState = new AFPPaintingState();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
DataStream stream = sut.createDataStream(paintingState, outStream);
@Before
public void setUp() {
- singlebyteEncoder = CharactersetEncoder.newInstance("cp500", CharacterSetType.SINGLE_BYTE);
- doublebyteEncoder = CharactersetEncoder.newInstance("cp937",
- CharacterSetType.DOUBLE_BYTE_LINE_DATA);
+ singlebyteEncoder = CharacterSetType.SINGLE_BYTE.getEncoder("cp500");
+ doublebyteEncoder = CharacterSetType.DOUBLE_BYTE_LINE_DATA.getEncoder("cp937");
}
// This is just an arbitrary CJK string
import org.junit.Before;
import org.junit.Test;
-import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.ResourceResolverFactory;
import static org.junit.Assert.assertEquals;
*/
public class DejaVuLGCSerifTestCase {
- private InternalResourceResolver resolver = new InternalResourceResolver(new File(".").toURI(),
- ResourceResolverFactory.createDefaultResourceResolver());
+ private InternalResourceResolver resolver =
+ ResourceResolverFactory.createDefaultInternalResourceResolver(new File(".").toURI());
private CustomFont font;
/**
import org.junit.Test;
-import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.EncodingMode;
import static org.junit.Assert.assertFalse;
boolean useComplexScriptFeatures = false;
File file = new File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf");
URI absoluteFilePath = file.toURI();
- InternalResourceResolver resolver = ResourceResolverFactory.createDefaultWrapper();
+ InternalResourceResolver resourceResolver = ResourceResolverFactory.createDefaultInternalResourceResolver(
+ new File(".").toURI());
String fontName = "Deja Vu";
boolean embedded = false;
boolean useKerning = true;
TTFFontLoader fontLoader = new TTFFontLoader(absoluteFilePath, fontName, embedded,
- EncodingMode.AUTO, useKerning, useComplexScriptFeatures, resolver);
+ EncodingMode.AUTO, useKerning, useComplexScriptFeatures, resourceResolver);
assertTrue(fontLoader.getFont().hasKerningInfo());
useKerning = false;
fontLoader = new TTFFontLoader(absoluteFilePath, fontName, embedded, EncodingMode.AUTO,
- useKerning, useComplexScriptFeatures, resolver);
+ useKerning, useComplexScriptFeatures, resourceResolver);
assertFalse(fontLoader.getFont().hasKerningInfo());
}
}
package org.apache.fop.pdf;
+import java.io.File;
+import java.net.URI;
+
import org.junit.Test;
-import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.apps.io.InternalResourceResolver;
+import org.apache.fop.apps.io.ResourceResolver;
+import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.fonts.CIDSubset;
import org.apache.fop.fonts.MultiByteFont;
}
PDFDocument doc = new PDFDocument("Test");
PDFFactory pdfFactory = new PDFFactory(doc);
- MockedFont font = new MockedFont(ResourceResolverFactory.createDefaultWrapper());
+ URI thisURI = new File(".").toURI();
+ ResourceResolver resolver = ResourceResolverFactory.createDefaultResourceResolver();
+ InternalResourceResolver resourceResolver = ResourceResolverFactory.createInternalResourceResolver(
+ thisURI, resolver);
+ MockedFont font = new MockedFont(resourceResolver);
PDFFont pdfDejaVu = pdfFactory.makeFont("DejaVu", "DejaVu", "TTF", font, font);
assertEquals("/EAAAAA+DejaVu", pdfDejaVu.getBaseFont().toString());
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
+import java.net.URI;
import java.util.List;
import java.util.Map;
@Test
public void testSetProfile() throws Exception {
- String testString = "this string is purely for testing and has no contextual meaning";
+ String testString = "this.uri.is.purely.for.testing.and.has.no.contextual.meaning";
parseConfigMockUtil(createBuilder().setOutputProfile(testString));
- verify(pdfUtil).setOutputProfileURI(testString);
+ verify(pdfUtil).setOutputProfileURI(URI.create(testString));
}
@Test