You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by George Sexton <ge...@mhsoftware.com> on 2016/03/17 21:29:14 UTC
Open TrueType Fonts
I was looking through things on my server and I'm seeing that my
application has about 130 TrueType font files open. I'm running this
under Tomcat so the process is persistent.
I've dug through the source code a little bit and I can see that
AbstractTTFParser.parseTTF(File ttfFile) explicitly doesn't close the
stream. I'm guessing this is because there's a way to do deferred
parsing of the file.
I looked at o.a.fontbox.util.FontManager as well, and it looks like when
it gets created, it's loading all available truetype fonts and at least
getting the Font Names table to map the font names to the constructed
TrueTypeFont objects.
Is there ever a point when the file input stream could be closed? Is
there some operation performed on TrueTypeFont that would definitively
conclude access to the stream?
--
George Sexton
*MH Software, Inc.*
Voice: 303 438 9585
http://www.connectdaily.com
Re: Open TrueType Fonts
Posted by George Sexton <ge...@mhsoftware.com>.
On 3/18/2016 3:09 PM, John Hewson wrote:
> When we do the scan, we close each font immediately afterwards. If
> PDFBox then goes on to use that font, we’ll re-open the file and then
> cache the new font. The cache is a map of SoftReference<T> objects,
> which get released when the JVM feels like it. But now I’m wondering,
> when do we close fonts which are dropped from the FontCache? Maybe
> there’s an issue here… — John
I just did lsof -p <tomcat pid> and I have 148 TrueType fonts open.
--
George Sexton
*MH Software, Inc.*
Voice: 303 438 9585
http://www.connectdaily.com
Re: Open TrueType Fonts
Posted by John Hewson <jo...@jahewson.com>.
> On 17 Mar 2016, at 13:29, George Sexton <ge...@mhsoftware.com> wrote:
>
> I was looking through things on my server and I'm seeing that my application has about 130 TrueType font files open. I'm running this under Tomcat so the process is persistent.
>
> I've dug through the source code a little bit and I can see that AbstractTTFParser.parseTTF(File ttfFile) explicitly doesn't close the stream. I'm guessing this is because there's a way to do deferred parsing of the file.
Yes, that’s right.
> I looked at o.a.fontbox.util.FontManager as well, and it looks like when it gets created, it's loading all available truetype fonts and at least getting the Font Names table to map the font names to the constructed TrueTypeFont objects.
That’s right, though it only does this once and then saves the naming metadata to an on-disk cache.
> Is there ever a point when the file input stream could be closed? Is there some operation performed on TrueTypeFont that would definitively conclude access to the stream?
When we do the scan, we close each font immediately afterwards. If PDFBox then goes on to use that font, we’ll re-open the file and then cache the new font. The cache is a map of SoftReference<T> objects, which get released when the JVM feels like it. But now I’m wondering, when do we close fonts which are dropped from the FontCache? Maybe there’s an issue here…
— John
>
> --
> George Sexton
> *MH Software, Inc.*
> Voice: 303 438 9585
> http://www.connectdaily.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org
Re: Open TrueType Fonts
Posted by Tilman Hausherr <TH...@t-online.de>.
https://issues.apache.org/jira/browse/PDFBOX-3272
Tilman
Am 17.03.2016 um 21:29 schrieb George Sexton:
> I was looking through things on my server and I'm seeing that my
> application has about 130 TrueType font files open. I'm running this
> under Tomcat so the process is persistent.
>
> I've dug through the source code a little bit and I can see that
> AbstractTTFParser.parseTTF(File ttfFile) explicitly doesn't close the
> stream. I'm guessing this is because there's a way to do deferred
> parsing of the file.
>
> I looked at o.a.fontbox.util.FontManager as well, and it looks like
> when it gets created, it's loading all available truetype fonts and at
> least getting the Font Names table to map the font names to the
> constructed TrueTypeFont objects.
>
> Is there ever a point when the file input stream could be closed? Is
> there some operation performed on TrueTypeFont that would definitively
> conclude access to the stream?
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org