FileDocCategorySizeDatePackage
FontTable.javaAPI DocApache Poi 3.0.14248Mon Jan 01 18:55:34 GMT 2007org.apache.poi.hwpf.model

FontTable

public class FontTable extends Object
FontTable or in MS terminology sttbfffn is a common data structure written in all Word files. The sttbfffn is an sttbf where each string is an FFN structure instead of pascal-style strings. An sttbf is a string Table stored in file. Thus sttbffn is like an Sttbf with an array of FFN structures that stores the font name strings
author
Praveen Mathew

Fields Summary
private short
_stringCount
private short
_extraDataSz
private int
lcbSttbfffn
private int
fcSttbfffn
private Ffn[]
_fontNames
Constructors Summary
public FontTable(byte[] buf, int offset, int lcbSttbfffn)



        
  
    this.lcbSttbfffn = lcbSttbfffn;
    this.fcSttbfffn = offset;

    _stringCount = LittleEndian.getShort(buf, offset);
    offset += LittleEndian.SHORT_SIZE;
    _extraDataSz = LittleEndian.getShort(buf, offset);
    offset += LittleEndian.SHORT_SIZE;

    _fontNames = new Ffn[_stringCount]; //Ffn corresponds to a Pascal style String in STTBF.

    for(int i = 0;i<_stringCount; i++)
    {
      _fontNames[i] = new Ffn(buf,offset);
      offset += _fontNames[i].getSize();
    }
  
Methods Summary
public booleanequals(java.lang.Object o)

  	boolean retVal = true;

    if(((FontTable)o).getStringCount() == _stringCount)
    {
      if(((FontTable)o).getExtraDataSz() == _extraDataSz)
      {
        Ffn[] fontNamesNew = ((FontTable)o).getFontNames();
        for(int i = 0;i<_stringCount; i++)
        {
          if(!(_fontNames[i].equals(fontNamesNew[i])))
            retVal = false;
        }
      }
      else
        retVal = false;
    }
    else
	    retVal = false;


	  return retVal;
  
public java.lang.StringgetAltFont(int chpFtc)

    if(chpFtc >= _stringCount)
    {
      System.out.println("Mismatch in chpFtc with stringCount");
      return null;
    }

    return _fontNames[chpFtc].getAltFontName();
  
public shortgetExtraDataSz()

  	return _extraDataSz;
  
public org.apache.poi.hwpf.model.Ffn[]getFontNames()

  	return _fontNames;
  
public java.lang.StringgetMainFont(int chpFtc)

    if(chpFtc >= _stringCount)
    {
      System.out.println("Mismatch in chpFtc with stringCount");
      return null;
    }

    return _fontNames[chpFtc].getMainFontName();
  
public intgetSize()

    return lcbSttbfffn;
  
public shortgetStringCount()

    return  _stringCount;
  
public voidsetStringCount(short stringCount)

    this._stringCount = stringCount;
  
public voidwriteTo(org.apache.poi.hwpf.model.io.HWPFFileSystem sys)

	  HWPFOutputStream tableStream = sys.getStream("1Table");

	  byte[] buf = new byte[LittleEndian.SHORT_SIZE];
	  LittleEndian.putShort(buf, _stringCount);
	  tableStream.write(buf);
	  LittleEndian.putShort(buf, _extraDataSz);
	  tableStream.write(buf);

	  for(int i = 0; i < _fontNames.length; i++)
	  {
		  tableStream.write(_fontNames[i].toByteArray());
	  }