[jira] [Commented] (FOP-2857) FontCache.toDirectory() and FontCache.getDefaultCacheFile() work not correct

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (FOP-2857) FontCache.toDirectory() and FontCache.getDefaultCacheFile() work not correct

simon steiner (Jira)

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

simon steiner commented on FOP-2857:
------------------------------------

What about setting user.home to /tmp or

I think you use EnvironmentalProfileFactory.createRestrictedIO to disable font caching
{code:java}
        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}

> FontCache.toDirectory() and FontCache.getDefaultCacheFile() work not correct
> ----------------------------------------------------------------------------
>
>                 Key: FOP-2857
>                 URL: https://issues.apache.org/jira/browse/FOP-2857
>             Project: FOP
>          Issue Type: Bug
>          Components: font/unqualified
>    Affects Versions: 2.3
>            Reporter: Vera Straube
>            Priority: Critical
>         Attachments: FontCache.java.patch, FontCache.java.patch2
>
>
> The function getDefaultCacheFile() of the class FontCache should work like this:
> [1] case:       select user_dir
> -> user_dir:    'C:\Users\strv'
> -> temp_dir:    'C:\Users\strv\AppData\Local\Temp\'
> -> cache_file:  'C:\Users\strv\.fop\fop-fonts.cache'
> [2] case:       select temp_dir
> -> user_dir:    ''
> -> temp_dir:    'C:\Users\strv\AppData\Local\Temp\'
> -> cache_file:  'C:\Users\strv\AppData\Local\Temp\.fop\fop-fonts.cache'
> [3] case:       select curr_dir
> -> user_dir:    ''
> -> temp_dir:    ''
> -> cache_file:  'fop-fonts.cache'
> Actually it works uncorrectly like this:
> [1] case:       select user_dir
> -> user_dir:    'C:\Users\strv'
> -> temp_dir:    'C:\Users\strv\AppData\Local\Temp\'
> -> cache_file:  'C:\Users\strv\.fop\fop-fonts.cache'
> [2] case:       select temp_dir
> -> user_dir:    ''
> -> temp_dir:    'C:\Users\strv\AppData\Local\Temp\'
> -> cache_file:  '.fop'  --> wrong behavior !!!
> [3] case:       select curr_dir
> -> user_dir:    ''
> -> temp_dir:    ''
> -> cache_file:  '.fop'  --> wrong behavior !!!



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)