You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Jonathan Levinson <Jo...@intersystems.com> on 2010/08/13 23:38:17 UTC

Problem with creation of font cache on Windows 7 64 bit

On Windows XP, fop creates it font-cache in "C:\Documents and Settings\<username>\.fop".

I've had a couple of reports that on Windows 7 64 bit, fop puts its font cache in c:\.fop, a directory to which the user may not have write permissions.

Is this a known issue?

Is there a way of telling fop where to put the font cache?

Best Regards,
Jonathan Levinson


RE: RE: Problem with creation of font cache on Windows 7 64 bit

Posted by Jonathan Levinson <Jo...@intersystems.com>.
Hi,

Turning on tracing the problem is that while the font cache is being written to the temporary directory:

 [TRACE] FontCache - Writing font cache to C:\Documents and Settings\levinson\Local Settings\Temp\.fop\fop-fonts.cache

The font cache is never read from the temporary directory.  It is always read from the place user.home points to.   For the code to be able to use the temporary directory, it would have to check to see if there is no .fop directory in directory given by System property user.home and if there is no .fop directory look under the temporary directory for .fop.  I don't know if this would be an acceptable change.

Best Regards,
Jonathan Levinson

From: Jonathan Levinson [mailto:Jonathan.Levinson@intersystems.com]
Sent: Monday, August 16, 2010 1:58 PM
To: Adrian Cumiskey
Cc: fop-users@xmlgraphics.apache.org
Subject: RE: RE: Problem with creation of font cache on Windows 7 64 bit

Hi Adrian,

Thanks for your help!  I'm noticing behavior I did not expect after reading your code and reading https://issues.apache.org/bugzilla/show_bug.cgi?id=46686.

It looks like if "mkdir" fails, FOP will use the temp directory.   However testing this by pointing -Duser.home to a directory to which I do not have write permissions on Windows XP, I don't see any font cache created.  Instead, it seems like fonts are completely reloaded each time with the <auto-detect> feature under <fonts> turned on.

Reading the code, I see the following, which leads me to expect the temporary directory would be used.

  /**
     * Returns the default font cache file.
     * @param forWriting true if the user directory should be created
     * @return the default font cache file
     */
    public static File getDefaultCacheFile(boolean forWriting) {
        File userHome = getUserHome();
        if (userHome != null) {
            File fopUserDir = new File(userHome, FOP_USER_DIR);
            if (forWriting) {
                boolean writable = fopUserDir.canWrite();
                if (!fopUserDir.exists()) {
                    writable = fopUserDir.mkdir();
                }
                if (!writable) {
                    userHome = getTempDirectory();
                    fopUserDir = new File(userHome, FOP_USER_DIR);
                    fopUserDir.mkdir();
                }
            }
            return new File(fopUserDir, DEFAULT_CACHE_FILENAME);
        }
        return new File(FOP_USER_DIR);
    }


Best Regards,
Jonathan Levinson

From: adrian.cumiskey@gmail.com [mailto:adrian.cumiskey@gmail.com] On Behalf Of Adrian Cumiskey
Sent: Sunday, August 15, 2010 10:43 PM
To: Jonathan Levinson
Cc: fop-users@xmlgraphics.apache.org; adrian@cumiskey.com
Subject: Re: RE: Problem with creation of font cache on Windows 7 64 bit


Hi Jonathan,

Well spotted, yes that should work well also.  Although its a bit of a sneaky "back door" way of achieving it : -).

Cheers, Adrian.
On 2010-08-16 1:23 AM, "Jonathan Levinson" <Jo...@intersystems.com>> wrote:
Thank you Adrian!

Also I've noticed you can redirect the font-cache with the Java system property -Duser.home, so one can direct it to a different place by editing the JAVAOPTS set in fop.bat.

Best Regards,
Jonathan Levinson

From: Adrian Cumiskey [mailto:adrian.cumiskey@gmail.com<ma...@gmail.com>]
Sent: Sunday, August 15, 2010 12:28 PM
To: fop-users@xmlgraphics.apache.org<ma...@xmlgraphics.apache.org>
Subject: Re: Problem with creation of font cache on Windows 7 64 bit




Hi Jonathan,



I have just committed a fix to the missing "cache-file" configuration option (...

RE: RE: Problem with creation of font cache on Windows 7 64 bit

Posted by Jonathan Levinson <Jo...@intersystems.com>.
Hi Adrian,

Thanks for your help!  I'm noticing behavior I did not expect after reading your code and reading https://issues.apache.org/bugzilla/show_bug.cgi?id=46686.

It looks like if "mkdir" fails, FOP will use the temp directory.   However testing this by pointing -Duser.home to a directory to which I do not have write permissions on Windows XP, I don't see any font cache created.  Instead, it seems like fonts are completely reloaded each time with the <auto-detect> feature under <fonts> turned on.

Reading the code, I see the following, which leads me to expect the temporary directory would be used.

  /**
     * Returns the default font cache file.
     * @param forWriting true if the user directory should be created
     * @return the default font cache file
     */
    public static File getDefaultCacheFile(boolean forWriting) {
        File userHome = getUserHome();
        if (userHome != null) {
            File fopUserDir = new File(userHome, FOP_USER_DIR);
            if (forWriting) {
                boolean writable = fopUserDir.canWrite();
                if (!fopUserDir.exists()) {
                    writable = fopUserDir.mkdir();
                }
                if (!writable) {
                    userHome = getTempDirectory();
                    fopUserDir = new File(userHome, FOP_USER_DIR);
                    fopUserDir.mkdir();
                }
            }
            return new File(fopUserDir, DEFAULT_CACHE_FILENAME);
        }
        return new File(FOP_USER_DIR);
    }


Best Regards,
Jonathan Levinson

From: adrian.cumiskey@gmail.com [mailto:adrian.cumiskey@gmail.com] On Behalf Of Adrian Cumiskey
Sent: Sunday, August 15, 2010 10:43 PM
To: Jonathan Levinson
Cc: fop-users@xmlgraphics.apache.org; adrian@cumiskey.com
Subject: Re: RE: Problem with creation of font cache on Windows 7 64 bit


Hi Jonathan,

Well spotted, yes that should work well also.  Although its a bit of a sneaky "back door" way of achieving it : -).

Cheers, Adrian.
On 2010-08-16 1:23 AM, "Jonathan Levinson" <Jo...@intersystems.com>> wrote:
Thank you Adrian!

Also I've noticed you can redirect the font-cache with the Java system property -Duser.home, so one can direct it to a different place by editing the JAVAOPTS set in fop.bat.

Best Regards,
Jonathan Levinson

From: Adrian Cumiskey [mailto:adrian.cumiskey@gmail.com<ma...@gmail.com>]
Sent: Sunday, August 15, 2010 12:28 PM
To: fop-users@xmlgraphics.apache.org<ma...@xmlgraphics.apache.org>
Subject: Re: Problem with creation of font cache on Windows 7 64 bit




Hi Jonathan,



I have just committed a fix to the missing "cache-file" configuration option (...

Re: RE: Problem with creation of font cache on Windows 7 64 bit

Posted by Adrian Cumiskey <ad...@cumiskey.com>.
Hi Jonathan,

Well spotted, yes that should work well also.  Although its a bit of a
sneaky "back door" way of achieving it : -).

Cheers, Adrian.

On 2010-08-16 1:23 AM, "Jonathan Levinson" <
Jonathan.Levinson@intersystems.com> wrote:

 Thank you Adrian!



Also I’ve noticed you can redirect the font-cache with the Java system
property –Duser.home, so one can direct it to a different place by editing
the JAVAOPTS set in fop.bat.



Best Regards,

Jonathan Levinson



*From:* Adrian Cumiskey [mailto:adrian.cumiskey@gmail.com]
*Sent:* Sunday, August 15, 2010 12:28 PM
*To:* fop-users@xmlgraphics.apache.org
*Subject:* Re: Problem with creation of font cache on Windows 7 64 bit





Hi Jonathan,



I have just committed a fix to the missing "cache-file" configuration option
(...

RE: Problem with creation of font cache on Windows 7 64 bit

Posted by Jonathan Levinson <Jo...@intersystems.com>.
Thank you Adrian!

Also I've noticed you can redirect the font-cache with the Java system property -Duser.home, so one can direct it to a different place by editing the JAVAOPTS set in fop.bat.

Best Regards,
Jonathan Levinson

From: Adrian Cumiskey [mailto:adrian.cumiskey@gmail.com]
Sent: Sunday, August 15, 2010 12:28 PM
To: fop-users@xmlgraphics.apache.org
Subject: Re: Problem with creation of font cache on Windows 7 64 bit

Hi Jonathan,

I have just committed a fix to the missing "cache-file" configuration option (see http://xmlgraphics.apache.org/fop/1.0/configuration.html#general-elements) to the Fop trunk code.  All the documentation regarding font caching should now reflect the actual implementation.

I also added a convenience "-delete-cache" option to the Fop command line as quite a few users have previously asked how to delete/clear this file (when not knowing its location on the filesystem).

Hope this helps,

Adrian.

On 14 August 2010 20:38, Adrian Cumiskey <ad...@gmail.com>> wrote:
Sorry Jonathan, I've just looked into the matter and realised that what I told you was incorrect (partially at least).

If you take a look at http://xmlgraphics.apache.org/fop/1.0/configuration.html#general-elements you'll see that there is a "cache-file" option that you can provide to tell Fop where you would like your font cache file to be created.  Unfortunately this documentation does not reflect the current state of the system.  At some stage during further development of the font caching mechanism, this setting was lost as a configuration setting and instead Fop tries to always store the font cache file in the user's home directory.

I will work this weekend on reinstating this feature and integrate it into the current font caching system.

Cheers, Adrian.

On 14 August 2010 09:09, Adrian Cumiskey <ad...@gmail.com>> wrote:
Hi Jonathan,

The font caching was written prior to the Windows 7 release so it was never tested at the time.  There is currently no way of telling Fop where to put its font cache but it shouldn't be too much effort to add this feature.  I'll look at adding support for this.

Adrian.

On 14 August 2010 05:38, Jonathan Levinson <Jo...@intersystems.com>> wrote:
On Windows XP, fop creates it font-cache in "C:\Documents and Settings\<username>\.fop".

I've had a couple of reports that on Windows 7 64 bit, fop puts its font cache in c:\.fop, a directory to which the user may not have write permissions.

Is this a known issue?

Is there a way of telling fop where to put the font cache?

Best Regards,
Jonathan Levinson





Re: Problem with creation of font cache on Windows 7 64 bit

Posted by Adrian Cumiskey <ad...@gmail.com>.
Hi Jonathan,

I have just committed a fix to the missing "cache-file" configuration option
(see
http://xmlgraphics.apache.org/fop/1.0/configuration.html#general-elements)
to the Fop trunk code.  All the documentation regarding font caching should
now reflect the actual implementation.

I also added a convenience "-delete-cache" option to the Fop command line as
quite a few users have previously asked how to delete/clear this file (when
not knowing its location on the filesystem).

Hope this helps,

Adrian.

On 14 August 2010 20:38, Adrian Cumiskey <ad...@gmail.com> wrote:

> Sorry Jonathan, I've just looked into the matter and realised that what I
> told you was incorrect (partially at least).
>
> If you take a look at
> http://xmlgraphics.apache.org/fop/1.0/configuration.html#general-elements you'll
> see that there is a "cache-file" option that you can provide to tell Fop
> where you would like your font cache file to be created.  Unfortunately this
> documentation does not reflect the current state of the system.  At some
> stage during further development of the font caching mechanism, this setting
> was lost as a configuration setting and instead Fop tries to always store
> the font cache file in the user's home directory.
>
> I will work this weekend on reinstating this feature and integrate it into
> the current font caching system.
>
> Cheers, Adrian.
>
> On 14 August 2010 09:09, Adrian Cumiskey <ad...@gmail.com>wrote:
>
>> Hi Jonathan,
>>
>> The font caching was written prior to the Windows 7 release so it was
>> never tested at the time.  There is currently no way of telling Fop where to
>> put its font cache but it shouldn't be too much effort to add this feature.
>> I'll look at adding support for this.
>>
>> Adrian.
>>
>>
>> On 14 August 2010 05:38, Jonathan Levinson <
>> Jonathan.Levinson@intersystems.com> wrote:
>>
>>>  On Windows XP, fop creates it font-cache in “C:\Documents and
>>> Settings\<username>\.fop”.
>>>
>>>
>>>
>>> I’ve had a couple of reports that on Windows 7 64 bit, fop puts its font
>>> cache in c:\.fop, a directory to which the user may not have write
>>> permissions.
>>>
>>>
>>>
>>> Is this a known issue?
>>>
>>>
>>>
>>> Is there a way of telling fop where to put the font cache?
>>>
>>>
>>>
>>> Best Regards,
>>>
>>> Jonathan Levinson
>>>
>>>
>>>
>>
>>
>

Re: Problem with creation of font cache on Windows 7 64 bit

Posted by Adrian Cumiskey <ad...@gmail.com>.
Sorry Jonathan, I've just looked into the matter and realised that what I
told you was incorrect (partially at least).

If you take a look at
http://xmlgraphics.apache.org/fop/1.0/configuration.html#general-elements
you'll
see that there is a "cache-file" option that you can provide to tell Fop
where you would like your font cache file to be created.  Unfortunately this
documentation does not reflect the current state of the system.  At some
stage during further development of the font caching mechanism, this setting
was lost as a configuration setting and instead Fop tries to always store
the font cache file in the user's home directory.

I will work this weekend on reinstating this feature and integrate it into
the current font caching system.

Cheers, Adrian.

On 14 August 2010 09:09, Adrian Cumiskey <ad...@gmail.com> wrote:

> Hi Jonathan,
>
> The font caching was written prior to the Windows 7 release so it was never
> tested at the time.  There is currently no way of telling Fop where to put
> its font cache but it shouldn't be too much effort to add this feature.
> I'll look at adding support for this.
>
> Adrian.
>
>
> On 14 August 2010 05:38, Jonathan Levinson <
> Jonathan.Levinson@intersystems.com> wrote:
>
>>  On Windows XP, fop creates it font-cache in “C:\Documents and
>> Settings\<username>\.fop”.
>>
>>
>>
>> I’ve had a couple of reports that on Windows 7 64 bit, fop puts its font
>> cache in c:\.fop, a directory to which the user may not have write
>> permissions.
>>
>>
>>
>> Is this a known issue?
>>
>>
>>
>> Is there a way of telling fop where to put the font cache?
>>
>>
>>
>> Best Regards,
>>
>> Jonathan Levinson
>>
>>
>>
>
>

Re: Problem with creation of font cache on Windows 7 64 bit

Posted by Adrian Cumiskey <ad...@gmail.com>.
Hi Jonathan,

The font caching was written prior to the Windows 7 release so it was never
tested at the time.  There is currently no way of telling Fop where to put
its font cache but it shouldn't be too much effort to add this feature.
I'll look at adding support for this.

Adrian.

On 14 August 2010 05:38, Jonathan Levinson <
Jonathan.Levinson@intersystems.com> wrote:

>  On Windows XP, fop creates it font-cache in “C:\Documents and
> Settings\<username>\.fop”.
>
>
>
> I’ve had a couple of reports that on Windows 7 64 bit, fop puts its font
> cache in c:\.fop, a directory to which the user may not have write
> permissions.
>
>
>
> Is this a known issue?
>
>
>
> Is there a way of telling fop where to put the font cache?
>
>
>
> Best Regards,
>
> Jonathan Levinson
>
>
>