Retrieves the fake font details for a given font.
if (fontMetricsProps == null)
{
InputStream metricsIn = null;
try
{
fontMetricsProps = new Properties();
if (System.getProperty("font.metrics.filename") != null)
{
String filename = System.getProperty("font.metrics.filename");
File file = new File(filename);
if (!file.exists())
throw new FileNotFoundException("font_metrics.properties not found at path " + file.getAbsolutePath());
metricsIn = new FileInputStream(file);
}
else
{
metricsIn = FontDetails.class.getResourceAsStream("/font_metrics.properties");
if (metricsIn == null)
throw new FileNotFoundException("font_metrics.properties not found in classpath");
}
fontMetricsProps.load(metricsIn);
}
catch ( IOException e )
{
throw new RuntimeException("Could not load font metrics: " + e.getMessage());
}
finally
{
if (metricsIn != null)
{
try
{
metricsIn.close();
}
catch ( IOException ignore ) { }
}
}
}
String fontName = font.getName();
if (fontDetailsMap.get(fontName) == null)
{
FontDetails fontDetails = FontDetails.create(fontName, fontMetricsProps);
fontDetailsMap.put( fontName, fontDetails );
return fontDetails;
}
else
{
return (FontDetails) fontDetailsMap.get(fontName);
}