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 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 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 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; } }
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 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(); } }
System.out.println("Font: "+f.getMainFontName()+", "+f.getSize()+", "+f.getWeight());
System.out.println("Font: "+f.getMainFontName()+", "+f.getSize()+", "+f.getWeight());