/**
*
*/
protected HSSFFont getLoadedFont(JRFont font, short forecolor, Map attributes, Locale locale)
{
HSSFFont cellFont = null;
String fontName = font.getFontName();
if (fontMap != null && fontMap.containsKey(fontName))
{
fontName = (String) fontMap.get(fontName);
}
else
{
FontInfo fontInfo = JRFontUtil.getFontInfo(fontName, locale);
if (fontInfo != null)
{
//fontName found in font extensions
FontFamily family = fontInfo.getFontFamily();
String exportFont = family.getExportFont(getExporterKey());
if (exportFont != null)
{
fontName = exportFont;
}
}
}
short superscriptType = HSSFFont.SS_NONE;
if( attributes != null && attributes.get(TextAttribute.SUPERSCRIPT) != null)
{
Object value = attributes.get(TextAttribute.SUPERSCRIPT);
if(TextAttribute.SUPERSCRIPT_SUPER.equals(value))
{
superscriptType = HSSFFont.SS_SUPER;
}
else if(TextAttribute.SUPERSCRIPT_SUB.equals(value))
{
superscriptType = HSSFFont.SS_SUB;
}
}
for (int i = 0; i < loadedFonts.size(); i++)
{
HSSFFont cf = (HSSFFont)loadedFonts.get(i);
short fontSize = (short)font.getFontSize();
if (isFontSizeFixEnabled)
{
fontSize -= 1;
}
if (
cf.getFontName().equals(fontName) &&
(cf.getColor() == forecolor) &&
(cf.getFontHeightInPoints() == fontSize) &&
((cf.getUnderline() == HSSFFont.U_SINGLE)?(font.isUnderline()):(!font.isUnderline())) &&
(cf.getStrikeout() == font.isStrikeThrough()) &&
((cf.getBoldweight() == HSSFFont.BOLDWEIGHT_BOLD)?(font.isBold()):(!font.isBold())) &&
(cf.getItalic() == font.isItalic()) &&
(cf.getTypeOffset() == superscriptType)
)
{
cellFont = cf;
break;
}