Description: An element in the Font Table
REFERENCE: PG 315 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)
@author Andrew C. Oliver (acoliver at apache dot org) @version 2.0-pre
509510511512513514515516517518519
* * @return FontRecord that was just created */ public FontRecord createNewFont() { FontRecord rec = createFont(); records.add(records.getFontpos()+1, rec); records.setFontpos( records.getFontpos() + 1 ); numfonts++; return rec;
12601261126212631264126512661267126812691270127112721273
* bold weight = 0x190<P> * Font Name Length = 5 <P> * Font Name = Arial <P> */ private static FontRecord createFont() { FontRecord retval = new FontRecord(); retval.setFontHeight(( short ) 0xc8); retval.setAttributes(( short ) 0x0); retval.setColorPaletteIndex(( short ) 0x7fff); retval.setBoldWeight(( short ) 0x190); retval.setFontName("Arial"); return retval; }
820821822823824825826827828829830831
short fmt = (short)_workbook.createFormat(source.getDataFormatString() ); setDataFormat(fmt); // Finally we need to clone the font, // and update the format record for this FontRecord fr = _workbook.createNewFont(); fr.cloneStyleFrom( source._workbook.getFontRecordAt( source.getFontIndex() ) );
10171018101910201021102210231024102510261027
* @return new font object */ public HSSFFont createFont() { FontRecord font = workbook.createNewFont(); short fontindex = (short) (getNumberOfFonts() - 1); if (fontindex > 3) { fontindex++; // THERE IS NO FOUR!!
10871088108910901091109210931094109510961097
Short sIdx = Short.valueOf(idx); if(fonts.containsKey(sIdx)) { return (HSSFFont)fonts.get(sIdx); } FontRecord font = workbook.getFontRecordAt(idx); HSSFFont retval = new HSSFFont(idx, font); fonts.put(sIdx, retval); return retval; }
457458459460461462463464465466
if (index > (numfonts - 1)) { throw new ArrayIndexOutOfBoundsException( "There are only " + numfonts + " font records, you asked for " + idx); } FontRecord retval = ( FontRecord ) records.get((records.getFontpos() - (numfonts - 1)) + index); return retval; }
468469470471472473474475476477478
/** * Retrieves the index of the given font */ public int getFontIndex(FontRecord font) { for(int i=0; i<=numfonts; i++) { FontRecord thisFont = ( FontRecord ) records.get((records.getFontpos() - (numfonts - 1)) + i); if(thisFont == font) { // There is no 4! if(i > 3) { return (i+1);
490491492493494495496497498499500
12451246124712481249125012511252125312541255125612571258
10161017101810191020102110221023102410251026