*/
public Rectangle getTextSize(String text, Font font) {
template.saveState();
// get the font
DefaultFontMapper mapper = new DefaultFontMapper();
BaseFont bf = mapper.awtToPdf(font);
template.setFontAndSize(bf, font.getSize());
// calculate text width and height
float textWidth = template.getEffectiveStringWidth(text, false);
float ascent = bf.getAscentPoint(text, font.getSize());
float descent = bf.getDescentPoint(text, font.getSize());