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
649650651652653654655656657658659
* @return new font object */ public HSSFFont createFont() { FontRecord font = workbook.createNewFont(); short fontindex = (short) (getNumberOfFonts() - 1); if (fontindex > 3) { fontindex++; // THERE IS NO FOUR!!
679680681682683684685686687688
* @return HSSFFont at the index */ public HSSFFont getFontAt(short idx) { FontRecord font = workbook.getFontRecordAt(idx); HSSFFont retval = new HSSFFont(idx, font); return retval; }
444445446447448449450451452453
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; }
455456457458459460461462463464465
/** * 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);
477478479480481482483484485486487
* * @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;
12331234123512361237123812391240124112421243124412451246
* 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; }
10151016101710181019102010211022102310241025
10851086108710881089109010911092109310941095
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; }
445446447448449450451452453454
456457458459460461462463464465466