Plus other internal cleanup git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_URI_Unification@1350538 13f79535-47bb-0310-9956-ffa450edef68pull/26/head
@@ -44,7 +44,7 @@ import org.apache.fop.afp.modca.ResourceGroup; | |||
import org.apache.fop.afp.modca.ResourceObject; | |||
import org.apache.fop.afp.util.AFPResourceAccessor; | |||
import org.apache.fop.afp.util.AFPResourceUtil; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
/** | |||
* Manages the creation and storage of document resources | |||
@@ -80,9 +80,9 @@ public class AFPResourceManager { | |||
/** | |||
* Main constructor | |||
*/ | |||
public AFPResourceManager(URIResolverWrapper uriResolverWrapper) { | |||
public AFPResourceManager(InternalResourceResolver resourceResolver) { | |||
this.factory = new Factory(); | |||
this.streamer = new AFPStreamer(factory, uriResolverWrapper); | |||
this.streamer = new AFPStreamer(factory, resourceResolver); | |||
this.dataObjectFactory = new AFPDataObjectFactory(factory); | |||
} | |||
@@ -35,7 +35,7 @@ import org.apache.commons.logging.LogFactory; | |||
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.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
/** | |||
* Manages the streaming of the AFP output | |||
@@ -51,7 +51,7 @@ public class AFPStreamer implements Streamable { | |||
private final Factory factory; | |||
private final URIResolverWrapper uriResolverWrapper; | |||
private final InternalResourceResolver resourceResolver; | |||
/** A mapping of external resource destinations to resource groups */ | |||
private final Map<URI, ResourceGroup> pathResourceGroupMap = new HashMap<URI, ResourceGroup>(); | |||
@@ -75,10 +75,11 @@ public class AFPStreamer implements Streamable { | |||
* Main constructor | |||
* | |||
* @param factory a factory | |||
* @param resourceResolver resource resolver | |||
*/ | |||
public AFPStreamer(Factory factory, URIResolverWrapper uriResolverWrapper) { | |||
public AFPStreamer(Factory factory, InternalResourceResolver resourceResolver) { | |||
this.factory = factory; | |||
this.uriResolverWrapper = uriResolverWrapper; | |||
this.resourceResolver = resourceResolver; | |||
this.tempUri = TEMP_URI_GENERATOR.generate(); | |||
defaultResourceGroupUri = URI.create(DEFAULT_EXTERNAL_RESOURCE_FILENAME); | |||
@@ -92,7 +93,7 @@ public class AFPStreamer implements Streamable { | |||
* @throws IOException thrown if an I/O exception of some sort has occurred | |||
*/ | |||
public DataStream createDataStream(AFPPaintingState paintingState) throws IOException { | |||
this.tempOutputStream = new BufferedOutputStream(uriResolverWrapper.resolveOut(tempUri)); | |||
this.tempOutputStream = new BufferedOutputStream(resourceResolver.getOutputStream(tempUri)); | |||
this.dataStream = factory.createDataStream(paintingState, tempOutputStream); | |||
return dataStream; | |||
} | |||
@@ -127,7 +128,7 @@ public class AFPStreamer implements Streamable { | |||
if (resourceGroup == null) { | |||
OutputStream os = null; | |||
try { | |||
os = new BufferedOutputStream(uriResolverWrapper.resolveOut(uri)); | |||
os = new BufferedOutputStream(resourceResolver.getOutputStream(uri)); | |||
} catch (IOException ioe) { | |||
LOG.error("Failed to create/open external resource group for uri '" | |||
+ uri + "'"); | |||
@@ -184,7 +185,7 @@ public class AFPStreamer implements Streamable { | |||
/** {@inheritDoc} */ | |||
public void writeToStream(OutputStream os) throws IOException { | |||
tempOutputStream.close(); | |||
InputStream tempInputStream = uriResolverWrapper.resolveIn(tempUri); | |||
InputStream tempInputStream = resourceResolver.getResource(tempUri); | |||
IOUtils.copy(tempInputStream, os); | |||
//TODO this should notify the stream provider that it is safe to delete the temp data | |||
tempInputStream.close(); |
@@ -24,34 +24,36 @@ import java.io.InputStream; | |||
import java.net.URI; | |||
import java.net.URISyntaxException; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
/** | |||
* Defines an interface through which external resource objects can be accessed. | |||
*/ | |||
public final class AFPResourceAccessor { | |||
private final URIResolverWrapper resolver; | |||
private final InternalResourceResolver resourceResolver; | |||
private final String baseURI; | |||
/** | |||
* Constructor for resource to be accessed via the {@link FOUserAgent}. This contructor | |||
* can take two base URIs: the category base URI is the one to use when differentiating between | |||
* normal resources (ex. images) and font resources. So, if fonts need to be accessed, you can | |||
* set the {@link org.apache.fop.fonts.FontManager}'s base URI instead of the one on the | |||
* {@link org.apache.fop.apps.FopFactory}. | |||
* @param userAgent the FO user agent | |||
* @param categoryBaseURI the category base URI (may be null) | |||
* takes a base URI for resolving font resource URIs. So, if fonts need to be accessed, you can | |||
* set the {@link FontManager}'s base URI instead of the one on the {@link FopFactory}. | |||
* | |||
* @param InternalResourceResolver resource resolver | |||
* @param baseURI the custom base URI to resolve relative URIs against (may be null) | |||
*/ | |||
public AFPResourceAccessor(URIResolverWrapper resolver, String baseURI) { | |||
this.resolver = resolver; | |||
public AFPResourceAccessor(InternalResourceResolver resourceResolver, String baseURI) { | |||
this.resourceResolver = resourceResolver; | |||
this.baseURI = baseURI; | |||
} | |||
public AFPResourceAccessor(URIResolverWrapper resolver) { | |||
this.resolver = resolver; | |||
this.baseURI = null; | |||
/** | |||
* Constructor for resource to be accessed via the {@link FOUserAgent}. | |||
* | |||
* @param InternalResourceResolver resource resolver | |||
*/ | |||
public AFPResourceAccessor(InternalResourceResolver resourceResolver) { | |||
this(resourceResolver, null); | |||
} | |||
private URI getResourceURI(URI uri) { | |||
@@ -59,7 +61,7 @@ public final class AFPResourceAccessor { | |||
return uri; | |||
} | |||
try { | |||
URI baseURI = URIResolverWrapper.getBaseURI(this.baseURI); | |||
URI baseURI = InternalResourceResolver.getBaseURI(this.baseURI); | |||
return baseURI.resolve(uri); | |||
} catch (URISyntaxException use) { | |||
return uri; | |||
@@ -68,7 +70,7 @@ public final class AFPResourceAccessor { | |||
/** {@inheritDoc} */ | |||
public InputStream createInputStream(URI uri) throws IOException { | |||
return resolver.resolveIn(getResourceURI(uri)); | |||
return resourceResolver.getResource(getResourceURI(uri)); | |||
} | |||
} |
@@ -22,7 +22,7 @@ package org.apache.fop.apps; | |||
import java.net.URI; | |||
import org.apache.fop.apps.io.ResourceResolver; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.FontCacheManager; | |||
import org.apache.fop.fonts.FontCacheManagerFactory; | |||
import org.apache.fop.fonts.FontDetector; | |||
@@ -105,7 +105,7 @@ public final class EnvironmentalProfileFactory { | |||
private static FontManager createFontManager(URI defaultBaseUri, ResourceResolver resourceResolver, | |||
FontDetector fontDetector, FontCacheManager fontCacheManager) { | |||
return new FontManager(new URIResolverWrapper(defaultBaseUri, resourceResolver), fontDetector, | |||
return new FontManager(new InternalResourceResolver(defaultBaseUri, resourceResolver), fontDetector, | |||
fontCacheManager); | |||
} | |||
} |
@@ -45,7 +45,7 @@ import org.apache.fop.Version; | |||
import org.apache.fop.accessibility.Accessibility; | |||
import org.apache.fop.accessibility.DummyStructureTreeEventHandler; | |||
import org.apache.fop.accessibility.StructureTreeEventHandler; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.events.DefaultEventBroadcaster; | |||
import org.apache.fop.events.Event; | |||
import org.apache.fop.events.EventBroadcaster; | |||
@@ -93,7 +93,7 @@ public class FOUserAgent { | |||
private final FopFactory factory; | |||
private final URIResolverWrapper newUriResolver; | |||
private final InternalResourceResolver resourceResolver; | |||
private float targetResolution = FopFactoryConfig.DEFAULT_TARGET_RESOLUTION; | |||
private Map rendererOptions = new java.util.HashMap(); | |||
@@ -151,11 +151,12 @@ public class FOUserAgent { | |||
* Main constructor. <b>This constructor should not be called directly. Please use the | |||
* methods from FopFactory to construct FOUserAgent instances!</b> | |||
* @param factory the factory that provides environment-level information | |||
* @param resourceResolver the resolver used to acquire resources | |||
* @see org.apache.fop.apps.FopFactory | |||
*/ | |||
FOUserAgent(FopFactory factory, URIResolverWrapper uriResolver) { | |||
FOUserAgent(FopFactory factory, InternalResourceResolver resourceResolver) { | |||
this.factory = factory; | |||
this.newUriResolver = uriResolver; | |||
this.resourceResolver = resourceResolver; | |||
setTargetResolution(factory.getTargetResolution()); | |||
setAccessibility(factory.isAccessibilityEnabled()); | |||
} | |||
@@ -197,12 +198,12 @@ public class FOUserAgent { | |||
/** | |||
* Returns the URI Resolver. | |||
* Returns the resource resolver. | |||
* | |||
* @return the URI resolver | |||
* @return the resource resolver | |||
*/ | |||
public URIResolverWrapper getNewURIResolver() { | |||
return newUriResolver; | |||
public InternalResourceResolver getResourceResolver() { | |||
return resourceResolver; | |||
} | |||
// ---------------------------------------------- rendering-run dependent stuff | |||
@@ -405,7 +406,7 @@ public class FOUserAgent { | |||
// TODO: What do we want to do when resources aren't found??? | |||
try { | |||
// Have to do this so we can resolve data URIs | |||
Source src = new StreamSource(newUriResolver.resolveIn(uri)); | |||
Source src = new StreamSource(resourceResolver.getResource(uri)); | |||
src.setSystemId(uri); | |||
return src; | |||
} catch (URISyntaxException use) { |
@@ -41,7 +41,7 @@ import org.apache.xmlgraphics.image.loader.util.Penalty; | |||
import org.apache.fop.apps.io.ResourceResolver; | |||
import org.apache.fop.apps.io.ResourceResolverFactory; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.FontManagerConfigurator; | |||
import org.apache.fop.hyphenation.HyphenationTreeCache; | |||
import org.apache.fop.util.LogUtil; | |||
@@ -87,13 +87,13 @@ public class FopConfParser { | |||
* | |||
* @param fopConfStream the fop conf input stream | |||
* @param defaultBaseURI the default base URI | |||
* @param resolver the URI resolver | |||
* @param resourceResolver the URI resolver | |||
* @throws SAXException if a SAX error was thrown parsing the FOP conf | |||
* @throws IOException if an I/O error is thrown while parsing the FOP conf | |||
*/ | |||
public FopConfParser(InputStream fopConfStream, URI defaultBaseURI, | |||
ResourceResolver resolver) throws SAXException, IOException { | |||
this(fopConfStream, EnvironmentalProfileFactory.createDefault(defaultBaseURI, resolver)); | |||
ResourceResolver resourceResolver) throws SAXException, IOException { | |||
this(fopConfStream, EnvironmentalProfileFactory.createDefault(defaultBaseURI, resourceResolver)); | |||
} | |||
/** | |||
@@ -125,17 +125,17 @@ public class FopConfParser { | |||
* Constructor that parses the FOP conf and uses the URI resolver given. | |||
* | |||
* @param fopConfFile the FOP conf file | |||
* @param resolver the URI resolver | |||
* @param resourceResolver the URI resolver | |||
* @throws SAXException if a SAX error was thrown parsing the FOP conf | |||
* @throws IOException if an I/O error is thrown while parsing the FOP conf | |||
*/ | |||
public FopConfParser(File fopConfFile, ResourceResolver resolver) | |||
public FopConfParser(File fopConfFile, ResourceResolver resourceResolver) | |||
throws SAXException, IOException { | |||
this(new FileInputStream(fopConfFile), | |||
fopConfFile.getAbsoluteFile().getParentFile().toURI(), resolver); | |||
fopConfFile.getAbsoluteFile().getParentFile().toURI(), resourceResolver); | |||
} | |||
private void configure(final URI defaultBaseURI, final ResourceResolver resolver, | |||
private void configure(final URI defaultBaseURI, final ResourceResolver resourceResolver, | |||
Configuration cfg) throws FOPException { | |||
if (log.isDebugEnabled()) { | |||
log.debug("Initializing FopFactory Configuration"); | |||
@@ -164,7 +164,7 @@ public class FopConfParser { | |||
// base definitions for relative path resolution | |||
if (cfg.getChild("base", false) != null) { | |||
try { | |||
URI confUri = URIResolverWrapper.getBaseURI(cfg.getChild("base").getValue(null)); | |||
URI confUri = InternalResourceResolver.getBaseURI(cfg.getChild("base").getValue(null)); | |||
fopFactoryBuilder.setBaseURI(defaultBaseURI.resolve(confUri)); | |||
} catch (URISyntaxException use) { | |||
LogUtil.handleException(log, use, strict); | |||
@@ -233,7 +233,7 @@ public class FopConfParser { | |||
} | |||
// configure font manager | |||
new FontManagerConfigurator(cfg, fopFactoryBuilder.getBaseUri(), resolver).configure( | |||
new FontManagerConfigurator(cfg, fopFactoryBuilder.getBaseUri(), resourceResolver).configure( | |||
fopFactoryBuilder.getFontManager(), strict); | |||
// configure image loader framework |
@@ -38,7 +38,7 @@ import org.apache.xmlgraphics.image.loader.ImageContext; | |||
import org.apache.xmlgraphics.image.loader.ImageManager; | |||
import org.apache.xmlgraphics.util.UnitConv; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fo.ElementMapping; | |||
import org.apache.fop.fo.ElementMappingRegistry; | |||
import org.apache.fop.fonts.FontManager; | |||
@@ -82,15 +82,15 @@ public final class FopFactory implements ImageContext { | |||
private final FopFactoryConfig config; | |||
private final URIResolverWrapper uriResolverWrapper; | |||
private final InternalResourceResolver resolver; | |||
private final Map<String, RendererConfig> rendererConfig; | |||
private FopFactory(FopFactoryConfig config) { | |||
this.config = config; | |||
this.uriResolverWrapper = new URIResolverWrapper(config.getBaseURI(), config.getNewURIResolver()); | |||
this.resolver = new InternalResourceResolver(config.getBaseURI(), config.getResourceResolver()); | |||
this.elementMappingRegistry = new ElementMappingRegistry(this); | |||
this.colorSpaceCache = new ColorSpaceCache(uriResolverWrapper); | |||
this.colorSpaceCache = new ColorSpaceCache(resolver); | |||
this.rendererFactory = new RendererFactory(config.preferRenderer()); | |||
this.xmlHandlers = new XMLHandlerRegistry(); | |||
this.imageHandlers = new ImageHandlerRegistry(); | |||
@@ -163,7 +163,7 @@ public final class FopFactory implements ImageContext { | |||
* @throws FOPException | |||
*/ | |||
public FOUserAgent newFOUserAgent() { | |||
FOUserAgent userAgent = new FOUserAgent(this, uriResolverWrapper); | |||
FOUserAgent userAgent = new FOUserAgent(this, resolver); | |||
return userAgent; | |||
} | |||
@@ -26,8 +26,6 @@ import java.util.HashSet; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import javax.xml.transform.URIResolver; | |||
import org.apache.avalon.framework.configuration.Configuration; | |||
import org.apache.xmlgraphics.image.loader.ImageContext; | |||
@@ -75,10 +73,10 @@ public final class FopFactoryBuilder { | |||
* A builder class for {@link FopFactory} which can be used for setting configuration. | |||
* | |||
* @param defaultBaseURI the default base URI for resolving URIs against | |||
* @param uriResolver the URI resolver | |||
* @param resourceResolver the URI resolver | |||
*/ | |||
public FopFactoryBuilder(URI defaultBaseURI, ResourceResolver uriResolver) { | |||
this(EnvironmentalProfileFactory.createDefault(defaultBaseURI, uriResolver)); | |||
public FopFactoryBuilder(URI defaultBaseURI, ResourceResolver resourceResolver) { | |||
this(EnvironmentalProfileFactory.createDefault(defaultBaseURI, resourceResolver)); | |||
} | |||
/** | |||
@@ -163,19 +161,6 @@ public final class FopFactoryBuilder { | |||
return this; | |||
} | |||
/** | |||
* Sets the URI resolver to be used for controlling FOP's file access. | |||
* | |||
* @param resolver the URI resolver | |||
* @return <code>this</code> | |||
* @deprecated this URIResolver will be phased out in favour of a unified URI resolution | |||
* mechanism | |||
*/ | |||
public FopFactoryBuilder setURIResolver(URIResolver resolver) { | |||
fopFactoryConfigBuilder.setURIResolver(resolver); | |||
return this; | |||
} | |||
/** | |||
* Sets the base URI, this will be used for resolving all URIs given to FOP. | |||
* | |||
@@ -351,8 +336,6 @@ public final class FopFactoryBuilder { | |||
private Set<String> ignoredNamespaces = new HashSet<String>(); | |||
private URIResolver resolver; | |||
private Configuration cfg; | |||
private boolean preferRenderer; | |||
@@ -391,15 +374,10 @@ public final class FopFactoryBuilder { | |||
} | |||
/** {@inheritDoc} */ | |||
public ResourceResolver getNewURIResolver() { | |||
public ResourceResolver getResourceResolver() { | |||
return enviro.getResourceResolver(); | |||
} | |||
/** {@inheritDoc} */ | |||
public URIResolver getURIResolver() { | |||
return resolver; | |||
} | |||
/** {@inheritDoc} */ | |||
public URI getBaseURI() { | |||
return baseURI; | |||
@@ -485,8 +463,6 @@ public final class FopFactoryBuilder { | |||
void setLayoutManagerMakerOverride(LayoutManagerMaker lmMaker); | |||
void setURIResolver(URIResolver resolver); | |||
void setBaseURI(URI baseURI); | |||
void setStrictFOValidation(boolean validateStrictly); | |||
@@ -534,18 +510,10 @@ public final class FopFactoryBuilder { | |||
} | |||
public void setURIResolver(URIResolver resolver) { | |||
throwIllegalStateException(); | |||
} | |||
public void setBaseURI(URI baseURI) { | |||
throwIllegalStateException(); | |||
} | |||
public void setHyphenationBaseURI(URI hyphenationBase) { | |||
throwIllegalStateException(); | |||
} | |||
public void setStrictFOValidation(boolean validateStrictly) { | |||
throwIllegalStateException(); | |||
} | |||
@@ -617,10 +585,6 @@ public final class FopFactoryBuilder { | |||
config.layoutManagerMaker = lmMaker; | |||
} | |||
public void setURIResolver(URIResolver resolver) { | |||
config.resolver = resolver; | |||
} | |||
public void setBaseURI(URI baseURI) { | |||
config.baseURI = baseURI; | |||
} |
@@ -72,7 +72,7 @@ public interface FopFactoryConfig { | |||
* | |||
* @return the URI resolver | |||
*/ | |||
ResourceResolver getNewURIResolver(); | |||
ResourceResolver getResourceResolver(); | |||
/** | |||
* The base URI from which URIs are resolved against. |
@@ -42,10 +42,10 @@ public final class ResourceResolverFactory { | |||
return new TempAwareResourceResolver(tempResourceResolver, defaultResourceResolver); | |||
} | |||
public static URIResolverWrapper createDefaultWrapper() { | |||
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 URIResolverWrapper(thisUri, new DefaultResourceResolver()); | |||
return new InternalResourceResolver(thisUri, new DefaultResourceResolver()); | |||
} | |||
public static SchemaAwareResourceResolverBuilder createSchemaAwareResourceResolverBuilder( |
@@ -80,7 +80,7 @@ public class CachedRenderPagesModel extends RenderPagesModel { | |||
// load page from cache | |||
URI tempURI = pageMap.get(pageViewport); | |||
log.debug("Loading page from: " + tempURI); | |||
InputStream inStream = renderer.getUserAgent().getNewURIResolver().resolveIn(tempURI); | |||
InputStream inStream = renderer.getUserAgent().getResourceResolver().getResource(tempURI); | |||
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(inStream)); | |||
try { | |||
pageViewport.loadPage(in); | |||
@@ -124,7 +124,7 @@ public class CachedRenderPagesModel extends RenderPagesModel { | |||
ObjectOutputStream tempstream; | |||
String fname = "fop-page-" + page.getPageIndex() + ".ser"; | |||
URI tempURI = tempBaseURI.resolve(fname); | |||
OutputStream outStream = renderer.getUserAgent().getNewURIResolver().resolveOut(tempURI); | |||
OutputStream outStream = renderer.getUserAgent().getResourceResolver().getOutputStream(tempURI); | |||
tempstream = new ObjectOutputStream(new BufferedOutputStream(outStream)); | |||
try { | |||
page.savePage(tempstream); |
@@ -71,7 +71,7 @@ public class SVGElement extends SVGObj { | |||
/* if width and height are zero, get the bounds of the content. */ | |||
try { | |||
URI baseUri = getUserAgent().getNewURIResolver().getBaseURI(); | |||
URI baseUri = getUserAgent().getResourceResolver().getBaseURI(); | |||
if (baseUri != null) { | |||
SVGOMDocument svgdoc = (SVGOMDocument)doc; | |||
svgdoc.setURLObject(baseUri.toURL()); |
@@ -19,7 +19,7 @@ | |||
package org.apache.fop.fonts; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
//Java | |||
@@ -32,10 +32,10 @@ public abstract class CIDFont extends CustomFont { | |||
protected int[] width = null; | |||
/** | |||
* @param resolver the URI resolver for controlling file access | |||
* @param resourceResolver the URI resolver for controlling file access | |||
*/ | |||
public CIDFont(URIResolverWrapper resolver) { | |||
super(resolver); | |||
public CIDFont(InternalResourceResolver resourceResolver) { | |||
super(resourceResolver); | |||
} | |||
// ---- Required ---- |
@@ -28,7 +28,7 @@ import java.util.HashSet; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
/** | |||
@@ -43,7 +43,7 @@ public abstract class CustomFont extends Typeface | |||
private String fontSubName; | |||
private URI embedFileURI; | |||
private String embedResourceName; | |||
private final URIResolverWrapper resolver; | |||
private final InternalResourceResolver resourceResolver; | |||
private int capHeight; | |||
private int xHeight; | |||
@@ -65,10 +65,10 @@ public abstract class CustomFont extends Typeface | |||
private boolean useAdvanced = true; | |||
/** | |||
* @param resolver the URI resolver for controlling file access | |||
* @param resourceResolver the URI resource resolver for controlling file access | |||
*/ | |||
public CustomFont(URIResolverWrapper resolver) { | |||
this.resolver = resolver; | |||
public CustomFont(InternalResourceResolver resourceResolver) { | |||
this.resourceResolver = resourceResolver; | |||
} | |||
/** {@inheritDoc} */ | |||
@@ -127,7 +127,7 @@ public abstract class CustomFont extends Typeface | |||
* @throws IOException if embedFileName is not null but Source is not found | |||
*/ | |||
public InputStream getInputStream() throws IOException { | |||
return resolver.resolveIn(embedFileURI); | |||
return resourceResolver.getResource(embedFileURI); | |||
} | |||
/** |
@@ -21,7 +21,7 @@ package org.apache.fop.fonts; | |||
import java.util.List; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
/** | |||
* Sets up a set of custom (embedded) fonts | |||
@@ -29,7 +29,7 @@ import org.apache.fop.apps.io.URIResolverWrapper; | |||
public class CustomFontCollection implements FontCollection { | |||
private final List<EmbedFontInfo> embedFontInfoList; | |||
private final URIResolverWrapper uriResolver; | |||
private final InternalResourceResolver uriResolver; | |||
private final boolean useComplexScripts; | |||
/** | |||
@@ -38,7 +38,7 @@ public class CustomFontCollection implements FontCollection { | |||
* @param customFonts the list of custom fonts | |||
* @param useComplexScriptFeatures true if complex script features enabled | |||
*/ | |||
public CustomFontCollection(URIResolverWrapper fontResolver, | |||
public CustomFontCollection(InternalResourceResolver fontResolver, | |||
List<EmbedFontInfo> customFonts, boolean useComplexScriptFeatures) { | |||
this.uriResolver = fontResolver; | |||
this.embedFontInfoList = customFonts; |
@@ -31,7 +31,7 @@ import org.apache.commons.logging.Log; | |||
import org.apache.commons.logging.LogFactory; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.DefaultFontConfig.Directory; | |||
import org.apache.fop.fonts.autodetect.FontFileFinder; | |||
import org.apache.fop.fonts.autodetect.FontInfoFinder; | |||
@@ -46,7 +46,7 @@ public class DefaultFontConfigurator implements FontConfigurator<EmbedFontInfo> | |||
protected static Log log = LogFactory.getLog(DefaultFontConfigurator.class); | |||
private final FontManager fontManager; | |||
private final URIResolverWrapper uriResolver; | |||
private final InternalResourceResolver resourceResolver; | |||
private final FontEventListener listener; | |||
private final boolean strict; | |||
@@ -59,7 +59,7 @@ public class DefaultFontConfigurator implements FontConfigurator<EmbedFontInfo> | |||
*/ | |||
public DefaultFontConfigurator(FontManager fontManager, FontEventListener listener, boolean strict) { | |||
this.fontManager = fontManager; | |||
this.uriResolver = fontManager.getURIResolver(); | |||
this.resourceResolver = fontManager.getResourceResolver(); | |||
this.listener = listener; | |||
this.strict = strict; | |||
} | |||
@@ -78,7 +78,7 @@ public class DefaultFontConfigurator implements FontConfigurator<EmbedFontInfo> | |||
log.debug("Starting font configuration..."); | |||
start = System.currentTimeMillis(); | |||
} | |||
FontAdder fontAdder = new FontAdder(fontManager, uriResolver, listener); | |||
FontAdder fontAdder = new FontAdder(fontManager, resourceResolver, listener); | |||
// native o/s search (autodetect) configuration | |||
fontManager.autoDetectFonts(adobeFontInfoConfig.isAutoDetectFonts(), fontAdder, strict, | |||
listener, fontInfoList); | |||
@@ -146,19 +146,19 @@ public class DefaultFontConfigurator implements FontConfigurator<EmbedFontInfo> | |||
String embed = font.getEmbedURI(); | |||
String metrics = font.getMetrics(); | |||
String subFont = font.getSubFont(); | |||
URI metricsUri = metrics == null ? null : URIResolverWrapper.cleanURI(metrics); | |||
URI embedUri = URIResolverWrapper.cleanURI(embed); | |||
URI metricsUri = metrics == null ? null : InternalResourceResolver.cleanURI(metrics); | |||
URI embedUri = InternalResourceResolver.cleanURI(embed); | |||
List<FontTriplet> tripletList = font.getTripletList(); | |||
// no font triplet info | |||
if (tripletList.size() == 0) { | |||
//TODO: could be problematic!! | |||
URI fontUri = uriResolver.getBaseURI().resolve(embedUri); | |||
URI fontUri = resourceResolver.resolveFromBase(embedUri); | |||
if (fontUri != null) { | |||
FontInfoFinder finder = new FontInfoFinder(); | |||
finder.setEventListener(listener); | |||
EmbedFontInfo[] infos = finder.find(fontUri, uriResolver, fontCache); | |||
EmbedFontInfo[] infos = finder.find(fontUri, resourceResolver, fontCache); | |||
return infos[0]; //When subFont is set, only one font is returned | |||
} else { | |||
return null; | |||
@@ -169,7 +169,7 @@ public class DefaultFontConfigurator implements FontConfigurator<EmbedFontInfo> | |||
font.isAdvanced(), tripletList, embedUri, subFont, encodingMode); | |||
if (fontCache != null) { | |||
if (!fontCache.containsFont(embedFontInfo)) { | |||
fontCache.addFont(embedFontInfo, uriResolver); | |||
fontCache.addFont(embedFontInfo, resourceResolver); | |||
} | |||
} | |||
@@ -23,7 +23,7 @@ import java.net.URISyntaxException; | |||
import java.net.URL; | |||
import java.util.List; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.autodetect.FontInfoFinder; | |||
/** | |||
@@ -31,18 +31,19 @@ import org.apache.fop.fonts.autodetect.FontInfoFinder; | |||
*/ | |||
public class FontAdder { | |||
private final FontEventListener listener; | |||
private final URIResolverWrapper resolver; | |||
private final InternalResourceResolver resourceResolver; | |||
private final FontManager manager; | |||
/** | |||
* Main constructor | |||
* @param manager a font manager | |||
* @param resolver a font resolver | |||
* @param resourceResolver a font resolver | |||
* @param listener a font event handler | |||
*/ | |||
public FontAdder(FontManager manager, URIResolverWrapper resolver, FontEventListener listener) { | |||
public FontAdder(FontManager manager, InternalResourceResolver resourceResolver, | |||
FontEventListener listener) { | |||
this.manager = manager; | |||
this.resolver = resolver; | |||
this.resourceResolver = resourceResolver; | |||
this.listener = listener; | |||
} | |||
@@ -59,7 +60,7 @@ public class FontAdder { | |||
finder.setEventListener(listener); | |||
for (URL fontURL : fontURLList) { | |||
EmbedFontInfo[] embedFontInfos = finder.find(fontURL.toURI(), resolver, cache); | |||
EmbedFontInfo[] embedFontInfos = finder.find(fontURL.toURI(), resourceResolver, cache); | |||
if (embedFontInfos == null) { | |||
continue; | |||
} |
@@ -41,7 +41,7 @@ import org.apache.commons.logging.Log; | |||
import org.apache.commons.logging.LogFactory; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.util.LogUtil; | |||
/** | |||
@@ -320,7 +320,7 @@ public final class FontCache implements Serializable { | |||
* @param fontInfo | |||
* font info | |||
*/ | |||
public void addFont(EmbedFontInfo fontInfo, URIResolverWrapper resolver) { | |||
public void addFont(EmbedFontInfo fontInfo, InternalResourceResolver resourceResolver) { | |||
String cacheKey = getCacheKey(fontInfo); | |||
synchronized (changeLock) { | |||
CachedFontFile cachedFontFile; | |||
@@ -331,8 +331,7 @@ public final class FontCache implements Serializable { | |||
} | |||
} else { | |||
// try and determine modified date | |||
// TODO: This could be problematic?!!?!?! | |||
URI fontUri = resolver.getBaseURI().resolve(fontInfo.getEmbedURI()); | |||
URI fontUri = resourceResolver.resolveFromBase(fontInfo.getEmbedURI()); | |||
File fontFile = new File(fontUri); | |||
long lastModified = (fontFile != null ? fontFile.lastModified() : -1); | |||
cachedFontFile = new CachedFontFile(lastModified); |
@@ -90,15 +90,13 @@ public final class FontDetectorFactory { | |||
// search in font base if it is defined and | |||
// is a directory but don't recurse | |||
FontFileFinder fontFileFinder = new FontFileFinder(eventListener); | |||
URI fontBaseURI = fontManager.getURIResolver().getBaseURI(); | |||
if (fontBaseURI != null) { | |||
File fontBase = FileUtils.toFile(fontBaseURI.toURL()); | |||
if (fontBase != null) { | |||
List<URL> fontURLList = fontFileFinder.find(fontBase.getAbsolutePath()); | |||
fontAdder.add(fontURLList, fontInfoList); | |||
//Can only use the font base URL if it's a file URL | |||
} | |||
URI fontBaseURI = fontManager.getResourceResolver().getBaseURI(); | |||
File fontBase = FileUtils.toFile(fontBaseURI.toURL()); | |||
if (fontBase != null) { | |||
List<URL> fontURLList = fontFileFinder.find(fontBase.getAbsolutePath()); | |||
fontAdder.add(fontURLList, fontInfoList); | |||
//Can only use the font base URL if it's a file URL | |||
} | |||
// native o/s font directory finding |
@@ -25,7 +25,7 @@ import java.net.URI; | |||
import org.apache.commons.logging.Log; | |||
import org.apache.commons.logging.LogFactory; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.truetype.TTFFontLoader; | |||
import org.apache.fop.fonts.type1.Type1FontLoader; | |||
@@ -39,8 +39,8 @@ public abstract class FontLoader { | |||
/** URI representing the font file */ | |||
protected final URI fontFileURI; | |||
/** the FontResolver to use for font URI resolution */ | |||
protected final URIResolverWrapper resolver; | |||
/** the resource resolver to use for font URI resolution */ | |||
protected final InternalResourceResolver resourceResolver; | |||
/** the loaded font */ | |||
protected CustomFont returnFont; | |||
@@ -60,15 +60,15 @@ public abstract class FontLoader { | |||
* @param useKerning indicates whether kerning information shall be loaded if available | |||
* @param useAdvanced indicates whether advanced typographic information shall be loaded if | |||
* available | |||
* @param resolver the font resolver used to resolve URIs | |||
* @param resourceResolver the font resolver used to resolve URIs | |||
*/ | |||
public FontLoader(URI fontFileURI, boolean embedded, boolean useKerning, | |||
boolean useAdvanced, URIResolverWrapper resolver) { | |||
boolean useAdvanced, InternalResourceResolver resourceResolver) { | |||
this.fontFileURI = fontFileURI; | |||
this.embedded = embedded; | |||
this.useKerning = useKerning; | |||
this.useAdvanced = useAdvanced; | |||
this.resolver = resolver; | |||
this.resourceResolver = resourceResolver; | |||
} | |||
private static boolean isType1(URI fontURI) { | |||
@@ -84,13 +84,13 @@ public abstract class FontLoader { | |||
* @param useKerning indicates whether kerning information should be loaded if available | |||
* @param useAdvanced indicates whether advanced typographic information shall be loaded if | |||
* available | |||
* @param resolver the font resolver to use when resolving URIs | |||
* @param resourceResolver the font resolver to use when resolving URIs | |||
* @return the newly loaded font | |||
* @throws IOException In case of an I/O error | |||
*/ | |||
public static CustomFont loadFont(URI fontFileURI, String subFontName, | |||
boolean embedded, EncodingMode encodingMode, boolean useKerning, | |||
boolean useAdvanced, URIResolverWrapper resolver) throws IOException { | |||
boolean useAdvanced, InternalResourceResolver resourceResolver) throws IOException { | |||
boolean type1 = isType1(fontFileURI); | |||
FontLoader loader; | |||
if (type1) { | |||
@@ -98,10 +98,10 @@ public abstract class FontLoader { | |||
throw new IllegalArgumentException( | |||
"CID encoding mode not supported for Type 1 fonts"); | |||
} | |||
loader = new Type1FontLoader(fontFileURI, embedded, useKerning, resolver); | |||
loader = new Type1FontLoader(fontFileURI, embedded, useKerning, resourceResolver); | |||
} else { | |||
loader = new TTFFontLoader(fontFileURI, subFontName, | |||
embedded, encodingMode, useKerning, useAdvanced, resolver); | |||
embedded, encodingMode, useKerning, useAdvanced, resourceResolver); | |||
} | |||
return loader.getFont(); | |||
} |
@@ -23,7 +23,7 @@ import java.io.File; | |||
import java.util.List; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.FontTriplet.Matcher; | |||
import org.apache.fop.fonts.substitute.FontSubstitutions; | |||
@@ -36,8 +36,8 @@ import org.apache.fop.fonts.substitute.FontSubstitutions; | |||
*/ | |||
public class FontManager { | |||
/** The base URL for all font URL resolutions. */ | |||
private URIResolverWrapper uriResolver; | |||
/** The resource resolver */ | |||
private InternalResourceResolver resourceResolver; | |||
private final FontDetector fontDetector; | |||
@@ -58,27 +58,27 @@ public class FontManager { | |||
/** | |||
* Main constructor | |||
* | |||
* @param uriResolver the URI resolver | |||
* @param resourceResolver the URI resolver | |||
* @param fontDetector the font detector | |||
* @param fontCacheManager the font cache manager | |||
*/ | |||
public FontManager(URIResolverWrapper uriResolver, FontDetector fontDetector, | |||
public FontManager(InternalResourceResolver resourceResolver, FontDetector fontDetector, | |||
FontCacheManager fontCacheManager) { | |||
this.uriResolver = uriResolver; | |||
this.resourceResolver = resourceResolver; | |||
this.fontDetector = fontDetector; | |||
this.fontCacheManager = fontCacheManager; | |||
} | |||
/** | |||
* Sets the font URI resolver | |||
* @param uriResolver font base URI | |||
* Sets the font resource resolver | |||
* @param resourceResolver resource resolver | |||
*/ | |||
public void setFontURIResolver(URIResolverWrapper uriResolver) { | |||
this.uriResolver = uriResolver; | |||
public void setResourceResolver(InternalResourceResolver resourceResolver) { | |||
this.resourceResolver = resourceResolver; | |||
} | |||
public URIResolverWrapper getURIResolver() { | |||
return this.uriResolver; | |||
public InternalResourceResolver getResourceResolver() { | |||
return this.resourceResolver; | |||
} | |||
/** @return true if kerning on base 14 fonts is enabled */ |
@@ -32,7 +32,7 @@ import org.apache.commons.logging.LogFactory; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.apps.io.ResourceResolver; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.substitute.FontSubstitutions; | |||
import org.apache.fop.fonts.substitute.FontSubstitutionsConfigurator; | |||
import org.apache.fop.util.LogUtil; | |||
@@ -49,19 +49,19 @@ public class FontManagerConfigurator { | |||
private final URI defaultBaseUri; | |||
private final ResourceResolver uriResolver; | |||
private final ResourceResolver resourceResolver; | |||
/** | |||
* Main constructor | |||
* @param cfg the font manager configuration object | |||
* @param defaultBaseUri the default URI base to use for URI resolution | |||
* @param resolver the URI resolver | |||
* @param resourceResolver the resource resolver | |||
*/ | |||
public FontManagerConfigurator(Configuration cfg, URI defaultBaseUri, | |||
ResourceResolver resolver) { | |||
ResourceResolver resourceResolver) { | |||
this.cfg = cfg; | |||
this.defaultBaseUri = defaultBaseUri; | |||
this.uriResolver = resolver; | |||
this.resourceResolver = resourceResolver; | |||
} | |||
/** | |||
@@ -88,15 +88,15 @@ public class FontManagerConfigurator { | |||
} | |||
if (cfg.getChild("font-base", false) != null) { | |||
try { | |||
URI fontBase = URIResolverWrapper.getBaseURI(cfg.getChild("font-base").getValue( | |||
URI fontBase = InternalResourceResolver.getBaseURI(cfg.getChild("font-base").getValue( | |||
null)); | |||
fontManager.setFontURIResolver(new URIResolverWrapper( | |||
defaultBaseUri.resolve(fontBase), uriResolver)); | |||
fontManager.setResourceResolver(new InternalResourceResolver( | |||
defaultBaseUri.resolve(fontBase), resourceResolver)); | |||
} catch (URISyntaxException use) { | |||
LogUtil.handleException(log, use, true); | |||
} | |||
} else { | |||
fontManager.setFontURIResolver(new URIResolverWrapper(defaultBaseUri, uriResolver)); | |||
fontManager.setResourceResolver(new InternalResourceResolver(defaultBaseUri, resourceResolver)); | |||
} | |||
// [GA] permit configuration control over base14 kerning; without this, |
@@ -39,7 +39,7 @@ import org.xml.sax.XMLReader; | |||
import org.xml.sax.helpers.DefaultHandler; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.apps.TTFReader; | |||
/** | |||
@@ -58,7 +58,7 @@ public class FontReader extends DefaultHandler { | |||
private CustomFont returnFont; | |||
private MultiByteFont multiFont; | |||
private SingleByteFont singleFont; | |||
private final URIResolverWrapper resolver; | |||
private final InternalResourceResolver resourceResolver; | |||
private StringBuffer text = new StringBuffer(); | |||
private List<Integer> cidWidths; | |||
@@ -74,8 +74,8 @@ public class FontReader extends DefaultHandler { | |||
* @param source Source of the font metric file | |||
* @throws FOPException if loading the font fails | |||
*/ | |||
public FontReader(InputSource source, URIResolverWrapper resolver) throws FOPException { | |||
this.resolver = resolver; | |||
public FontReader(InputSource source, InternalResourceResolver resourceResolver) throws FOPException { | |||
this.resourceResolver = resourceResolver; | |||
createFont(source); | |||
} | |||
@@ -156,25 +156,25 @@ public class FontReader extends DefaultHandler { | |||
throws SAXException { | |||
if (localName.equals("font-metrics")) { | |||
if ("TYPE0".equals(attributes.getValue("type"))) { | |||
multiFont = new MultiByteFont(resolver); | |||
multiFont = new MultiByteFont(resourceResolver); | |||
returnFont = multiFont; | |||
isCID = true; | |||
TTFReader.checkMetricsVersion(attributes); | |||
} else if ("TRUETYPE".equals(attributes.getValue("type"))) { | |||
singleFont = new SingleByteFont(resolver); | |||
singleFont = new SingleByteFont(resourceResolver); | |||
singleFont.setFontType(FontType.TRUETYPE); | |||
returnFont = singleFont; | |||
isCID = false; | |||
TTFReader.checkMetricsVersion(attributes); | |||
} else { | |||
singleFont = new SingleByteFont(resolver); | |||
singleFont = new SingleByteFont(resourceResolver); | |||
singleFont.setFontType(FontType.TYPE1); | |||
returnFont = singleFont; | |||
isCID = false; | |||
} | |||
} else if ("embed".equals(localName)) { | |||
try { | |||
returnFont.setEmbedURI(URIResolverWrapper.cleanURI(attributes.getValue("file"))); | |||
returnFont.setEmbedURI(InternalResourceResolver.cleanURI(attributes.getValue("file"))); | |||
} catch (URISyntaxException e) { | |||
// TODO: dunno what to do here?!?! | |||
} |
@@ -22,7 +22,7 @@ package org.apache.fop.fonts; | |||
// FOP (base 14 fonts) | |||
import java.util.List; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.base14.Courier; | |||
import org.apache.fop.fonts.base14.CourierBold; | |||
import org.apache.fop.fonts.base14.CourierBoldOblique; | |||
@@ -69,11 +69,11 @@ public final class FontSetup { | |||
* | |||
* @param fontInfo the font info object to set up | |||
* @param embedFontInfoList a list of EmbedFontInfo objects | |||
* @param resolver the font resolver | |||
* @param resourceResolver the font resolver | |||
* @param base14Kerning true if base14 kerning applies | |||
*/ | |||
public static void setup(FontInfo fontInfo, List embedFontInfoList, | |||
URIResolverWrapper resolver, boolean base14Kerning) { | |||
InternalResourceResolver resourceResolver, boolean base14Kerning) { | |||
fontInfo.addMetrics("F1", new Helvetica(base14Kerning)); | |||
fontInfo.addMetrics("F2", new HelveticaOblique(base14Kerning)); | |||
fontInfo.addMetrics("F3", new HelveticaBold(base14Kerning)); | |||
@@ -179,7 +179,7 @@ public final class FontSetup { | |||
final int startNum = 15; | |||
/* Add configured fonts */ | |||
addConfiguredFonts(fontInfo, embedFontInfoList, startNum, resolver, base14Kerning); | |||
addConfiguredFonts(fontInfo, embedFontInfoList, startNum, resourceResolver, base14Kerning); | |||
} | |||
/** | |||
@@ -187,15 +187,15 @@ public final class FontSetup { | |||
* @param fontInfo the font info to set up | |||
* @param embedFontInfoList a list of EmbedFontInfo objects | |||
* @param num starting index for internal font numbering | |||
* @param resolver the font resolver | |||
* @param resourceResolver the font resolver | |||
*/ | |||
private static void addConfiguredFonts(FontInfo fontInfo, | |||
List<EmbedFontInfo> embedFontInfoList, int num, URIResolverWrapper resolver, | |||
List<EmbedFontInfo> embedFontInfoList, int num, InternalResourceResolver resourceResolver, | |||
boolean base14Kerning) { | |||
if (embedFontInfoList == null) { | |||
return; //No fonts to process | |||
} | |||
assert resolver != null; | |||
assert resourceResolver != null; | |||
String internalName = null; | |||
@@ -203,7 +203,7 @@ public final class FontSetup { | |||
internalName = "F" + num; | |||
num++; | |||
LazyFont font = new LazyFont(embedFontInfo, resolver, false); | |||
LazyFont font = new LazyFont(embedFontInfo, resourceResolver, false); | |||
fontInfo.addMetrics(internalName, font); | |||
List<FontTriplet> triplets = embedFontInfo.getFontTriplets(); |
@@ -30,7 +30,7 @@ import org.apache.commons.logging.Log; | |||
import org.apache.commons.logging.LogFactory; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.complexscripts.fonts.Positionable; | |||
import org.apache.fop.complexscripts.fonts.Substitutable; | |||
@@ -48,7 +48,7 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, | |||
private final EncodingMode encodingMode; | |||
private final boolean embedded; | |||
private final String subFontName; | |||
private final URIResolverWrapper resolver; | |||
private final InternalResourceResolver resourceResolver; | |||
private boolean isMetricsLoaded; | |||
private Typeface realFont; | |||
@@ -57,13 +57,14 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, | |||
/** | |||
* Main constructor | |||
* @param fontInfo the font info to embed | |||
* @param resolver the font resolver to handle font URIs | |||
* @param resourceResolver the font resolver to handle font URIs | |||
*/ | |||
public LazyFont(EmbedFontInfo fontInfo, URIResolverWrapper resolver, boolean useComplexScripts) { | |||
public LazyFont(EmbedFontInfo fontInfo, InternalResourceResolver resourceResolver, | |||
boolean useComplexScripts) { | |||
this.metricsURI = fontInfo.getMetricsURI(); | |||
this.fontEmbedURI = fontInfo.getEmbedURI(); | |||
this.useKerning = fontInfo.getKerning(); | |||
if (resolver != null) { | |||
if (resourceResolver != null) { | |||
this.useAdvanced = useComplexScripts; | |||
} else { | |||
this.useAdvanced = fontInfo.getAdvanced(); | |||
@@ -72,7 +73,7 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, | |||
: EncodingMode.AUTO; | |||
this.subFontName = fontInfo.getSubFontName(); | |||
this.embedded = fontInfo.isEmbedded(); | |||
this.resolver = resolver; | |||
this.resourceResolver = resourceResolver; | |||
} | |||
/** {@inheritDoc} */ | |||
@@ -93,10 +94,10 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, | |||
if (metricsURI != null) { | |||
/**@todo Possible thread problem here */ | |||
FontReader reader = null; | |||
InputStream in = resolver.resolveIn(metricsURI); | |||
InputStream in = resourceResolver.getResource(metricsURI); | |||
InputSource src = new InputSource(in); | |||
src.setSystemId(metricsURI.toASCIIString()); | |||
reader = new FontReader(src, resolver); | |||
reader = new FontReader(src, resourceResolver); | |||
reader.setKerningEnabled(useKerning); | |||
reader.setAdvancedEnabled(useAdvanced); | |||
if (this.embedded) { | |||
@@ -108,7 +109,7 @@ public class LazyFont extends Typeface implements FontDescriptor, Substitutable, | |||
throw new RuntimeException("Cannot load font. No font URIs available."); | |||
} | |||
realFont = FontLoader.loadFont(fontEmbedURI, this.subFontName, | |||
this.embedded, this.encodingMode, useKerning, useAdvanced, resolver); | |||
this.embedded, this.encodingMode, useKerning, useAdvanced, resourceResolver); | |||
} | |||
if (realFont instanceof FontDescriptor) { | |||
realFontDescriptor = (FontDescriptor) realFont; |
@@ -26,7 +26,7 @@ import java.util.Map; | |||
import org.apache.commons.logging.Log; | |||
import org.apache.commons.logging.LogFactory; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.complexscripts.fonts.GlyphDefinitionTable; | |||
import org.apache.fop.complexscripts.fonts.GlyphPositioningTable; | |||
import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable; | |||
@@ -75,10 +75,10 @@ public class MultiByteFont extends CIDFont implements Substitutable, Positionabl | |||
private int lastUnmapped; | |||
/** | |||
* @param resolver the URI resolver for controlling file access | |||
* @param resourceResolver the resource resolver for accessing the font | |||
*/ | |||
public MultiByteFont(URIResolverWrapper resolver) { | |||
super(resolver); | |||
public MultiByteFont(InternalResourceResolver resourceResolver) { | |||
super(resourceResolver); | |||
subset.setupFirstGlyph(); | |||
setFontType(FontType.TYPE0); | |||
} |
@@ -31,7 +31,7 @@ import org.apache.commons.logging.LogFactory; | |||
import org.apache.xmlgraphics.fonts.Glyphs; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
/** | |||
* Generic SingleByte font | |||
@@ -52,10 +52,10 @@ public class SingleByteFont extends CustomFont { | |||
/** | |||
* @param resolver the URI resolver for controlling file access | |||
* @param resourceResolver the URI resolver for controlling file access | |||
*/ | |||
public SingleByteFont(URIResolverWrapper resolver) { | |||
super(resolver); | |||
public SingleByteFont(InternalResourceResolver resourceResolver) { | |||
super(resourceResolver); | |||
setEncoding(CodePointMapping.WIN_ANSI_ENCODING); | |||
} | |||
@@ -30,7 +30,7 @@ import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.logging.Log; | |||
import org.apache.commons.logging.LogFactory; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.CustomFont; | |||
import org.apache.fop.fonts.EmbedFontInfo; | |||
import org.apache.fop.fonts.EncodingMode; | |||
@@ -131,15 +131,8 @@ public class FontInfoFinder { | |||
return style; | |||
} | |||
/** | |||
* Attempts to determine FontInfo from a given custom font | |||
* @param fontUri the font URI | |||
* @param customFont the custom font | |||
* @param fontCache font cache (may be null) | |||
* @return FontInfo from the given custom font | |||
*/ | |||
private EmbedFontInfo getFontInfoFromCustomFont(URI fontUri, CustomFont customFont, | |||
FontCache fontCache, URIResolverWrapper resolver) { | |||
FontCache fontCache, InternalResourceResolver resourceResolver) { | |||
List<FontTriplet> fontTripletList = new java.util.ArrayList<FontTriplet>(); | |||
generateTripletsFromFont(customFont, fontTripletList); | |||
String subFontName = null; | |||
@@ -150,7 +143,7 @@ public class FontInfoFinder { | |||
customFont.isAdvancedEnabled(), fontTripletList, fontUri, subFontName); | |||
fontInfo.setPostScriptName(customFont.getFontName()); | |||
if (fontCache != null) { | |||
fontCache.addFont(fontInfo, resolver); | |||
fontCache.addFont(fontInfo, resourceResolver); | |||
} | |||
return fontInfo; | |||
} | |||
@@ -159,13 +152,13 @@ public class FontInfoFinder { | |||
* Attempts to determine EmbedFontInfo from a given font file. | |||
* | |||
* @param fontURI the URI of the font resource | |||
* @param resolver font resolver used to resolve font | |||
* @param resourceResolver font resolver used to resolve font | |||
* @param fontCache font cache (may be null) | |||
* @return an array of newly created embed font info. Generally, this array | |||
* will have only one entry, unless the fontUrl is a TrueType Collection | |||
*/ | |||
public EmbedFontInfo[] find(URI fontURI, URIResolverWrapper resolver, FontCache fontCache) { | |||
URI embedUri = resolver.getBaseURI().resolve(fontURI); | |||
public EmbedFontInfo[] find(URI fontURI, InternalResourceResolver resourceResolver, FontCache fontCache) { | |||
URI embedUri = resourceResolver.resolveFromBase(fontURI); | |||
String embedStr = embedUri.toASCIIString(); | |||
boolean useKerning = true; | |||
boolean useAdvanced = true; | |||
@@ -196,7 +189,7 @@ public class FontInfoFinder { | |||
List<String> ttcNames = null; | |||
InputStream in = null; | |||
try { | |||
in = resolver.resolveIn(fontURI); | |||
in = resourceResolver.getResource(fontURI); | |||
TTFFile ttf = new TTFFile(false, false); | |||
FontFileReader reader = new FontFileReader(in); | |||
ttcNames = ttf.getTTCnames(reader); | |||
@@ -219,7 +212,7 @@ public class FontInfoFinder { | |||
} | |||
try { | |||
TTFFontLoader ttfLoader = new TTFFontLoader(fontURI, fontName, true, | |||
EncodingMode.AUTO, useKerning, useAdvanced, resolver); | |||
EncodingMode.AUTO, useKerning, useAdvanced, resourceResolver); | |||
customFont = ttfLoader.getFont(); | |||
if (this.eventListener != null) { | |||
customFont.setEventListener(this.eventListener); | |||
@@ -235,7 +228,7 @@ public class FontInfoFinder { | |||
continue; | |||
} | |||
EmbedFontInfo fi = getFontInfoFromCustomFont(fontURI, customFont, fontCache, | |||
resolver); | |||
resourceResolver); | |||
if (fi != null) { | |||
embedFontInfoList.add(fi); | |||
} | |||
@@ -246,7 +239,7 @@ public class FontInfoFinder { | |||
// The normal case | |||
try { | |||
customFont = FontLoader.loadFont(fontURI, null, true, EncodingMode.AUTO, | |||
useKerning, useAdvanced, resolver); | |||
useKerning, useAdvanced, resourceResolver); | |||
if (this.eventListener != null) { | |||
customFont.setEventListener(this.eventListener); | |||
} | |||
@@ -260,7 +253,7 @@ public class FontInfoFinder { | |||
} | |||
return null; | |||
} | |||
EmbedFontInfo fi = getFontInfoFromCustomFont(fontURI, customFont, fontCache, resolver); | |||
EmbedFontInfo fi = getFontInfoFromCustomFont(fontURI, customFont, fontCache, resourceResolver); | |||
if (fi != null) { | |||
return new EmbedFontInfo[] {fi}; | |||
} else { |
@@ -31,7 +31,7 @@ import org.apache.commons.io.IOUtils; | |||
import org.apache.xmlgraphics.fonts.Glyphs; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.BFEntry; | |||
import org.apache.fop.fonts.CIDFontType; | |||
import org.apache.fop.fonts.EncodingMode; | |||
@@ -54,10 +54,10 @@ public class TTFFontLoader extends FontLoader { | |||
/** | |||
* Default constructor | |||
* @param fontFileURI the URI representing the font file | |||
* @param resolver the FontResolver for font URI resolution | |||
* @param resourceResolver the resource resolver for font URI resolution | |||
*/ | |||
public TTFFontLoader(URI fontFileURI, URIResolverWrapper resolver) { | |||
this(fontFileURI, null, true, EncodingMode.AUTO, true, true, resolver); | |||
public TTFFontLoader(URI fontFileURI, InternalResourceResolver resourceResolver) { | |||
this(fontFileURI, null, true, EncodingMode.AUTO, true, true, resourceResolver); | |||
} | |||
/** | |||
@@ -73,7 +73,7 @@ public class TTFFontLoader extends FontLoader { | |||
*/ | |||
public TTFFontLoader(URI fontFileURI, String subFontName, | |||
boolean embedded, EncodingMode encodingMode, boolean useKerning, | |||
boolean useAdvanced, URIResolverWrapper resolver) { | |||
boolean useAdvanced, InternalResourceResolver resolver) { | |||
super(fontFileURI, embedded, useKerning, useAdvanced, resolver); | |||
this.subFontName = subFontName; | |||
this.encodingMode = encodingMode; | |||
@@ -95,7 +95,7 @@ public class TTFFontLoader extends FontLoader { | |||
* @throws IOException if an I/O error occurs | |||
*/ | |||
private void read(String ttcFontName) throws IOException { | |||
InputStream in = resolver.resolveIn(this.fontFileURI); | |||
InputStream in = resourceResolver.getResource(this.fontFileURI); | |||
try { | |||
TTFFile ttf = new TTFFile(useKerning, useAdvanced); | |||
FontFileReader reader = new FontFileReader(in); | |||
@@ -123,11 +123,11 @@ public class TTFFontLoader extends FontLoader { | |||
} | |||
if (isCid) { | |||
multiFont = new MultiByteFont(resolver); | |||
multiFont = new MultiByteFont(resourceResolver); | |||
returnFont = multiFont; | |||
multiFont.setTTCName(ttcFontName); | |||
} else { | |||
singleFont = new SingleByteFont(resolver); | |||
singleFont = new SingleByteFont(resourceResolver); | |||
returnFont = singleFont; | |||
} | |||
@@ -30,7 +30,7 @@ import java.util.Set; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.CodePointMapping; | |||
import org.apache.fop.fonts.FontLoader; | |||
import org.apache.fop.fonts.FontType; | |||
@@ -49,12 +49,12 @@ public class Type1FontLoader extends FontLoader { | |||
* @param fontFileURI the URI to the PFB file of a Type 1 font | |||
* @param embedded indicates whether the font is embedded or referenced | |||
* @param useKerning indicates whether to load kerning information if available | |||
* @param resolver the font resolver used to resolve URIs | |||
* @param resourceResolver the font resolver used to resolve URIs | |||
* @throws IOException In case of an I/O error | |||
*/ | |||
public Type1FontLoader(URI fontFileURI, boolean embedded, boolean useKerning, | |||
URIResolverWrapper resolver) throws IOException { | |||
super(fontFileURI, embedded, useKerning, true, resolver); | |||
InternalResourceResolver resourceResolver) throws IOException { | |||
super(fontFileURI, embedded, useKerning, true, resourceResolver); | |||
} | |||
private String getPFMURI(String pfbURI) { | |||
@@ -79,7 +79,7 @@ public class Type1FontLoader extends FontLoader { | |||
for (int i = 0; i < AFM_EXTENSIONS.length; i++) { | |||
try { | |||
afmUri = partialAfmUri + AFM_EXTENSIONS[i]; | |||
afmIn = resolver.resolveIn(afmUri); | |||
afmIn = resourceResolver.getResource(afmUri); | |||
if (afmIn != null) { | |||
break; | |||
} | |||
@@ -102,7 +102,7 @@ public class Type1FontLoader extends FontLoader { | |||
String pfmUri = getPFMURI(fontFileStr); | |||
InputStream pfmIn = null; | |||
try { | |||
pfmIn = resolver.resolveIn(pfmUri); | |||
pfmIn = resourceResolver.getResource(pfmUri); | |||
} catch (IOException ioe) { | |||
// Ignore, PFM probably not available under the URI | |||
} catch (URISyntaxException e) { | |||
@@ -134,7 +134,7 @@ public class Type1FontLoader extends FontLoader { | |||
if (afm == null && pfm == null) { | |||
throw new IllegalArgumentException("Need at least an AFM or a PFM!"); | |||
} | |||
singleFont = new SingleByteFont(resolver); | |||
singleFont = new SingleByteFont(resourceResolver); | |||
singleFont.setFontType(FontType.TYPE1); | |||
if (this.embedded) { | |||
singleFont.setEmbedURI(this.fontFileURI); |
@@ -32,7 +32,7 @@ import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.logging.Log; | |||
import org.apache.commons.logging.LogFactory; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
/** | |||
* <p>This class is the main entry point to the hyphenation package. | |||
@@ -69,12 +69,12 @@ public final class Hyphenator { | |||
* The hyphenation trees are cached. | |||
* @param lang the language | |||
* @param country the country (may be null or "none") | |||
* @param resolver resolver to find the hyphenation files | |||
* @param resourceResolver resolver to find the hyphenation files | |||
* @param hyphPatNames the map with user-configured hyphenation pattern file names | |||
* @return the hyphenation tree | |||
*/ | |||
public static HyphenationTree getHyphenationTree(String lang, | |||
String country, URIResolverWrapper resolver, Map hyphPatNames) { | |||
String country, InternalResourceResolver resourceResolver, Map hyphPatNames) { | |||
String llccKey = HyphenationTreeCache.constructLlccKey(lang, country); | |||
HyphenationTreeCache cache = getHyphenationTreeCache(); | |||
@@ -83,13 +83,13 @@ public final class Hyphenator { | |||
return null; | |||
} | |||
HyphenationTree hTree = getHyphenationTree2(lang, country, resolver, hyphPatNames); | |||
HyphenationTree hTree = getHyphenationTree2(lang, country, resourceResolver, hyphPatNames); | |||
// fallback to lang only | |||
if (hTree == null && country != null && !country.equals("none")) { | |||
String llKey = HyphenationTreeCache.constructLlccKey(lang, null); | |||
if (!cache.isMissing(llKey)) { | |||
hTree = getHyphenationTree2(lang, null, resolver, hyphPatNames); | |||
hTree = getHyphenationTree2(lang, null, resourceResolver, hyphPatNames); | |||
if (hTree != null && log.isDebugEnabled()) { | |||
log.debug("Couldn't find hyphenation pattern " | |||
+ "for lang=\"" + lang + "\",country=\"" + country + "\"." | |||
@@ -125,12 +125,12 @@ public final class Hyphenator { | |||
* The hyphenation trees are cached. | |||
* @param lang the language | |||
* @param country the country (may be null or "none") | |||
* @param resolver resolver to find the hyphenation files | |||
* @param resourceResolver resource resolver to find the hyphenation files | |||
* @param hyphPatNames the map with user-configured hyphenation pattern file names | |||
* @return the hyphenation tree | |||
*/ | |||
public static HyphenationTree getHyphenationTree2(String lang, | |||
String country, URIResolverWrapper resolver, Map hyphPatNames) { | |||
String country, InternalResourceResolver resourceResolver, Map hyphPatNames) { | |||
String llccKey = HyphenationTreeCache.constructLlccKey(lang, country); | |||
HyphenationTreeCache cache = getHyphenationTreeCache(); | |||
@@ -146,8 +146,8 @@ public final class Hyphenator { | |||
key = llccKey; | |||
} | |||
if (resolver != null) { | |||
hTree = getUserHyphenationTree(key, resolver); | |||
if (resourceResolver != null) { | |||
hTree = getUserHyphenationTree(key, resourceResolver); | |||
} | |||
if (hTree == null) { | |||
hTree = getFopHyphenationTree(key); | |||
@@ -229,11 +229,11 @@ public final class Hyphenator { | |||
* Load tree from serialized file or xml file | |||
* using configuration settings | |||
* @param key language key for the requested hyphenation file | |||
* @param resolver resolver to find the hyphenation files | |||
* @param resourceResolver resource resolver to find the hyphenation files | |||
* @return the requested HypenationTree or null if it is not available | |||
*/ | |||
public static HyphenationTree getUserHyphenationTree(String key, | |||
URIResolverWrapper resolver) { | |||
InternalResourceResolver resourceResolver) { | |||
HyphenationTree hTree = null; | |||
// I use here the following convention. The file name specified in | |||
// the configuration is taken as the base name. First we try | |||
@@ -243,7 +243,7 @@ public final class Hyphenator { | |||
// first try serialized object | |||
String name = key + ".hyp"; | |||
try { | |||
InputStream in = getHyphenationTreeStream(name, resolver); | |||
InputStream in = getHyphenationTreeStream(name, resourceResolver); | |||
try { | |||
hTree = readHyphenationTree(in); | |||
} finally { | |||
@@ -260,7 +260,7 @@ public final class Hyphenator { | |||
name = key + ".xml"; | |||
hTree = new HyphenationTree(); | |||
try { | |||
InputStream in = getHyphenationTreeStream(name, resolver); | |||
InputStream in = getHyphenationTreeStream(name, resourceResolver); | |||
try { | |||
InputSource src = new InputSource(in); | |||
src.setSystemId(name); | |||
@@ -284,10 +284,10 @@ public final class Hyphenator { | |||
} | |||
} | |||
private static InputStream getHyphenationTreeStream(String name, URIResolverWrapper resolver) | |||
throws IOException { | |||
private static InputStream getHyphenationTreeStream(String name, | |||
InternalResourceResolver resourceResolver) throws IOException { | |||
try { | |||
return new BufferedInputStream(resolver.resolveIn(name)); | |||
return new BufferedInputStream(resourceResolver.getResource(name)); | |||
} catch (URISyntaxException use) { | |||
log.debug("An exception was thrown while attempting to load " + name, use); | |||
} | |||
@@ -298,7 +298,7 @@ public final class Hyphenator { | |||
* Hyphenates a word. | |||
* @param lang the language | |||
* @param country the optional country code (may be null or "none") | |||
* @param resolver resolver to find the hyphenation files | |||
* @param resourceResolver resource resolver to find the hyphenation files | |||
* @param hyphPatNames the map with user-configured hyphenation pattern file names | |||
* @param word the word to hyphenate | |||
* @param leftMin the minimum number of characters before the hyphenation point | |||
@@ -306,8 +306,9 @@ public final class Hyphenator { | |||
* @return the hyphenation result | |||
*/ | |||
public static Hyphenation hyphenate(String lang, String country, | |||
URIResolverWrapper resolver, Map hyphPatNames, String word, int leftMin, int rightMin) { | |||
HyphenationTree hTree = getHyphenationTree(lang, country, resolver, hyphPatNames); | |||
InternalResourceResolver resourceResolver, Map hyphPatNames, String word, int leftMin, | |||
int rightMin) { | |||
HyphenationTree hTree = getHyphenationTree(lang, country, resourceResolver, hyphPatNames); | |||
if (hTree == null) { | |||
return null; | |||
} |
@@ -1398,7 +1398,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager | |||
// on an inline or wrapper below the block level. | |||
Hyphenation hyph = Hyphenator.hyphenate(hyphenationProperties.language.getString(), | |||
hyphenationProperties.country.getString(), | |||
getFObj().getUserAgent().getNewURIResolver(), | |||
getFObj().getUserAgent().getResourceResolver(), | |||
getFObj().getUserAgent().getHyphPatNames(), | |||
sbChars.toString(), | |||
hyphenationProperties.hyphenationRemainCharacterCount.getValue(), |
@@ -92,7 +92,7 @@ public abstract class PrintRenderer extends AbstractRenderer { | |||
FontManager fontManager = userAgent.getFontManager(); | |||
FontCollection[] fontCollections = new FontCollection[] { | |||
new Base14FontCollection(fontManager.isBase14KerningEnabled()), | |||
new CustomFontCollection(fontManager.getURIResolver(), getFontList(), | |||
new CustomFontCollection(fontManager.getResourceResolver(), getFontList(), | |||
userAgent.isComplexScriptFeaturesEnabled()) | |||
}; | |||
fontManager.setup(getFontInfo(), fontCollections); |
@@ -27,7 +27,7 @@ import org.apache.commons.logging.LogFactory; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.apps.FOUserAgent; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.CustomFontCollection; | |||
import org.apache.fop.fonts.DefaultFontConfigurator; | |||
import org.apache.fop.fonts.EmbedFontInfo; | |||
@@ -108,13 +108,13 @@ public abstract class PrintRendererConfigurator extends AbstractRendererConfigur | |||
public void setupFontInfo(String mimeType, FontInfo fontInfo) throws FOPException { | |||
FontManager fontManager = userAgent.getFontManager(); | |||
List<FontCollection> fontCollections = getDefaultFontCollection(); | |||
fontCollections.add(getCustomFontCollection(fontManager.getURIResolver(), mimeType)); | |||
fontCollections.add(getCustomFontCollection(fontManager.getResourceResolver(), mimeType)); | |||
fontManager.setup(fontInfo, fontCollections.toArray(new FontCollection[fontCollections.size()])); | |||
} | |||
protected abstract List<FontCollection> getDefaultFontCollection(); | |||
protected FontCollection getCustomFontCollection(URIResolverWrapper uriResolverWrapper, String mimeType) | |||
protected FontCollection getCustomFontCollection(InternalResourceResolver resolver, String mimeType) | |||
throws FOPException { | |||
List<EmbedFontInfo> fontList; | |||
if (rendererConfigParser == null) { | |||
@@ -122,12 +122,12 @@ public abstract class PrintRendererConfigurator extends AbstractRendererConfigur | |||
} else { | |||
fontList = fontInfoConfigurator.configure(getRendererConfig(mimeType).getFontInfoConfig()); | |||
} | |||
return createCollectionFromFontList(uriResolverWrapper, fontList); | |||
return createCollectionFromFontList(resolver, fontList); | |||
} | |||
protected FontCollection createCollectionFromFontList(URIResolverWrapper uriResolverWrapper, | |||
protected FontCollection createCollectionFromFontList(InternalResourceResolver resolver, | |||
List<EmbedFontInfo> fontList) { | |||
return new CustomFontCollection(uriResolverWrapper, fontList, | |||
return new CustomFontCollection(resolver, fontList, | |||
userAgent.isComplexScriptFeaturesEnabled()); | |||
} | |||
@@ -104,7 +104,7 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler | |||
*/ | |||
public AFPDocumentHandler(IFContext context) { | |||
super(context); | |||
this.resourceManager = new AFPResourceManager(context.getUserAgent().getNewURIResolver()); | |||
this.resourceManager = new AFPResourceManager(context.getUserAgent().getResourceResolver()); | |||
this.paintingState = new AFPPaintingState(); | |||
this.unitConv = paintingState.getUnitConverter(); | |||
} | |||
@@ -386,7 +386,7 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler | |||
} else if (extension instanceof AFPIncludeFormMap) { | |||
AFPIncludeFormMap formMap = (AFPIncludeFormMap)extension; | |||
AFPResourceAccessor accessor = new AFPResourceAccessor( | |||
getUserAgent().getNewURIResolver()); | |||
getUserAgent().getResourceResolver()); | |||
try { | |||
getResourceManager().createIncludedResource(formMap.getName(), | |||
formMap.getSrc(), accessor, |
@@ -40,7 +40,7 @@ import org.apache.fop.afp.fonts.OutlineFont; | |||
import org.apache.fop.afp.fonts.RasterFont; | |||
import org.apache.fop.afp.util.AFPResourceAccessor; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.events.EventProducer; | |||
import org.apache.fop.fonts.FontConfig; | |||
import org.apache.fop.fonts.FontManager; | |||
@@ -302,11 +302,11 @@ public final class AFPFontConfig implements FontConfig { | |||
return font != null ? new AFPFontInfo(font, config.triplets) : null; | |||
} | |||
abstract AFPFontInfo getFontInfo(URIResolverWrapper resolver, AFPEventProducer eventProducer) | |||
throws IOException; | |||
abstract AFPFontInfo getFontInfo(InternalResourceResolver resourceResolver, | |||
AFPEventProducer eventProducer) throws IOException; | |||
AFPResourceAccessor getAccessor(URIResolverWrapper resolver) { | |||
return new AFPResourceAccessor(resolver, uri); | |||
AFPResourceAccessor getAccessor(InternalResourceResolver resourceResolver) { | |||
return new AFPResourceAccessor(resourceResolver, uri); | |||
} | |||
} | |||
@@ -324,9 +324,9 @@ public final class AFPFontConfig implements FontConfig { | |||
} | |||
@Override | |||
AFPFontInfo getFontInfo(URIResolverWrapper resolver, AFPEventProducer eventProducer) | |||
AFPFontInfo getFontInfo(InternalResourceResolver resourceResolver, AFPEventProducer eventProducer) | |||
throws IOException { | |||
AFPResourceAccessor accessor = getAccessor(resolver); | |||
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), | |||
@@ -346,7 +346,7 @@ public final class AFPFontConfig implements FontConfig { | |||
} | |||
@Override | |||
AFPFontInfo getFontInfo(URIResolverWrapper resolver, AFPEventProducer eventProducer) | |||
AFPFontInfo getFontInfo(InternalResourceResolver resourceResolver, AFPEventProducer eventProducer) | |||
throws IOException { | |||
CharacterSet characterSet = null; | |||
if (base14 != null) { | |||
@@ -370,7 +370,7 @@ public final class AFPFontConfig implements FontConfig { | |||
LOG.error(msg); | |||
} | |||
} else { | |||
AFPResourceAccessor accessor = getAccessor(resolver); | |||
AFPResourceAccessor accessor = getAccessor(resourceResolver); | |||
characterSet = CharacterSetBuilder.getSingleByteInstance().buildSBCS( | |||
characterset, super.codePage, super.encoding, accessor, eventProducer); | |||
} | |||
@@ -389,7 +389,7 @@ public final class AFPFontConfig implements FontConfig { | |||
} | |||
@Override | |||
AFPFontInfo getFontInfo(URIResolverWrapper resolver, AFPEventProducer eventProducer) | |||
AFPFontInfo getFontInfo(InternalResourceResolver resourceResolver, AFPEventProducer eventProducer) | |||
throws IOException { | |||
RasterFont rasterFont = new RasterFont(super.name, super.embeddable); | |||
for (RasterCharactersetData charset : charsets) { | |||
@@ -415,7 +415,7 @@ public final class AFPFontConfig implements FontConfig { | |||
LOG.error(msg); | |||
} | |||
} else { | |||
AFPResourceAccessor accessor = getAccessor(resolver); | |||
AFPResourceAccessor accessor = getAccessor(resourceResolver); | |||
rasterFont.addCharacterSet(charset.size, | |||
CharacterSetBuilder.getSingleByteInstance().buildSBCS(charset.characterset, | |||
super.codePage, super.encoding, accessor, eventProducer)); |
@@ -203,7 +203,7 @@ public class AFPPainter extends AbstractIFPainter { | |||
//Do we need to embed an external page segment? | |||
if (pageSegment.getURI() != null) { | |||
AFPResourceAccessor accessor = new AFPResourceAccessor( | |||
documentHandler.getUserAgent().getNewURIResolver()); | |||
documentHandler.getUserAgent().getResourceResolver()); | |||
try { | |||
URI resourceUri = new URI(pageSegment.getURI()); | |||
documentHandler.getResourceManager().createIncludedResourceFromExternal( |
@@ -32,7 +32,7 @@ import org.apache.fop.afp.fonts.AFPFontCollection; | |||
import org.apache.fop.afp.fonts.AFPFontInfo; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.apps.FOUserAgent; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.FontCollection; | |||
import org.apache.fop.render.PrintRendererConfigurator; | |||
import org.apache.fop.render.RendererConfig.RendererConfigParser; | |||
@@ -128,7 +128,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator implement | |||
} | |||
@Override | |||
protected FontCollection getCustomFontCollection(URIResolverWrapper uriResolverWrapper, | |||
protected FontCollection getCustomFontCollection(InternalResourceResolver uriResolverWrapper, | |||
String mimeType) throws FOPException { | |||
AFPRendererConfig config = (AFPRendererConfig) getRendererConfig(mimeType); | |||
if (config != null) { | |||
@@ -150,7 +150,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator implement | |||
throws FOPException, IOException { | |||
List<AFPFontInfo> afpFonts = new ArrayList<AFPFontInfo>(); | |||
for (AFPFontConfigData config : fontConfig.getFontConfig()) { | |||
afpFonts.add(config.getFontInfo(userAgent.getFontManager().getURIResolver(), | |||
afpFonts.add(config.getFontInfo(userAgent.getFontManager().getResourceResolver(), | |||
eventProducer)); | |||
} | |||
return afpFonts; |
@@ -24,7 +24,7 @@ import java.util.List; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.apps.FOUserAgent; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.EmbedFontInfo; | |||
import org.apache.fop.fonts.FontCollection; | |||
import org.apache.fop.render.RendererConfig.RendererConfigParser; | |||
@@ -85,9 +85,9 @@ public class BitmapRendererConfigurator extends Java2DRendererConfigurator { | |||
} | |||
@Override | |||
protected FontCollection createCollectionFromFontList(URIResolverWrapper uriResolverWrapper, | |||
protected FontCollection createCollectionFromFontList(InternalResourceResolver resourceResolver, | |||
List<EmbedFontInfo> fontList) { | |||
return new ConfiguredFontCollection(uriResolverWrapper, fontList, userAgent.isComplexScriptFeaturesEnabled()); | |||
return new ConfiguredFontCollection(resourceResolver, fontList, userAgent.isComplexScriptFeaturesEnabled()); | |||
} | |||
@Override |
@@ -64,7 +64,7 @@ public abstract class AbstractBinaryWritingIFDocumentHandler extends AbstractIFD | |||
} | |||
try { | |||
URI resultURI = URI.create(streamResult.getSystemId()); | |||
out = new BufferedOutputStream(getUserAgent().getNewURIResolver().resolveOut(resultURI)); | |||
out = new BufferedOutputStream(getUserAgent().getResourceResolver().getOutputStream(resultURI)); | |||
} catch (IOException ioe) { | |||
throw new IFException("I/O error while opening output stream" , ioe); | |||
} |
@@ -26,7 +26,7 @@ import java.util.List; | |||
import org.apache.commons.logging.Log; | |||
import org.apache.commons.logging.LogFactory; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.CustomFont; | |||
import org.apache.fop.fonts.EmbedFontInfo; | |||
import org.apache.fop.fonts.EncodingMode; | |||
@@ -43,19 +43,19 @@ public class ConfiguredFontCollection implements FontCollection { | |||
private static Log log = LogFactory.getLog(ConfiguredFontCollection.class); | |||
private final URIResolverWrapper uriResolver; | |||
private final InternalResourceResolver resourceResolver; | |||
private final List<EmbedFontInfo> embedFontInfoList; | |||
private final boolean useComplexScripts; | |||
/** | |||
* Main constructor | |||
* @param uriResolver a font resolver | |||
* @param resourceResolver a font resolver | |||
* @param customFonts the list of custom fonts | |||
* @param useComplexScriptFeatures true if complex script features enabled | |||
*/ | |||
public ConfiguredFontCollection(URIResolverWrapper uriResolver, | |||
public ConfiguredFontCollection(InternalResourceResolver resourceResolver, | |||
List<EmbedFontInfo> customFonts, boolean useComplexScriptFeatures) { | |||
this.uriResolver = uriResolver; | |||
this.resourceResolver = resourceResolver; | |||
this.embedFontInfoList = customFonts; | |||
this.useComplexScripts = useComplexScriptFeatures; | |||
} | |||
@@ -78,14 +78,14 @@ public class ConfiguredFontCollection implements FontCollection { | |||
// If the user specified an XML-based metrics file, we'll use it | |||
// Otherwise, calculate metrics directly from the font file. | |||
if (metricsURI != null) { | |||
LazyFont fontMetrics = new LazyFont(configFontInfo, uriResolver, useComplexScripts); | |||
InputStream fontSource = uriResolver.resolveIn(fontURI); | |||
LazyFont fontMetrics = new LazyFont(configFontInfo, resourceResolver, useComplexScripts); | |||
InputStream fontSource = resourceResolver.getResource(fontURI); | |||
font = new CustomFontMetricsMapper(fontMetrics, fontSource); | |||
} else { | |||
CustomFont fontMetrics = FontLoader.loadFont( | |||
fontURI, null, true, EncodingMode.AUTO, | |||
configFontInfo.getKerning(), | |||
configFontInfo.getAdvanced(), uriResolver); | |||
configFontInfo.getAdvanced(), resourceResolver); | |||
font = new CustomFontMetricsMapper(fontMetrics); | |||
} | |||
@@ -180,7 +180,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem | |||
FontCollection[] fontCollections = new FontCollection[] { | |||
new Base14FontCollection(java2DFontMetrics), | |||
new InstalledFontCollection(java2DFontMetrics), | |||
new ConfiguredFontCollection(fontManager.getURIResolver(), getFontList(), | |||
new ConfiguredFontCollection(fontManager.getResourceResolver(), getFontList(), | |||
userAgent.isComplexScriptFeaturesEnabled()) | |||
}; | |||
fontManager.setup(getFontInfo(), fontCollections); |
@@ -23,7 +23,7 @@ import java.util.List; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.apps.FOUserAgent; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.EmbedFontInfo; | |||
import org.apache.fop.fonts.FontCollection; | |||
import org.apache.fop.render.PrintRendererConfigurator; | |||
@@ -81,9 +81,9 @@ public class PCLRendererConfigurator extends PrintRendererConfigurator | |||
} | |||
@Override | |||
protected FontCollection createCollectionFromFontList(URIResolverWrapper uriResolverWrapper, | |||
protected FontCollection createCollectionFromFontList(InternalResourceResolver resourceResolver, | |||
List<EmbedFontInfo> fontList) { | |||
return new ConfiguredFontCollection(uriResolverWrapper, fontList, | |||
return new ConfiguredFontCollection(resourceResolver, fontList, | |||
userAgent.isComplexScriptFeaturesEnabled()); | |||
} | |||
@@ -149,7 +149,7 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { | |||
final OutputStream out; | |||
if (psUtil.isOptimizeResources()) { | |||
tempURI = TEMP_URI_GENERATOR.generate(); | |||
out = new BufferedOutputStream(getUserAgent().getNewURIResolver().resolveOut(tempURI)); | |||
out = new BufferedOutputStream(getUserAgent().getResourceResolver().getOutputStream(tempURI)); | |||
} else { | |||
out = this.outputStream; | |||
} | |||
@@ -256,7 +256,7 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { | |||
log.debug("Processing PostScript resources..."); | |||
long startTime = System.currentTimeMillis(); | |||
ResourceTracker resTracker = gen.getResourceTracker(); | |||
InputStream in = new BufferedInputStream(getUserAgent().getNewURIResolver().resolveIn(tempURI)); | |||
InputStream in = new BufferedInputStream(getUserAgent().getResourceResolver().getResource(tempURI)); | |||
try { | |||
try { | |||
ResourceHandler handler = new ResourceHandler(getUserAgent(), this.fontInfo, |
@@ -168,7 +168,7 @@ public class RTFHandler extends FOEventHandler { | |||
bDefer = true; | |||
boolean base14Kerning = false; | |||
FontSetup.setup(fontInfo, null, userAgent.getNewURIResolver(), base14Kerning); | |||
FontSetup.setup(fontInfo, null, userAgent.getResourceResolver(), base14Kerning); | |||
} | |||
/** |
@@ -26,7 +26,7 @@ import org.apache.avalon.framework.configuration.ConfigurationException; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.apps.io.ResourceResolverFactory; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.DefaultFontConfig; | |||
import org.apache.fop.fonts.DefaultFontConfigurator; | |||
import org.apache.fop.fonts.EmbedFontInfo; | |||
@@ -85,9 +85,9 @@ public class PDFDocumentGraphics2DConfigurator { | |||
FontInfo fontInfo = new FontInfo(); | |||
final boolean strict = false; | |||
if (cfg != null) { | |||
URIResolverWrapper resolver = ResourceResolverFactory.createDefaultWrapper(); | |||
InternalResourceResolver resourceResolver = ResourceResolverFactory.createDefaultWrapper(); | |||
//TODO The following could be optimized by retaining the FontManager somewhere | |||
FontManager fontManager = new FontManager(resolver, FontDetectorFactory.createDefault(), | |||
FontManager fontManager = new FontManager(resourceResolver, FontDetectorFactory.createDefault(), | |||
FontCacheManagerFactory.createDefault()); | |||
//TODO Make use of fontBaseURL, font substitution and referencing configuration | |||
@@ -101,7 +101,7 @@ public class PDFDocumentGraphics2DConfigurator { | |||
= new DefaultFontConfigurator(fontManager, listener, strict); | |||
List<EmbedFontInfo> fontInfoList = fontInfoConfigurator.configure(fontInfoConfig); | |||
fontManager.saveCache(); | |||
FontSetup.setup(fontInfo, fontInfoList, resolver, useComplexScriptFeatures); | |||
FontSetup.setup(fontInfo, fontInfoList, resourceResolver, useComplexScriptFeatures); | |||
} else { | |||
FontSetup.setup(fontInfo, useComplexScriptFeatures); | |||
} |
@@ -32,7 +32,7 @@ import org.apache.commons.logging.LogFactory; | |||
import org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent; | |||
import org.apache.xmlgraphics.java2d.color.RenderingIntent; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
/** | |||
* Map with cached ICC based ColorSpace objects. | |||
@@ -41,15 +41,15 @@ public class ColorSpaceCache { | |||
/** logger instance */ | |||
private static Log log = LogFactory.getLog(ColorSpaceCache.class); | |||
private URIResolverWrapper resolver; | |||
private InternalResourceResolver resourceResolver; | |||
private Map<String, ColorSpace> colorSpaceMap = Collections.synchronizedMap(new HashMap<String, ColorSpace>()); | |||
/** | |||
* Default constructor | |||
* @param resolver uri resolver | |||
* @param resourceResolver uri resolver | |||
*/ | |||
public ColorSpaceCache(URIResolverWrapper resolver) { | |||
this.resolver = resolver; | |||
public ColorSpaceCache(InternalResourceResolver resourceResolver) { | |||
this.resourceResolver = resourceResolver; | |||
} | |||
/** | |||
@@ -77,7 +77,7 @@ public class ColorSpaceCache { | |||
ICC_Profile iccProfile = null; | |||
// First attempt to use the FOP URI resolver to locate the ICC | |||
// profile | |||
InputStream stream = resolver.resolveIn(iccProfileSrc); | |||
InputStream stream = resourceResolver.getResource(iccProfileSrc); | |||
if (stream != null) { | |||
// FOP URI resolver found ICC profile - create ICC profile | |||
// from the Source |
@@ -90,7 +90,7 @@ public class MIFHandler extends FOEventHandler { | |||
super(ua); | |||
outStream = os; | |||
boolean base14Kerning = false; //TODO - FIXME | |||
FontSetup.setup(fontInfo, null, ua.getNewURIResolver(), base14Kerning); | |||
FontSetup.setup(fontInfo, null, ua.getResourceResolver(), base14Kerning); | |||
} | |||
/** {@inheritDoc} */ |
@@ -85,8 +85,8 @@ public class URIResolverWrapperTestCase { | |||
@Test | |||
public void getBaseURI() throws URISyntaxException { | |||
assertEquals(URIResolverWrapper.getBaseURI("x/y/z/"), new URI("x/y/z/")); | |||
assertEquals(URIResolverWrapper.getBaseURI("x/y/z"), new URI("x/y/z/")); | |||
assertEquals(InternalResourceResolver.getBaseURI("x/y/z/"), new URI("x/y/z/")); | |||
assertEquals(InternalResourceResolver.getBaseURI("x/y/z"), new URI("x/y/z/")); | |||
} | |||
@Test | |||
@@ -94,19 +94,19 @@ public class URIResolverWrapperTestCase { | |||
String[] uris = new String[] {".", "path/to/resource", "path\\to\\resource", | |||
"bad resource name"}; | |||
for (String uri : uris) { | |||
assertEquals(URIResolverWrapper.cleanURI(uri), cleanURI(uri)); | |||
assertEquals(InternalResourceResolver.cleanURI(uri), cleanURI(uri)); | |||
} | |||
assertNull(URIResolverWrapper.cleanURI(null)); | |||
assertNull(InternalResourceResolver.cleanURI(null)); | |||
} | |||
private void test(String uriStr, URI uri, URI expected) throws IOException, URISyntaxException { | |||
ResourceResolver resolver = mock(ResourceResolver.class); | |||
URIResolverWrapper sut = new URIResolverWrapper(base, resolver); | |||
sut.resolveIn(uriStr); | |||
InternalResourceResolver sut = new InternalResourceResolver(base, resolver); | |||
sut.getResource(uriStr); | |||
verify(resolver).getResource(eq(expected)); | |||
resolver = mock(ResourceResolver.class); | |||
sut = new URIResolverWrapper(base, resolver); | |||
sut.resolveIn(uri); | |||
sut = new InternalResourceResolver(base, resolver); | |||
sut.getResource(uri); | |||
verify(resolver).getResource(eq(expected)); | |||
} | |||
@@ -66,7 +66,7 @@ public class FontsSubstitutionTestCase extends BaseConstructiveUserConfigTest { | |||
FontManager fontManager = ua.getFontManager(); | |||
FontCollection[] fontCollections = new FontCollection[] { | |||
new Base14FontCollection(fontManager.isBase14KerningEnabled()), | |||
new CustomFontCollection(fontManager.getURIResolver(), renderer.getFontList(), | |||
new CustomFontCollection(fontManager.getResourceResolver(), renderer.getFontList(), | |||
ua.isComplexScriptFeaturesEnabled()) | |||
}; | |||
fontManager.setup(fontInfo, fontCollections); |
@@ -25,7 +25,7 @@ import org.junit.Before; | |||
import org.junit.Test; | |||
import org.apache.fop.apps.io.ResourceResolverFactory; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import static org.junit.Assert.assertEquals; | |||
@@ -34,7 +34,7 @@ import static org.junit.Assert.assertEquals; | |||
*/ | |||
public class DejaVuLGCSerifTestCase { | |||
private URIResolverWrapper resolver = new URIResolverWrapper(new File(".").toURI(), | |||
private InternalResourceResolver resolver = new InternalResourceResolver(new File(".").toURI(), | |||
ResourceResolverFactory.createDefaultResourceResolver()); | |||
private CustomFont font; | |||
@@ -71,14 +71,14 @@ public class FontManagerConfiguratorTestCase { | |||
String actualBase = "../../resources/fonts/ttf/"; | |||
FontManager fontManager = setBaseAndGetManager(actualBase); | |||
URI expectedURI = baseURI.resolve(actualBase); | |||
assertEquals(expectedURI, fontManager.getURIResolver().getBaseURI()); | |||
assertEquals(expectedURI, fontManager.getResourceResolver().getBaseURI()); | |||
} | |||
@Test | |||
public void currentRelativeFontBaseTest() { | |||
String actualBase = "."; | |||
FontManager fontManager = setBaseAndGetManager(actualBase); | |||
assertEquals(baseURI, fontManager.getURIResolver().getBaseURI()); | |||
assertEquals(baseURI, fontManager.getResourceResolver().getBaseURI()); | |||
} | |||
/** | |||
@@ -93,7 +93,7 @@ public class FontManagerConfiguratorTestCase { | |||
String actualBase = "non-existing-dir/"; | |||
FontManager fontManager = setBaseAndGetManager(actualBase); | |||
assertEquals(baseURI.resolve("non-existing-dir/"), | |||
fontManager.getURIResolver().getBaseURI()); | |||
fontManager.getResourceResolver().getBaseURI()); | |||
} | |||
/** | |||
@@ -105,13 +105,13 @@ public class FontManagerConfiguratorTestCase { | |||
builder.setBaseURI(actualBase); | |||
FontManager fontManager = getManager(); | |||
assertEquals(baseURI.resolve(actualBase), | |||
fontManager.getURIResolver().getBaseURI()); | |||
fontManager.getResourceResolver().getBaseURI()); | |||
} | |||
@Test | |||
public void absoluteBaseURI() { | |||
String absoluteBase = "test:///absolute/"; | |||
FontManager fontManager = setBaseAndGetManager(absoluteBase); | |||
assertEquals(URI.create(absoluteBase), fontManager.getURIResolver().getBaseURI()); | |||
assertEquals(URI.create(absoluteBase), fontManager.getResourceResolver().getBaseURI()); | |||
} | |||
} |
@@ -26,7 +26,7 @@ import java.net.URI; | |||
import org.junit.Test; | |||
import org.apache.fop.apps.io.ResourceResolverFactory; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.EncodingMode; | |||
import static org.junit.Assert.assertFalse; | |||
@@ -42,7 +42,7 @@ public class TTFFontLoaderTestCase { | |||
boolean useComplexScriptFeatures = false; | |||
File file = new File("test/resources/fonts/ttf/DejaVuLGCSerif.ttf"); | |||
URI absoluteFilePath = file.toURI(); | |||
URIResolverWrapper resolver = ResourceResolverFactory.createDefaultWrapper(); | |||
InternalResourceResolver resolver = ResourceResolverFactory.createDefaultWrapper(); | |||
String fontName = "Deja Vu"; | |||
boolean embedded = false; | |||
boolean useKerning = true; |
@@ -203,8 +203,8 @@ public class FOTreeTestCase { | |||
return delegate.getLayoutManagerMakerOverride(); | |||
} | |||
public ResourceResolver getNewURIResolver() { | |||
return delegate.getNewURIResolver(); | |||
public ResourceResolver getResourceResolver() { | |||
return delegate.getResourceResolver(); | |||
} | |||
public URI getBaseURI() { |
@@ -22,7 +22,7 @@ package org.apache.fop.pdf; | |||
import org.junit.Test; | |||
import org.apache.fop.apps.io.ResourceResolverFactory; | |||
import org.apache.fop.apps.io.URIResolverWrapper; | |||
import org.apache.fop.apps.io.InternalResourceResolver; | |||
import org.apache.fop.fonts.CIDSubset; | |||
import org.apache.fop.fonts.MultiByteFont; | |||
@@ -40,7 +40,7 @@ public class PDFFactoryTestCase { | |||
@Test | |||
public void testSubsetFontNamePrefix() { | |||
class MockedFont extends MultiByteFont { | |||
public MockedFont(URIResolverWrapper resolver) { | |||
public MockedFont(InternalResourceResolver resolver) { | |||
super(resolver); | |||
} | |||