public String getMainFont(int chpFtc ) { if(chpFtc >= _stringCount) { _logger.log(POILogger.INFO, "Mismatch in chpFtc with stringCount"); return null; } return _fontNames[chpFtc].getMainFontName(); }
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(); } }
@Override public boolean equals(Object other) { if (!(other instanceof FontTable)) return false; FontTable o = (FontTable)other; if (o._stringCount != this._stringCount || o._extraDataSz != this._extraDataSz || o._fontNames.length != this._fontNames.length ) return false; for (int i=0; i<o._fontNames.length; i++) { if (!o._fontNames[i].equals(this._fontNames[i])) return false; } return true; }
System.out.println("Font: "+f.getMainFontName()+", "+f.getSize()+", "+f.getWeight());
public byte[] toByteArray() { int offset = 0; byte[] buf = new byte[this.getSize()]; buf[offset] = (byte)_cbFfnM1; offset += LittleEndian.BYTE_SIZE; buf[offset] = _info; offset += LittleEndian.BYTE_SIZE; LittleEndian.putShort(buf, offset, _wWeight); offset += LittleEndian.SHORT_SIZE; buf[offset] = _chs; offset += LittleEndian.BYTE_SIZE; buf[offset] = _ixchSzAlt; offset += LittleEndian.BYTE_SIZE; System.arraycopy(_panose,0,buf, offset,_panose.length); offset += _panose.length; System.arraycopy(_fontSig,0,buf, offset, _fontSig.length); offset += _fontSig.length; for(int i = 0; i < _xszFfn.length; i++) { LittleEndian.putShort(buf, offset, (short)_xszFfn[i]); offset += LittleEndian.SHORT_SIZE; } return buf; }
public String getAltFont(int chpFtc ) { if(chpFtc >= _stringCount) { _logger.log(POILogger.INFO, "Mismatch in chpFtc with stringCount"); return null; } return _fontNames[chpFtc].getAltFontName(); }
public void writeTo( ByteArrayOutputStream tableStream ) throws IOException { byte[] buf = new byte[LittleEndian.SHORT_SIZE]; LittleEndian.putShort(buf, 0, _stringCount); tableStream.write(buf); LittleEndian.putShort(buf, 0, _extraDataSz); tableStream.write(buf); for(int i = 0; i < _fontNames.length; i++) { tableStream.write(_fontNames[i].toByteArray()); } }
if (((Ffn)o).get_cbFfnM1() == _cbFfnM1)
System.out.println("Font: "+f.getMainFontName()+", "+f.getSize()+", "+f.getWeight());
public Ffn(byte[] buf, int offset) { int offsetTmp = offset; _cbFfnM1 = LittleEndian.getUnsignedByte(buf,offset); offset += LittleEndian.BYTE_SIZE; _info = buf[offset]; offset += LittleEndian.BYTE_SIZE; _wWeight = LittleEndian.getShort(buf, offset); offset += LittleEndian.SHORT_SIZE; _chs = buf[offset]; offset += LittleEndian.BYTE_SIZE; _ixchSzAlt = buf[offset]; offset += LittleEndian.BYTE_SIZE; // read panose and fs so we can write them back out. System.arraycopy(buf, offset, _panose, 0, _panose.length); offset += _panose.length; System.arraycopy(buf, offset, _fontSig, 0, _fontSig.length); offset += _fontSig.length; offsetTmp = offset - offsetTmp; _xszFfnLength = (this.getSize() - offsetTmp)/2; _xszFfn = new char[_xszFfnLength]; for(int i = 0; i < _xszFfnLength; i++) { _xszFfn[i] = (char)LittleEndian.getShort(buf, offset); offset += LittleEndian.SHORT_SIZE; } }
public String getAltFont(int chpFtc ) { if(chpFtc >= _stringCount) { _logger.log(POILogger.INFO, "Mismatch in chpFtc with stringCount"); return null; } return _fontNames[chpFtc].getAltFontName(); }
public void writeTo( HWPFOutputStream tableStream ) throws IOException { 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()); } }
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(); } }
public byte[] toByteArray() { int offset = 0; byte[] buf = IOUtils.safelyAllocate(this.getSize(), MAX_RECORD_LENGTH); buf[offset] = (byte)_cbFfnM1; offset += LittleEndian.BYTE_SIZE; buf[offset] = _info; offset += LittleEndian.BYTE_SIZE; LittleEndian.putShort(buf, offset, _wWeight); offset += LittleEndian.SHORT_SIZE; buf[offset] = _chs; offset += LittleEndian.BYTE_SIZE; buf[offset] = _ixchSzAlt; offset += LittleEndian.BYTE_SIZE; System.arraycopy(_panose,0,buf, offset,_panose.length); offset += _panose.length; System.arraycopy(_fontSig,0,buf, offset, _fontSig.length); offset += _fontSig.length; for(int i = 0; i < _xszFfn.length; i++) { LittleEndian.putShort(buf, offset, (short)_xszFfn[i]); offset += LittleEndian.SHORT_SIZE; } return buf; }
public String getMainFont(int chpFtc ) { if(chpFtc >= _stringCount) { _logger.log(POILogger.INFO, "Mismatch in chpFtc with stringCount"); return null; } return _fontNames[chpFtc].getMainFontName(); }
public boolean equals(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 Ffn(byte[] buf, int offset) { int offsetTmp = offset; _cbFfnM1 = LittleEndian.getUByte(buf,offset); offset += LittleEndian.BYTE_SIZE; _info = buf[offset]; offset += LittleEndian.BYTE_SIZE; _wWeight = LittleEndian.getShort(buf, offset); offset += LittleEndian.SHORT_SIZE; _chs = buf[offset]; offset += LittleEndian.BYTE_SIZE; _ixchSzAlt = buf[offset]; offset += LittleEndian.BYTE_SIZE; // read panose and fs so we can write them back out. System.arraycopy(buf, offset, _panose, 0, _panose.length); offset += _panose.length; System.arraycopy(buf, offset, _fontSig, 0, _fontSig.length); offset += _fontSig.length; offsetTmp = offset - offsetTmp; _xszFfnLength = (this.getSize() - offsetTmp)/2; _xszFfn = new char[_xszFfnLength]; for(int i = 0; i < _xszFfnLength; i++) { _xszFfn[i] = (char)LittleEndian.getShort(buf, offset); offset += LittleEndian.SHORT_SIZE; } }