gt: 		List<FontFamily> fontFamilies = new ArrayList<FontFamily>();
context: /*
   * JasperReports - Free Java Reporting Library.
   * Copyright (C) 2001 - 2011 Jaspersoft Corporation. All rights reserved.
   * http://www.jaspersoft.com
   *
   * Unless you have purchased a commercial license agreement from Jaspersoft,
   * the following license terms apply:
   *
   * This program is part of JasperReports.
   *
   * JasperReports is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Lesser General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * JasperReports is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public License
   * along with JasperReports. If not, see <http://www.gnu.org/licenses/>.
   */
  package org.oss.pdfreporter.engine.fonts;
  
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.OutputStream;
  import java.io.OutputStreamWriter;
  import java.io.Writer;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  
  import org.oss.pdfreporter.engine.DefaultJasperReportsContext;
  import org.oss.pdfreporter.engine.JRException;
  import org.oss.pdfreporter.engine.JRRuntimeException;
  import org.oss.pdfreporter.engine.JasperReportsContext;
  import org.oss.pdfreporter.registry.IRegistry;
  import org.oss.pdfreporter.repo.RepositoryUtil;
  import org.oss.pdfreporter.uses.org.w3c.dom.Document;
  import org.oss.pdfreporter.uses.org.w3c.dom.NamedNodeMap;
  import org.oss.pdfreporter.uses.org.w3c.dom.Node;
  import org.oss.pdfreporter.uses.org.w3c.dom.NodeList;
  import org.oss.pdfreporter.xml.parsers.IDocumentBuilder;
  import org.oss.pdfreporter.xml.parsers.IDocumentBuilderFactory;
  import org.oss.pdfreporter.xml.parsers.ParserConfigurationException;
  import org.oss.pdfreporter.xml.parsers.XMLErrorHandler;
  import org.oss.pdfreporter.xml.parsers.XMLParseException;
  
  
  
  /**
   * @author Teodor Danciu (teodord@users.sourceforge.net)
   * @version $Id: SimpleFontExtensionHelper.java 5346 2012-05-08 12:08:01Z teodord $
   */
  public final class SimpleFontExtensionHelper implements XMLErrorHandler
  {
  	/**
  	 * Default XML output encoding.
  	 */
  	public static final String DEFAULT_ENCODING = "UTF-8";
  	
  
  	/**
  	 *
  	 */
  	private static final String NODE_fontFamily = "fontFamily";
  	private static final String NODE_normal = "normal";
  	private static final String NODE_bold = "bold";
  	private static final String NODE_italic = "italic";
  	private static final String NODE_boldItalic = "boldItalic";
  	private static final String NODE_pdfEncoding = "pdfEncoding";
  	private static final String NODE_pdfEmbedded = "pdfEmbedded";
  	private static final String NODE_exportFonts = "exportFonts";
  	private static final String NODE_export = "export";
  	private static final String NODE_locales = "locales";
  	private static final String NODE_locale = "locale";
  	private static final String ATTRIBUTE_name = "name";
  	private static final String ATTRIBUTE_key = "key";
  
  	/**
  	 * Thread local soft cache of instances.
  	 */
  	// TODO (29.04.2013, Donat, Open Software Solutions): Notice single threaded application SoftReference are static
  	private static SimpleFontExtensionHelper instance = null;
  	
  	/**
  	 * Return a cached instance.
  	 * 
  	 * @return a cached instance
  	 */
  	public static SimpleFontExtensionHelper getInstance()
  	{
  		if (instance == null)
  		{
  			instance = new SimpleFontExtensionHelper();
  		}
  		return instance;
  	}
  	
  	/**
  	 *
  	 */
  	private IDocumentBuilder documentBuilder;
  
  
  	/**
  	 *
  	 */
  	private SimpleFontExtensionHelper()
  	{
  		try
  		{
  			IDocumentBuilderFactory factory = IRegistry.getIXmlParserFactory().newDocumentBuilderFactory();
  			documentBuilder = factory.newDocumentBuilder();
  			documentBuilder.setErrorHandler(this);
  		}
  		catch (ParserConfigurationException e)
  		{
  			throw new JRRuntimeException(e);
  		}
  	}
  
  
  	/**
  	 * @see #loadFontFamilies(JasperReportsContext, String)
  	 */
  	public List<FontFamily> loadFontFamilies(String file)
  	{
  		return loadFontFamilies(DefaultJasperReportsContext.getInstance(), file);
  	}
  	
  	/**
  	 *
  	 */
  	public List<FontFamily> loadFontFamilies(JasperReportsContext jasperReportsContext, String file)
  	{
  		InputStream is = null; 
  		
  		try
  		{
  			is = RepositoryUtil.getInstance(jasperReportsContext).getInputStreamFromLocation(file);
  			return loadFontFamilies(jasperReportsContext, is);
  		}
  		catch (JRException e)
  		{
  			throw new JRRuntimeException(e);
  		}
  		finally
  		{
  			if (is != null)
  			{
  				try
  				{
  					is.close();
  				}
  				catch(IOException e)
  				{
  				}
  			}
  		}
  	}
  	
  	/**
  	 *
  	 */
  	public List<FontFamily> loadFontFamilies(JasperReportsContext jasperReportsContext, InputStream is)
  	{
  		List<FontFamily> fontFamilies = null;
  
  		try
  		{
  			Document document = documentBuilder.parse(IRegistry.getIXmlParserFactory().newInputSource(new InputStreamReader(is, "UTF-8")));
  			fontFamilies = parseFontFamilies(jasperReportsContext, document.getDocumentElement());
  		}
  		catch (XMLParseException e)
  		{
  			throw new JRRuntimeException(e);
  		}
  		
  		catch (IOException e)
  		{
  			throw new JRRuntimeException(e);
  		}
  		
  		return fontFamilies;
  	}
  	
  	/**
  	 * @deprecated To be removed.
  	 */
  	public List<FontFamily> loadFontFamilies(InputStream is)
  	{
  		return loadFontFamilies(DefaultJasperReportsContext.getInstance(), is);
  	}
  
  	/**
  	 *
  	 */
  	private List<FontFamily> parseFontFamilies(JasperReportsContext jasperReportsContext, Node fontFamiliesNode) throws XMLParseException
  	{
  