[ 
https://issues.apache.org/jira/browse/FOP-3054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17499956#comment-17499956
 ] 

Simon Steiner commented on FOP-3054:
------------------------------------

2nd example using EnvironmentalProfile avoids dealing with font manager

> FOP Customer Resolver not invoked in version 2.7
> ------------------------------------------------
>
>                 Key: FOP-3054
>                 URL: https://issues.apache.org/jira/browse/FOP-3054
>             Project: FOP
>          Issue Type: Bug
>    Affects Versions: 2.7
>            Reporter: tntim96
>            Assignee: Simon Steiner
>            Priority: Major
>
> The following FOP config and customer resolver works with FOP 2.6
> {code:java}
> ResourceResolver rr = ResourceResolverFactory
>     .createTempAwareResourceResolver(new InMemoryTempResourceResolver(), new 
> CustomResolver());
> {code}
> {code:java}
> class CustomResolver implements ResourceResolver {
>   public org.apache.xmlgraphics.io.Resource getResource(URI uri) throws 
> IOException {
>     if (uri.toString().startsWith("classpath:")) {
>       String actualPath = uri.toString().substring("classpath:".length());
>       try {
>         ClassPathResource resource = new ClassPathResource(actualPath);
>         InputStream resourceAsStream = resource.getInputStream();
> {code}
> {code:java}
> <?xml version="1.0" encoding="utf-8" ?>
> <fop>
>   <renderers>
>     <renderer mime="application/pdf">
>       <fonts>
>         <font kerning="yes" 
> embed-url="classpath:/somepath/DejaVuSans-Regular.ttf">
>           <font-triplet name="DejaVuSans" style="normal" weight="normal"/>
>         </font>
>       </fonts>
>     </renderer>
>   </renderers>
> </fop> {code}
> ...but with 2.7 we get the error:
> {noformat}
> 16:04:03.006 [main] ERROR org.apache.fop.fonts.LazyFont - Failed to read font 
> file classpath:/somepath/DejaVuSans-Regular.ttf unknown protocol: classpath
> java.net.MalformedURLException: unknown protocol: classpath
>     at java.net.URL.<init>(URL.java:600)
>     at java.net.URL.<init>(URL.java:490)
>     at java.net.URL.<init>(URL.java:439)
>     at java.net.URI.toURL(URI.java:1089)
>     at 
> org.apache.fop.apps.io.ResourceResolverFactory$NormalResourceResolver.getResource(ResourceResolverFactory.java:224)
>     at 
> org.apache.fop.apps.io.ResourceResolverFactory$TempAwareResourceResolver.getResource(ResourceResolverFactory.java:152)
>     at 
> org.apache.fop.apps.io.ResourceResolverFactory$DefaultResourceResolver.getResource(ResourceResolverFactory.java:121)
>     at 
> org.apache.fop.apps.io.InternalResourceResolver.getResource(InternalResourceResolver.java:92)
>     at org.apache.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:113)
>     at org.apache.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:103)
>     at org.apache.fop.fonts.FontLoader.getFont(FontLoader.java:126)
>     at org.apache.fop.fonts.FontLoader.loadFont(FontLoader.java:110)
>     at org.apache.fop.fonts.LazyFont.load(LazyFont.java:121)
>     at org.apache.fop.fonts.LazyFont.getAscender(LazyFont.java:237)
>     at org.apache.fop.fonts.Font.getAscender(Font.java:120)
>     at 
> org.apache.fop.layoutmgr.BlockLayoutManager.initialize(BlockLayoutManager.java:82)
>     at 
> org.apache.fop.layoutmgr.AbstractLayoutManager.getChildLM(AbstractLayoutManager.java:118)
>     at 
> org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:128)
>     at 
> org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:69)
>     at 
> org.apache.fop.layoutmgr.PageBreaker.getNextKnuthElements(PageBreaker.java:252)
>     at 
> org.apache.fop.layoutmgr.AbstractBreaker.getNextBlockList(AbstractBreaker.java:675)
> {noformat}
> It seems like our custom resolver is no longer invoked.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to