CharacterSet cs = raster.getCharacterSet(size);
if (cs == null) {
String msg = "Character set not found for font "
+ font.getFontName() + " with point size " + size;
log.error(msg);
throw new FontRuntimeException(msg);
}
fd._characterset = cs.getNameBytes();
if (fd._characterset.length != 8) {
throw new IllegalArgumentException("The character set "
+ new String(fd._characterset,
AFPConstants.EBCIDIC_ENCODING)
+ " must have a fixed length of 8 characters.");
}
fd._codepage = cs.getCodePage().getBytes(
AFPConstants.EBCIDIC_ENCODING);
if (fd._codepage.length != 8) {
throw new IllegalArgumentException("The code page "
+ new String(fd._codepage,
AFPConstants.EBCIDIC_ENCODING)
+ " must have a fixed length of 8 characters.");
}
} else if (font instanceof OutlineFont) {
OutlineFont outline = (OutlineFont) font;
CharacterSet cs = outline.getCharacterSet();
fd._characterset = cs.getNameBytes();
// There are approximately 72 points to 1 inch or 20 1440ths per point.
fd._scale = ((size / 1000) * 20);
fd._codepage = cs.getCodePage().getBytes(
AFPConstants.EBCIDIC_ENCODING);
if (fd._codepage.length != 8) {
throw new IllegalArgumentException("The code page "
+ new String(fd._codepage,
AFPConstants.EBCIDIC_ENCODING)
+ " must have a fixed length of 8 characters.");
}
} else {
String msg = "Font of type " + font.getClass().getName()
+ " not recognized.";
log.error(msg);
throw new FontRuntimeException(msg);
}
if (_fontlist.size() > 253) {
// Throw an exception if the size is exceeded
throw new MaximumSizeExceededException();
} else {
_fontlist.add(fd);
}
} catch (UnsupportedEncodingException ex) {
throw new FontRuntimeException("Failed to create font "
+ " due to a UnsupportedEncodingException", ex);
}
}