FileDocCategorySizeDatePackage
FontCollection.javaAPI DocApache Poi 3.0.13386Thu May 31 18:45:28 BST 2007org.apache.poi.hslf.record

FontCollection

public class FontCollection extends RecordContainer
FontCollection ia a container that holds information about all the fonts in the presentation.
author
Yegor Kozlov

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 intaddFont(java.lang.String name)
Add font with the specified name to the font collection. If the font is already present return its index.

param
name of the font
return
zero based index of the font in the collection

        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.StringgetFontWithId(int id)
Get the name of the font at the given ID, or null if there is no font at that ID.

param
id
return

		if(id >= fonts.size()) {
			// No font with that id
			return null;
		}
		return (String)fonts.get(id);
	
public longgetRecordType()
Return the type, which is 2005

        return RecordTypes.FontCollection.typeID;
    
public voidwriteOut(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);