if ("raster".equalsIgnoreCase(type)) {
String name = afpFontCfg.getAttribute("name", "Unknown");
// Create a new font object
RasterFont font = new RasterFont(name);
Configuration[] rasters = afpFontCfg.getChildren("afp-raster-font");
if (rasters.length == 0) {
eventProducer.fontConfigMissing(this, "<afp-raster-font...",
afpFontCfg.getLocation());
return null;
}
for (int j = 0; j < rasters.length; j++) {
Configuration rasterCfg = rasters[j];
String characterset = rasterCfg.getAttribute("characterset");
if (characterset == null) {
eventProducer.fontConfigMissing(this, "characterset attribute",
afpFontCfg.getLocation());
return null;
}
float size = rasterCfg.getAttributeAsFloat("size");
int sizeMpt = (int) (size * 1000);
String base14 = rasterCfg.getAttribute("base14-font", null);
if (base14 != null) {
try {
Class<? extends Typeface> clazz = Class.forName(
"org.apache.fop.fonts.base14." + base14).asSubclass(Typeface.class);
try {
Typeface tf = clazz.newInstance();
font.addCharacterSet(sizeMpt,
CharacterSetBuilder.getSingleByteInstance()
.build(characterset, codepage, encoding, tf,
eventProducer));
} catch (Exception ie) {
String msg = "The base 14 font class " + clazz.getName()
+ " could not be instantiated";
log.error(msg);
}
} catch (ClassNotFoundException cnfe) {
String msg = "The base 14 font class for " + characterset
+ " could not be found";
log.error(msg);
}
} else {
font.addCharacterSet(sizeMpt, CharacterSetBuilder.getSingleByteInstance()
.buildSBCS(characterset, codepage, encoding, accessor, eventProducer));
}
}
return font;