FontCollectionpublic class FontCollection extends RecordContainer FontCollection ia a container that holds information
about all the fonts in the presentation. |
Fields Summary |
---|
private List | fonts | private byte[] | _header |
Constructors Summary |
---|
protected FontCollection(byte[] source, int start, int len)
// Grab the header
_header = new byte[8];
System.arraycopy(source,start,_header,0,8);
_children = Record.findChildRecords(source,start+8,len-8);
// Save font names into <code>List</code>
fonts = new ArrayList();
for (int i = 0; i < _children.length; i++){
if(_children[i] instanceof FontEntityAtom) {
FontEntityAtom atom = (FontEntityAtom)_children[i];
fonts.add(atom.getFontName());
} else {
logger.log(POILogger.WARN, "Warning: FontCollection child wasn't a FontEntityAtom, was " + _children[i]);
}
}
|
Methods Summary |
---|
public int | addFont(java.lang.String name)Add font with the specified name to the font collection.
If the font is already present return its index.
for (int i = 0; i < fonts.size(); i++) {
if(fonts.get(i).equals(name)){
//if the font is already present return its index
return i;
}
}
FontEntityAtom fnt = new FontEntityAtom();
fnt.setFontIndex(fonts.size() << 4);
fnt.setFontName(name);
fonts.add(name);
// Append new child to the end
appendChildRecord(fnt);
return fonts.size()-1; //the added font is the last in the list
| public java.lang.String | getFontWithId(int id)Get the name of the font at the given ID, or null if there is
no font at that ID.
if(id >= fonts.size()) {
// No font with that id
return null;
}
return (String)fonts.get(id);
| public long | getRecordType()Return the type, which is 2005
return RecordTypes.FontCollection.typeID;
| public void | writeOut(java.io.OutputStream out)Write the contents of the record back, so it can be written
to disk
writeOut(_header[0],_header[1],getRecordType(),_children,out);
|
|