| Constructor: |
protected FontRecord(Font f) {
super(Type.FONT);
Assert.verify(f != null);
pointHeight = f.getPointSize();
colourIndex = f.getColour().getValue();
boldWeight = f.getBoldWeight();
scriptStyle = f.getScriptStyle().getValue();
underlineStyle = f.getUnderlineStyle().getValue();
italic = f.isItalic();
name = f.getName();
struckout = f.isStruckout();
initialized = false;
}
Publicly available copy constructor Parameters:
f - the font to copy
|
public FontRecord(Record t,
WorkbookSettings ws) {
super(t);
byte[] data = getRecord().getData();
pointHeight = IntegerHelper.getInt(data[0], data[1]) /
EXCEL_UNITS_PER_POINT;
colourIndex = IntegerHelper.getInt(data[4], data[5]);
boldWeight = IntegerHelper.getInt(data[6], data[7]);
scriptStyle = IntegerHelper.getInt(data[8], data[9]);
underlineStyle = data[10];
fontFamily = data[11];
characterSet = data[12];
initialized = false;
if ((data[2] & 0x02) != 0)
{
italic = true;
}
if ((data[2] & 0x08) != 0)
{
struckout = true;
}
int numChars = data[14];
if (data[15] == 0)
{
name = StringHelper.getString(data, numChars, 16, ws);
}
else if (data[15] == 1)
{
name = StringHelper.getUnicodeString(data, numChars, 16);
}
else
{
// Some font names don't have the unicode indicator
name = StringHelper.getString(data, numChars, 15, ws);
}
}
Constructs this object from the raw data. Used when reading in a
format record Parameters:
t - the raw data
ws - the workbook settings
|
public FontRecord(Record t,
WorkbookSettings ws,
FontRecord.Biff7 dummy) {
super(t);
byte[] data = getRecord().getData();
pointHeight = IntegerHelper.getInt(data[0], data[1]) /
EXCEL_UNITS_PER_POINT;
colourIndex = IntegerHelper.getInt(data[4], data[5]);
boldWeight = IntegerHelper.getInt(data[6], data[7]);
scriptStyle = IntegerHelper.getInt(data[8], data[9]);
underlineStyle = data[10];
fontFamily = data[11];
initialized = false;
if ((data[2] & 0x02) != 0)
{
italic = true;
}
if ((data[2] & 0x08) != 0)
{
struckout = true;
}
int numChars = data[14];
name = StringHelper.getString(data, numChars, 15, ws);
}
Constructs this object from the raw data. Used when reading in a
format record Parameters:
t - the raw data
ws - the workbook settings
dummy - dummy overload
|
protected FontRecord(String fn,
int ps,
int bold,
boolean it,
int us,
int ci,
int ss) {
super(Type.FONT);
boldWeight = bold;
underlineStyle = us;
name = fn;
pointHeight = ps;
italic = it;
scriptStyle = ss;
colourIndex = ci;
initialized = false;
struckout = false;
}
Constructor, used when creating a new font for writing out. Parameters:
bold - the bold indicator
ps - the point size
us - the underline style
fn - the name
it - italicised indicator
ss - the script style
ci - the colour index
|
| Method from jxl.biff.FontRecord Detail: |
public boolean equals(Object o) {
if (o == this)
{
return true;
}
if (!(o instanceof FontRecord))
{
return false;
}
FontRecord font = (FontRecord) o;
if (pointHeight == font.pointHeight &&
colourIndex == font.colourIndex &&
boldWeight == font.boldWeight &&
scriptStyle == font.scriptStyle &&
underlineStyle == font.underlineStyle &&
italic == font.italic &&
struckout == font.struckout &&
fontFamily == font.fontFamily &&
characterSet == font.characterSet &&
name.equals(font.name))
{
return true;
}
return false;
}
|
public int getBoldWeight() {
return boldWeight;
}
Gets the bold weight for this font |
public Colour getColour() {
return Colour.getInternalColour(colourIndex);
}
Gets the colour for this font |
public byte[] getData() {
byte[] data = new byte[16 + name.length() * 2];
// Excel expects font heights in 1/20ths of a point
IntegerHelper.getTwoBytes(pointHeight * EXCEL_UNITS_PER_POINT, data, 0);
// Set the font attributes to be zero for now
if (italic)
{
data[2] |= 0x2;
}
if (struckout)
{
data[2] |= 0x08;
}
// Set the index to the colour palette
IntegerHelper.getTwoBytes(colourIndex, data, 4);
// Bold style
IntegerHelper.getTwoBytes(boldWeight, data, 6);
// Script style
IntegerHelper.getTwoBytes(scriptStyle, data, 8);
// Underline style
data[10] = (byte) underlineStyle;
// Set the font family to be 0
data[11] = fontFamily;
// Set the character set to be zero
data[12] = characterSet;
// Set the reserved bit to be zero
data[13] = 0;
// Set the length of the font name
data[14] = (byte) name.length();
data[15] = (byte) 1;
// Copy in the string
StringHelper.getUnicodeBytes(name, data, 16);
return data;
}
Gets the byte data for writing out |
public final int getFontIndex() {
return fontIndex;
}
Accessor for the font index |
public String getName() {
return name;
}
Gets the name of this font |
public int getPointSize() {
return pointHeight;
}
Gets the point size for this font, if the font hasn't been initialized |
public ScriptStyle getScriptStyle() {
return ScriptStyle.getStyle(scriptStyle);
}
|
public UnderlineStyle getUnderlineStyle() {
return UnderlineStyle.getStyle(underlineStyle);
}
Gets the underline style for this font |
public int hashCode() {
return name.hashCode();
}
Standard hash code method |
public final void initialize(int pos) {
fontIndex = pos;
initialized = true;
}
Sets the font index of this record. Called from the FormattingRecords
object |
public final boolean isInitialized() {
return initialized;
}
Accessor to see whether this object is initialized or not. |
public boolean isItalic() {
return italic;
}
|
public boolean isStruckout() {
return struckout;
}
Accessor for the strike out flag |
protected void setFontBoldStyle(int bs) {
Assert.verify(!initialized);
boldWeight = bs;
}
Sets the bold style for this font, if the font hasn't been initialized |
protected void setFontColour(int c) {
Assert.verify(!initialized);
colourIndex = c;
}
Sets the colour for this font, if the font hasn't been
initialized |
protected void setFontItalic(boolean i) {
Assert.verify(!initialized);
italic = i;
}
Sets the italic indicator for this font, if the font hasn't been
initialized |
protected void setFontPointSize(int ps) {
Assert.verify(!initialized);
pointHeight = ps;
}
Sets the point size for this font, if the font hasn't been initialized |
protected void setFontScriptStyle(int ss) {
Assert.verify(!initialized);
scriptStyle = ss;
}
Sets the script style (eg. superscript, subscript) for this font,
if the font hasn't been initialized |
protected void setFontStruckout(boolean os) {
struckout = os;
}
|
protected void setFontUnderlineStyle(int us) {
Assert.verify(!initialized);
underlineStyle = us;
}
Sets the underline style for this font, if the font hasn't been
initialized |
public final void uninitialize() {
initialized = false;
}
Resets the initialize flag. This is called by the constructor of
WritableWorkbookImpl to reset the statically declared fonts |