You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by "simon steiner (JIRA)" <ji...@apache.org> on 2015/12/18 14:58:46 UTC

[jira] [Commented] (FOP-2554) FopConfig permits file URI for fonts only

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

simon steiner commented on FOP-2554:
------------------------------------

I think you use EnvironmentalProfileFactory.createRestrictedIO to disable font caching

{code}
        String fopxconf = "<fop version=\"1.0\"></fop>";
        ResourceResolver cloudResourceResolver = ResourceResolverFactory.createDefaultResourceResolver();
        FopFactoryBuilder confBuilder = new FopConfParser(new ByteArrayInputStream(fopxconf.getBytes()),
                EnvironmentalProfileFactory.createRestrictedIO(new File(".").toURI(), cloudResourceResolver)).getFopFactoryBuilder();
        FopFactory fopFactory = confBuilder.build();
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        FileOutputStream fos = new FileOutputStream("out.png");
        Fop fop = fopFactory.newFop("image/png", foUserAgent, fos);
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer();
        Source src = new StreamSource(new ByteArrayInputStream(fo.getBytes()));
        Result res = new SAXResult(fop.getDefaultHandler());
        transformer.transform(src, res);
        fos.close();

{code}

> FopConfig permits file URI for fonts only
> -----------------------------------------
>
>                 Key: FOP-2554
>                 URL: https://issues.apache.org/jira/browse/FOP-2554
>             Project: FOP
>          Issue Type: Bug
>          Components: font/unqualified
>    Affects Versions: 2.0
>         Environment: all flatforms
>            Reporter: Mr. Povarnitsyn
>            Assignee: simon steiner
>            Priority: Minor
>              Labels: font, uri
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> config has following:
>       <fonts>
>         <font metrics-url="classpath:///fonts/arialuni.xml" kerning="yes" embed-url="classpath:///fonts/arialuni.ttf">
>           <font-triplet name="arialuni" style="normal" weight="normal"/>
>         </font>
> Exception on FontCache.java (line 335)
>                 File fontFile = new File(fontUri);
> My proposal:
> Instead:
>                 File fontFile = new File(fontUri);
>                 long lastModified = fontFile.lastModified();
>                 cachedFontFile = new CachedFontFile(lastModified);
> Write:
> 		long lastModified = 0L;
> 		if(fontUri.getScheme().equals("file")){
> 	                File fontFile = new File(fontUri);
>         	        lastModified = fontFile.lastModified();			
> 		}
>                 cachedFontFile = new CachedFontFile(lastModified);
> This code is working.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)