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

2015-12-18 Thread JIRA

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

Martin Hönings commented on FOP-2554:
-

See https://issues.apache.org/jira/browse/FOP-2532 for a correct solution.

> 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
>Priority: Minor
>  Labels: font, uri
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> config has following:
>   
>  embed-url="classpath:///fonts/arialuni.ttf">
>   
> 
> 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)


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

2015-12-18 Thread simon steiner (JIRA)

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

simon steiner commented on FOP-2554:


I think you use EnvironmentalProfileFactory.createRestrictedIO to disable font 
caching

{code}
String fopxconf = "";
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:
>   
>  embed-url="classpath:///fonts/arialuni.ttf">
>   
> 
> 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)