| Constructor: |
public RtfFont(String fontName) {
super(Font.UNDEFINED, Font.UNDEFINED, Font.UNDEFINED, null);
this.fontName = fontName;
}
Constructs a RtfFont with the given font name and all other properties
at their default values. Parameters:
fontName - The font name to use
|
public RtfFont(String fontName,
float size) {
super(Font.UNDEFINED, size, Font.UNDEFINED, null);
this.fontName = fontName;
}
Constructs a RtfFont with the given font name and font size and all other
properties at their default values. Parameters:
fontName - The font name to use
size - The font size to use
|
protected RtfFont(RtfDocument doc,
int fontNumber) {
this.document = doc;
this.fontNumber = fontNumber;
color = new RtfColor(doc, 0, 0, 0);
}
Special constructor for the default font Parameters:
doc - The RtfDocument this font appears in
fontNumber - The id of this font
|
public RtfFont(RtfDocument doc,
Font font) {
this.document = doc;
if(font != null) {
if(font instanceof RtfFont) {
this.fontName = ((RtfFont) font).getFontName();
this.charset = ((RtfFont) font).getCharset();
} else {
setToDefaultFamily(font.getFamilyname());
}
if(font.getBaseFont() != null) {
String[][] fontNames = font.getBaseFont().getFullFontName();
for(int i = 0; i < fontNames.length; i++) {
if(fontNames[i][2].equals("0")) {
this.fontName = fontNames[i][3];
break;
} else if(fontNames[i][2].equals("1033") || fontNames[i][2].equals("")) {
this.fontName = fontNames[i][3];
}
}
}
setSize(font.getSize());
setStyle(font.getStyle());
setColor(font.getColor());
}
if(this.fontName.equalsIgnoreCase("unknown")) {
return;
}
if(document != null) {
setRtfDocument(document);
}
}
Constructs a RtfFont from a com.lowagie.text.Font Parameters:
doc - The RtfDocument this font appears in
font - The Font to use as a base
|
public RtfFont(String fontName,
float size,
int style) {
super(Font.UNDEFINED, size, style, null);
this.fontName = fontName;
}
Constructs a RtfFont with the given font name, font size and font style and the
default color. Parameters:
fontName - The font name to use
size - The font size to use
style - The font style to use
|
public RtfFont(String fontName,
float size,
int style,
Color color) {
super(Font.UNDEFINED, size, style, color);
this.fontName = fontName;
}
Constructs a RtfFont with the given font name, font size, font style and
color. Parameters:
fontName - The font name to use
size - the font size to use
style - The font style to use
color - The font color to use
|
public RtfFont(String fontName,
float size,
int style,
Color color,
int charset) {
this(fontName, size, style, color);
this.charset = charset;
}
Constructs a RtfFont with the given font name, font size, font style, color
and charset. This can be used when generating non latin-1 text. Parameters:
fontName - The font name to use
size - the font size to use
style - The font style to use
color - The font color to use
charset - The charset of the font content
|
| Method from com.lowagie.text.rtf.style.RtfFont Detail: |
public int compareTo(Object object) {
if (object == null) {
return -1;
}
if(object instanceof RtfFont) {
if(this.getFontName().compareTo(((RtfFont) object).getFontName()) != 0) {
return 1;
} else {
return super.compareTo(object);
}
} else if(object instanceof Font) {
return super.compareTo(object);
} else {
return -3;
}
}
|
public Font difference(Font font) {
String dFamilyname = font.getFamilyname();
if(dFamilyname == null || dFamilyname.trim().equals("") || dFamilyname.trim().equalsIgnoreCase("unknown")) {
dFamilyname = this.fontName;
}
float dSize = font.getSize();
if(dSize == Font.UNDEFINED) {
dSize = this.getSize();
}
int dStyle = Font.UNDEFINED;
if(this.getStyle() != Font.UNDEFINED && font.getStyle() != Font.UNDEFINED) {
dStyle = this.getStyle() | font.getStyle();
} else if(this.getStyle() != Font.UNDEFINED) {
dStyle = this.getStyle();
} else if(font.getStyle() != Font.UNDEFINED) {
dStyle = font.getStyle();
}
Color dColor = font.getColor();
if(dColor == null) {
dColor = this.getColor();
}
int dCharset = this.charset;
if(font instanceof RtfFont) {
dCharset = ((RtfFont) font).getCharset();
}
return new RtfFont(dFamilyname, dSize, dStyle, dColor, dCharset);
}
Replaces the attributes that are equal to null with
the attributes of a given font. |
public boolean equals(Object obj) {
if(!(obj instanceof RtfFont)) {
return false;
}
RtfFont font = (RtfFont) obj;
boolean result = true;
result = result & this.fontName.equals(font.getFontName());
return result;
}
Tests for equality of RtfFonts. RtfFonts are equal if their fontName,
fontSize, fontStyle and fontSuperSubscript are equal |
public int getCharset() {
return charset;
}
Gets the charset used for constructing this RtfFont. |
public String getFamilyname() {
return this.fontName;
}
|
public String getFontName() {
return this.fontName;
}
Gets the font name of this RtfFont |
public int getFontNumber() {
return fontNumber;
}
Gets the font number of this RtfFont |
public int getFontSize() {
return this.fontSize;
}
Gets the font size of this RtfFont |
public int getFontStyle() {
return this.fontStyle;
}
Gets the font style of this RtfFont |
public int hashCode() {
return (this.fontName + this.fontSize + "-" + this.fontStyle).hashCode();
}
Returns the hash code of this RtfFont. The hash code is the hash code of the
string containing the font name + font size + "-" + the font style + "-" + the
font super/supscript value. |
protected byte[] intToByteArray(int i) {
return Integer.toString(i).getBytes();
}
Transforms an integer into its String representation and then returns the bytes
of that string. |
public boolean isStandardFont() {
return false;
}
The RtfFont is never a standard font. |
public void setCharset(int charset) {
this.charset = charset;
}
Sets the charset used for constructing this RtfFont. |
public void setColor(Color color) {
super.setColor(color);
if(color != null) {
this.color = new RtfColor(document, color);
} else {
this.color = null;
}
}
|
public void setColor(int red,
int green,
int blue) {
super.setColor(red,green,blue);
this.color = new RtfColor(document, red, green, blue);
}
|
public void setFamily(String family) {
super.setFamily(family);
setToDefaultFamily(family);
}
|
protected void setFontName(String fontName) {
this.fontName = fontName;
if(document != null) {
this.fontNumber = document.getDocumentHeader().getFontNumber(this);
}
}
Sets the font name of this RtfFont. |
public void setInHeader(boolean inHeader) {
}
|
public void setInTable(boolean inTable) {
}
|
public void setRtfDocument(RtfDocument doc) {
this.document = doc;
if(document != null) {
this.fontNumber = document.getDocumentHeader().getFontNumber(this);
}
if(this.color != null) {
this.color.setRtfDocument(this.document);
}
}
Sets the RtfDocument this RtfFont belongs to |
public void setSize(float size) {
super.setSize(size);
this.fontSize = (int) getSize();
}
|
public void setStyle(int style) {
super.setStyle(style);
this.fontStyle = getStyle();
}
|
public void setStyle(String style) {
super.setStyle(style);
fontStyle = getStyle();
}
|
public void writeBegin(OutputStream result) throws IOException {
if(this.fontNumber != Font.UNDEFINED) {
result.write(RtfFontList.FONT_NUMBER);
result.write(intToByteArray(fontNumber));
}
if(this.fontSize != Font.UNDEFINED) {
result.write(FONT_SIZE);
result.write(intToByteArray(fontSize * 2));
}
if(this.fontStyle != UNDEFINED) {
if((fontStyle & STYLE_BOLD) == STYLE_BOLD) {
result.write(FONT_BOLD);
}
if((fontStyle & STYLE_ITALIC) == STYLE_ITALIC) {
result.write(FONT_ITALIC);
}
if((fontStyle & STYLE_UNDERLINE) == STYLE_UNDERLINE) {
result.write(FONT_UNDERLINE);
}
if((fontStyle & STYLE_STRIKETHROUGH) == STYLE_STRIKETHROUGH) {
result.write(FONT_STRIKETHROUGH);
}
if((fontStyle & STYLE_HIDDEN) == STYLE_HIDDEN) {
result.write(FONT_HIDDEN);
}
if((fontStyle & STYLE_DOUBLE_STRIKETHROUGH) == STYLE_DOUBLE_STRIKETHROUGH) {
result.write(FONT_DOUBLE_STRIKETHROUGH);
result.write(intToByteArray(1));
}
if((fontStyle & STYLE_SHADOW) == STYLE_SHADOW) {
result.write(FONT_SHADOW);
}
if((fontStyle & STYLE_OUTLINE) == STYLE_OUTLINE) {
result.write(FONT_OUTLINE);
}
if((fontStyle & STYLE_EMBOSSED) == STYLE_EMBOSSED) {
result.write(FONT_EMBOSSED);
}
if((fontStyle & STYLE_ENGRAVED) == STYLE_ENGRAVED) {
result.write(FONT_ENGRAVED);
}
}
if(color != null) {
color.writeBegin(result);
}
}
Writes the font beginning |
public void writeContent(OutputStream out) throws IOException {
}
|
public void writeDefinition(OutputStream result) throws IOException {
result.write(FONT_FAMILY);
result.write(FONT_CHARSET);
result.write(intToByteArray(charset));
result.write(DELIMITER);
document.filterSpecialChar(result, fontName, true, false);
}
Writes the font definition |
public void writeEnd(OutputStream result) throws IOException {
if(this.fontStyle != UNDEFINED) {
if((fontStyle & STYLE_BOLD) == STYLE_BOLD) {
result.write(FONT_BOLD);
result.write(intToByteArray(0));
}
if((fontStyle & STYLE_ITALIC) == STYLE_ITALIC) {
result.write(FONT_ITALIC);
result.write(intToByteArray(0));
}
if((fontStyle & STYLE_UNDERLINE) == STYLE_UNDERLINE) {
result.write(FONT_UNDERLINE);
result.write(intToByteArray(0));
}
if((fontStyle & STYLE_STRIKETHROUGH) == STYLE_STRIKETHROUGH) {
result.write(FONT_STRIKETHROUGH);
result.write(intToByteArray(0));
}
if((fontStyle & STYLE_HIDDEN) == STYLE_HIDDEN) {
result.write(FONT_HIDDEN);
result.write(intToByteArray(0));
}
if((fontStyle & STYLE_DOUBLE_STRIKETHROUGH) == STYLE_DOUBLE_STRIKETHROUGH) {
result.write(FONT_DOUBLE_STRIKETHROUGH);
result.write(intToByteArray(0));
}
if((fontStyle & STYLE_SHADOW) == STYLE_SHADOW) {
result.write(FONT_SHADOW);
result.write(intToByteArray(0));
}
if((fontStyle & STYLE_OUTLINE) == STYLE_OUTLINE) {
result.write(FONT_OUTLINE);
result.write(intToByteArray(0));
}
if((fontStyle & STYLE_EMBOSSED) == STYLE_EMBOSSED) {
result.write(FONT_EMBOSSED);
result.write(intToByteArray(0));
}
if((fontStyle & STYLE_ENGRAVED) == STYLE_ENGRAVED) {
result.write(FONT_ENGRAVED);
result.write(intToByteArray(0));
}
}
}
|