xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luis Bernardo <lmpmberna...@gmail.com>
Subject Re: Getting a list of font names without the memory hit...‏
Date Wed, 31 Jul 2013 02:41:10 GMT
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.


Mime
View raw message