pdfFont = new PdfFont(jrFont.getPdfFontName(), jrFont.getPdfEncoding(), jrFont.isPdfEmbedded());
}
else
{
//fontName found in font extensions
FontFamily family = fontInfo.getFontFamily();
FontFace face = fontInfo.getFontFace();
int faceStyle = java.awt.Font.PLAIN;
if (face == null)
{
//fontName matches family name in font extension
if (jrFont.isBold() && jrFont.isItalic())
{
face = family.getBoldItalicFace();
faceStyle = java.awt.Font.BOLD | java.awt.Font.ITALIC;
}
if (face == null && jrFont.isBold())
{
face = family.getBoldFace();
faceStyle = java.awt.Font.BOLD;
}
if (face == null && jrFont.isItalic())
{
face = family.getItalicFace();
faceStyle = java.awt.Font.ITALIC;
}
if (face == null)
{
face = family.getNormalFace();
faceStyle = java.awt.Font.PLAIN;
}
// if (face == null)
// {
// throw new JRRuntimeException("Font family '" + family.getName() + "' does not have the normal font face.");
// }
}
else
{
//fontName matches face name in font extension; not family name
faceStyle = fontInfo.getStyle();
}
String pdfFontName = null;
int pdfFontStyle = java.awt.Font.PLAIN;
if (jrFont.isBold() && jrFont.isItalic())
{
pdfFontName = family.getBoldItalicPdfFont();
pdfFontStyle = java.awt.Font.BOLD | java.awt.Font.ITALIC;
}
if (pdfFontName == null && jrFont.isBold())
{
pdfFontName = family.getBoldPdfFont();
pdfFontStyle = java.awt.Font.BOLD;
}
if (pdfFontName == null && jrFont.isItalic())
{
pdfFontName = family.getItalicPdfFont();
pdfFontStyle = java.awt.Font.ITALIC;
}
if (pdfFontName == null)
{
pdfFontName = family.getNormalPdfFont();
pdfFontStyle = java.awt.Font.PLAIN;
}
if (pdfFontName == null)
{
//in theory, face file cannot be null here
pdfFontName = (face == null || face.getFile() == null ? jrFont.getPdfFontName() : face.getFile());
pdfFontStyle = faceStyle;//FIXMEFONT not sure this is correct, in case we inherit pdfFontName from default properties
}
// String ttf = face.getFile();
// if (ttf == null)
// {
// throw new JRRuntimeException("The '" + face.getName() + "' font face in family '" + family.getName() + "' returns a null file.");
// }
pdfFont =
new PdfFont(
pdfFontName,
family.getPdfEncoding() == null ? jrFont.getPdfEncoding() : family.getPdfEncoding(),
family.isPdfEmbedded() == null ? jrFont.isPdfEmbedded() : family.isPdfEmbedded().booleanValue(),
jrFont.isBold() && ((pdfFontStyle & java.awt.Font.BOLD) == 0),
jrFont.isItalic() && ((pdfFontStyle & java.awt.Font.ITALIC) == 0)
);
}
}