Re: Getting a list of font names without the memory hit...‏

2013-08-01 Thread Chris Bowditch
The auto-detect feature creates the font cache, to save time on 
sunsequent calls to FOP, you can disable the cache using the setting: 
use-cachefalse/use-cache in your fop.xconf.


I suspect the reason for the high memory consumption is your use of 
auto-detect feature. Though I've not replicated the issue. If your 
intention  is to allow the user to pick any font installed on the 
Operating System, why not use the java.awt classes to list the available 
fonts instead? I've not tried it but I suspect it will use less memory 
as it doesn't need to load the full contents of every font in the system.


Thanks,

Chris

On 31/07/2013 12:53, Bernard Giannetti wrote:
Now I'm chasing my tail...looking at FontCachehas gotten me back to 
FontInfo.getFonts()!


Any other ideas please?!



From: thebernmeis...@hotmail.com
To: fop-users@xmlgraphics.apache.org
Subject: RE: Getting a list of font names without the memory hit...‏
Date: Wed, 31 Jul 2013 21:33:14 +1000

I'm readingorg.apache.fop.fonts.FontCache now...red-faced and fingers 
crossed!





From: thebernmeis...@hotmail.com
To: fop-users@xmlgraphics.apache.org
Subject: RE: Getting a list of font names without the memory hit...‏
Date: Wed, 31 Jul 2013 21:29:59 +1000

The config file or the cache file?

My config file has no fonts listed for PDF:

renderer mime=application/pdf
filterList
valueflate/value
/filterList

fonts
auto-detect/
/fonts
/renderer


 Date: Wed, 31 Jul 2013 04:26:33 -0700
 From: djs...@yahoo.com
 To: fop-users@xmlgraphics.apache.org
 Subject: RE: Getting a list of font names without the memory hit...‏

 Why don't you just read the config file which list all the available 
fonts?





-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



RE: Getting a list of font names without the memory hit...‏

2013-08-01 Thread Bernard Giannetti



Thanks Chris - simplest solution is often the best:
String fonts[] = 
GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
Getting a list of fonts this way does NOT appear to impact memory at all...so 
much better!
I don't have the use-cache tag in my config file, so I assume the cache is on 
by default.  I did a test run of creating a PDF:
With no use-cache present: memory used 111 MBWith 
use-cachefalse/use-cache present: memory used 330 MB
I think I'll stick with the default!
Thanks again,
Bernard.

 Date: Thu, 1 Aug 2013 13:58:57 +0100
 From: bowditch_ch...@hotmail.com
 To: fop-users@xmlgraphics.apache.org
 Subject: Re: Getting a list of font names without the memory hit...‏
 
 The auto-detect feature creates the font cache, to save time on 
 sunsequent calls to FOP, you can disable the cache using the setting: 
 use-cachefalse/use-cache in your fop.xconf.
 
 I suspect the reason for the high memory consumption is your use of 
 auto-detect feature. Though I've not replicated the issue. If your 
 intention  is to allow the user to pick any font installed on the 
 Operating System, why not use the java.awt classes to list the available 
 fonts instead? I've not tried it but I suspect it will use less memory 
 as it doesn't need to load the full contents of every font in the system.


  

RE: Getting a list of font names without the memory hit...‏

2013-07-31 Thread Bonekrusher
Why don't you just read the config file which list all the available fonts?



--
View this message in context: 
http://apache-fop.1065347.n5.nabble.com/Getting-a-list-of-font-names-without-the-memory-hit-tp38952p38958.html
Sent from the FOP - Users mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



RE: Getting a list of font names without the memory hit...‏

2013-07-31 Thread Bernard Giannetti
I've done some more digging/testing and noticed that when I get the fonts 
map... 
FontInfo fontInfo = new FontInfo();configurator.setupFontInfo( documentHandler, 
fontInfo );Map fonts = fontInfo.getFonts();
(the above essentially comes straight out of listfonts() and its subcalls)
the fontInfo.getFonts() was returning a Collections.unmodifiableMap(this.fonts) 
which I initially thought was the memory hog.  Well it sort of is, but it is 
not the main culprit.
Noticing that this.fonts is private, I used reflection to access the this.fonts 
directly (so no copy took place) and still the memory was excessive 
(essentially little difference to what I've initially seen).
On digging deeper, the big memory hit is happening within 
configurator.setupFontInfo( documentHandler, fontInfo );.
Let me back up and ask a couple of sanity questions...first, to reiterate: my 
desktop Java application allows a user to create PDF reports (from XML and XSL) 
by making direct Java calls to FOP (that is, I do NOT invoke FOP from the 
command line).
1) I want the user to be able to choose the name of a font for a given report.  
Should I be getting the font names by calling FontListGenerator.listFonts()?
2) I noticed in the guts of configurator.setupFontInfo(),  there is a font 
cache file which is written.  Is it possible to get the fonts names from this 
file instead?
In short, I am not fussed on how I get the font names so long as the memory 
doesn't go through the roof!


From: thebernmeis...@hotmail.com
To: fop-users@xmlgraphics.apache.org
Subject: RE: Getting a list of font names without the memory hit...‏
Date: Wed, 31 Jul 2013 13:17:32 +1000




I'm using FOP inside my desktop app.  I use FOP to combine .xml data files and 
.xsl template files into PDFs.  I wanted to give the user the choice of font to 
use for the PDF text and so I am calling FOP code to get that list of fonts.

Date: Tue, 30 Jul 2013 21:41:10 -0500
From: lmpmberna...@gmail.com
To: fop-users@xmlgraphics.apache.org
Subject: Re: Getting a list of font names without the memory hit...‏


  

  
  
Are you using FOP in your Desktop app
  (meaning you feed and FO file and output one of the supported
  formats) or you just want to use some classes to get the list of
  fonts in your system?

  

  On 7/30/13 5:42 PM, Bernard Giannetti wrote:



  
  
(apologies for the double post...somehow
my email got tagged to the end of an unrelated post)


  

  


  Hi,


  

  I'm making a call to 
org.apache.fop.tools.fontlist.FontListGenerator.listFonts(
  ... ) to get a list of font names
  for my desktop application.  To get the font names, I take the 
keys from the
  returned fontFamilies
  SortedMap; the actual data is
  junked.
  
  
  I hadn't
realised just how much memory is used by listfont(
... ) - on some platforms such as Windows 7, in
excess of 250 MB.  In this case I'm hitting out of
memory errors.
  

  
  I was
wondering if there's a simpler way (uses less memory) to
get just the font names (first family names)?  As I
said, I don't make use of the metrics and other font
details...just the first family name for each font.  Digging 
down into  listfont(
... ), I was wondering if it's safe to take the firstFamilyName 
and place it
  into a list say and then drop the following lines for the 
containers/sort?
  

  
Iterator iter =
fontInfo.getFontTriplets().entrySet().iterator();
while (iter.hasNext()) {
 
Map.Entry
  entry = (Map.Entry)iter.next();
 
FontTriplet
  triplet = (FontTriplet)entry.getKey();
 
String
  key = (String)entry.getValue();
 
FontSpec
  container;
 
if
  (keyBag.contains(key)) {
 
   
  keyBag.remove(key);

  
 
   
  FontMetrics metrics = (FontMetrics)fonts.get(key);

  
 
container = new FontSpec(key,
  metrics);
 
container.addFamilyNames(metrics.getFamilyNames());
 
keys.put(key, container);
 
String firstFamilyName =
  (String)container.getFamilyNames().first();
 

RE: Getting a list of font names without the memory hit...‏

2013-07-31 Thread Bernard Giannetti
The config file or the cache file?
My config file has no fonts listed for PDF:
renderer mime=application/pdf  filterListvalueflate/value  
/filterList
  fontsauto-detect/  /fonts/renderer

 Date: Wed, 31 Jul 2013 04:26:33 -0700
 From: djs...@yahoo.com
 To: fop-users@xmlgraphics.apache.org
 Subject: RE: Getting a list of font names without the memory hit...‏
 
 Why don't you just read the config file which list all the available fonts?

  

RE: Getting a list of font names without the memory hit...‏

2013-07-31 Thread Bernard Giannetti
I'm reading org.apache.fop.fonts.FontCache now...red-faced and fingers crossed!



From: thebernmeis...@hotmail.com
To: fop-users@xmlgraphics.apache.org
Subject: RE: Getting a list of font names without the memory hit...‏
Date: Wed, 31 Jul 2013 21:29:59 +1000




The config file or the cache file?
My config file has no fonts listed for PDF:
renderer mime=application/pdf  filterListvalueflate/value  
/filterList
  fontsauto-detect/  /fonts/renderer

 Date: Wed, 31 Jul 2013 04:26:33 -0700
 From: djs...@yahoo.com
 To: fop-users@xmlgraphics.apache.org
 Subject: RE: Getting a list of font names without the memory hit...‏
 
 Why don't you just read the config file which list all the available fonts?


  

RE: Getting a list of font names without the memory hit...‏

2013-07-31 Thread Bernard Giannetti
Now I'm chasing my tail...looking at FontCache has gotten me back to 
FontInfo.getFonts()!
Any other ideas please?!

From: thebernmeis...@hotmail.com
To: fop-users@xmlgraphics.apache.org
Subject: RE: Getting a list of font names without the memory hit...‏
Date: Wed, 31 Jul 2013 21:33:14 +1000




I'm reading org.apache.fop.fonts.FontCache now...red-faced and fingers crossed!



From: thebernmeis...@hotmail.com
To: fop-users@xmlgraphics.apache.org
Subject: RE: Getting a list of font names without the memory hit...‏
Date: Wed, 31 Jul 2013 21:29:59 +1000




The config file or the cache file?
My config file has no fonts listed for PDF:
renderer mime=application/pdf  filterListvalueflate/value  
/filterList
  fontsauto-detect/  /fonts/renderer

 Date: Wed, 31 Jul 2013 04:26:33 -0700
 From: djs...@yahoo.com
 To: fop-users@xmlgraphics.apache.org
 Subject: RE: Getting a list of font names without the memory hit...‏
 
 Why don't you just read the config file which list all the available fonts?


  

Re: Getting a list of font names without the memory hit...‏

2013-07-30 Thread Luis Bernardo
Are you using FOP in your Desktop app (meaning you feed and FO file and 
output one of the supported formats) or you just want to use some 
classes to get the list of fonts in your system?


On 7/30/13 5:42 PM, Bernard Giannetti wrote:
(apologies for the double post...somehow my email got tagged to the 
end of an unrelated post)



Hi,

I'm making a call to 
org.apache.fop.tools.fontlist.FontListGenerator.listFonts( ... ) to 
get a list of font names for my desktop application. To get the font 
names, I take the keys from the returned fontFamilies SortedMap; the 
actual data is junked.


I hadn't realised just how much memory is used by listfont( ... ) - on 
some platforms such as Windows 7, in excess of 250 MB.  In this case 
I'm hitting out of memory errors.


I was wondering if there's a simpler way (uses less memory) to get 
just the font names (first family names)?  As I said, I don't make use 
of the metrics and other font details...just the first family name for 
each font. Digging down into listfont( ... ), I was wondering if it's 
safe to take the firstFamilyName and place it into a list say and then 
drop the following lines for the containers/sort?


Iterator iter = fontInfo.getFontTriplets().entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry)iter.next();
FontTriplet triplet = (FontTriplet)entry.getKey();
String key = (String)entry.getValue();
FontSpec container;
if (keyBag.contains(key)) {
keyBag.remove(key);

FontMetrics metrics = (FontMetrics)fonts.get(key);

container = new FontSpec(key, metrics);
container.addFamilyNames(metrics.getFamilyNames());
keys.put(key, container);
String firstFamilyName = (String)container.getFamilyNames().first();
List containers = (List)fontFamilies.get(firstFamilyName);
if (containers == null) {
containers = new java.util.ArrayList();
fontFamilies.put(firstFamilyName, containers);
}
containers.add(container);
Collections.sort(containers);
} else {
container = (FontSpec)keys.get(key);
}
container.addTriplet(triplet);
}

I'm guessing a lot of memory is chewed up in the containers/sort 
section...but really I can't be sure as I don't fully follow what's 
going on!


Ideally I'd just up the amount of memory supplied to the desktop 
application, but I don't have that option and besides, it just delays 
the problem of running out of memory.



Thanks in advance,

Bernard.




RE: Getting a list of font names without the memory hit...‏

2013-07-30 Thread Bernard Giannetti
I'm using FOP inside my desktop app.  I use FOP to combine .xml data files and 
.xsl template files into PDFs.  I wanted to give the user the choice of font to 
use for the PDF text and so I am calling FOP code to get that list of fonts.

Date: Tue, 30 Jul 2013 21:41:10 -0500
From: lmpmberna...@gmail.com
To: fop-users@xmlgraphics.apache.org
Subject: Re: Getting a list of font names without the memory hit...‏


  

  
  
Are you using FOP in your Desktop app
  (meaning you feed and FO file and output one of the supported
  formats) or you just want to use some classes to get the list of
  fonts in your system?

  

  On 7/30/13 5:42 PM, Bernard Giannetti wrote:



  
  
(apologies for the double post...somehow
my email got tagged to the end of an unrelated post)


  

  


  Hi,


  

  I'm making a call to 
org.apache.fop.tools.fontlist.FontListGenerator.listFonts(
  ... ) to get a list of font names
  for my desktop application.  To get the font names, I take the 
keys from the
  returned fontFamilies
  SortedMap; the actual data is
  junked.
  
  
  I hadn't
realised just how much memory is used by listfont(
... ) - on some platforms such as Windows 7, in
excess of 250 MB.  In this case I'm hitting out of
memory errors.
  

  
  I was
wondering if there's a simpler way (uses less memory) to
get just the font names (first family names)?  As I
said, I don't make use of the metrics and other font
details...just the first family name for each font.  Digging 
down into  listfont(
... ), I was wondering if it's safe to take the firstFamilyName 
and place it
  into a list say and then drop the following lines for the 
containers/sort?
  

  
Iterator iter =
fontInfo.getFontTriplets().entrySet().iterator();
while (iter.hasNext()) {
 
Map.Entry
  entry = (Map.Entry)iter.next();
 
FontTriplet
  triplet = (FontTriplet)entry.getKey();
 
String
  key = (String)entry.getValue();
 
FontSpec
  container;
 
if
  (keyBag.contains(key)) {
 
   
  keyBag.remove(key);

  
 
   
  FontMetrics metrics = (FontMetrics)fonts.get(key);

  
 
container = new FontSpec(key,
  metrics);
 
container.addFamilyNames(metrics.getFamilyNames());
 
keys.put(key, container);
 
String firstFamilyName =
  (String)container.getFamilyNames().first();
 
List containers =
  (List)fontFamilies.get(firstFamilyName);
 
if (containers == null) {
 
 
containers = new
  java.util.ArrayList();
 
 
fontFamilies.put(firstFamilyName,
  containers);
 
}
 
containers.add(container);
 
Collections.sort(containers);
 
} else {
 
container =
  (FontSpec)keys.get(key);
 
}
 
container.addTriplet(triplet);
}
  
  

  I'm guessing a lot
  of memory is chewed up in the containers/sort
  section...but really I can't be sure as I don't fully
  follow what's going on!
  

  Ideally I'd just up
  the amount of memory supplied to the desktop application,
  but I don't have that option and besides, it just delays
  the problem of running out of memory.
  

  

  
  
Thanks in advance,

  
Bernard.