|
|
@ -49,11 +49,13 @@ |
|
|
|
|
|
|
|
|
|
|
|
package com.fr.third.com.lowagie.text; |
|
|
|
package com.fr.third.com.lowagie.text; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.Color; |
|
|
|
import com.fr.third.com.lowagie.text.ExceptionConverter; |
|
|
|
|
|
|
|
import com.fr.third.com.lowagie.text.FontFactory; |
|
|
|
import com.fr.third.com.lowagie.text.html.Markup; |
|
|
|
import com.fr.third.com.lowagie.text.html.Markup; |
|
|
|
import com.fr.third.com.lowagie.text.pdf.BaseFont; |
|
|
|
import com.fr.third.com.lowagie.text.pdf.BaseFont; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.Color; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Contains all the specifications of a font: fontfamily, size, style and color. |
|
|
|
* Contains all the specifications of a font: fontfamily, size, style and color. |
|
|
|
* <P> |
|
|
|
* <P> |
|
|
@ -133,6 +135,14 @@ public class Font implements Comparable { |
|
|
|
/** the external font */ |
|
|
|
/** the external font */ |
|
|
|
private BaseFont baseFont = null; |
|
|
|
private BaseFont baseFont = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String fontName = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getFontName(){ |
|
|
|
|
|
|
|
return fontName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// constructors
|
|
|
|
// constructors
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -141,7 +151,7 @@ public class Font implements Comparable { |
|
|
|
* @param other |
|
|
|
* @param other |
|
|
|
* the font that has to be copied |
|
|
|
* the font that has to be copied |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Font(Font other) { |
|
|
|
public Font(com.fr.third.com.lowagie.text.Font other) { |
|
|
|
this.family = other.family; |
|
|
|
this.family = other.family; |
|
|
|
this.size = other.size; |
|
|
|
this.size = other.size; |
|
|
|
this.style = other.style; |
|
|
|
this.style = other.style; |
|
|
@ -169,6 +179,13 @@ public class Font implements Comparable { |
|
|
|
this.color = color; |
|
|
|
this.color = color; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Font(String face, float size, int style, Color color) { |
|
|
|
|
|
|
|
this.fontName = face; |
|
|
|
|
|
|
|
this.size =size; |
|
|
|
|
|
|
|
this.style = style; |
|
|
|
|
|
|
|
this.color = color; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Constructs a Font. |
|
|
|
* Constructs a Font. |
|
|
|
* |
|
|
|
* |
|
|
@ -285,9 +302,9 @@ public class Font implements Comparable { |
|
|
|
if (object == null) { |
|
|
|
if (object == null) { |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
Font font; |
|
|
|
com.fr.third.com.lowagie.text.Font font; |
|
|
|
try { |
|
|
|
try { |
|
|
|
font = (Font) object; |
|
|
|
font = (com.fr.third.com.lowagie.text.Font) object; |
|
|
|
if (baseFont != null && !baseFont.equals(font.getBaseFont())) { |
|
|
|
if (baseFont != null && !baseFont.equals(font.getBaseFont())) { |
|
|
|
return -2; |
|
|
|
return -2; |
|
|
|
} |
|
|
|
} |
|
|
@ -335,35 +352,7 @@ public class Font implements Comparable { |
|
|
|
* @return the familyname |
|
|
|
* @return the familyname |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public String getFamilyname() { |
|
|
|
public String getFamilyname() { |
|
|
|
String tmp = "unknown"; |
|
|
|
return getFontName(); |
|
|
|
switch (getFamily()) { |
|
|
|
|
|
|
|
case Font.COURIER: |
|
|
|
|
|
|
|
return FontFactory.COURIER; |
|
|
|
|
|
|
|
case Font.HELVETICA: |
|
|
|
|
|
|
|
return FontFactory.HELVETICA; |
|
|
|
|
|
|
|
case Font.TIMES_ROMAN: |
|
|
|
|
|
|
|
return FontFactory.TIMES_ROMAN; |
|
|
|
|
|
|
|
case Font.SYMBOL: |
|
|
|
|
|
|
|
return FontFactory.SYMBOL; |
|
|
|
|
|
|
|
case Font.ZAPFDINGBATS: |
|
|
|
|
|
|
|
return FontFactory.ZAPFDINGBATS; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
if (baseFont != null) { |
|
|
|
|
|
|
|
String[][] names = baseFont.getFamilyFontName(); |
|
|
|
|
|
|
|
for (int i = 0; i < names.length; i++) { |
|
|
|
|
|
|
|
if ("0".equals(names[i][2])) { |
|
|
|
|
|
|
|
return names[i][3]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ("1033".equals(names[i][2])) { |
|
|
|
|
|
|
|
tmp = names[i][3]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ("".equals(names[i][2])) { |
|
|
|
|
|
|
|
tmp = names[i][3]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return tmp; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -374,9 +363,10 @@ public class Font implements Comparable { |
|
|
|
* A <CODE>String</CODE> representing a certain font-family. |
|
|
|
* A <CODE>String</CODE> representing a certain font-family. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setFamily(String family) { |
|
|
|
public void setFamily(String family) { |
|
|
|
this.family = getFamilyIndex(family); |
|
|
|
this.fontName = family; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Translates a <CODE>String</CODE> -value of a certain family into the |
|
|
|
* Translates a <CODE>String</CODE> -value of a certain family into the |
|
|
|
* index that is used for this family in this class. |
|
|
|
* index that is used for this family in this class. |
|
|
@ -697,7 +687,7 @@ public class Font implements Comparable { |
|
|
|
encoding = BaseFont.ZAPFDINGBATS; |
|
|
|
encoding = BaseFont.ZAPFDINGBATS; |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
case Font.HELVETICA: |
|
|
|
case com.fr.third.com.lowagie.text.Font.HELVETICA: |
|
|
|
switch (style & BOLDITALIC) { |
|
|
|
switch (style & BOLDITALIC) { |
|
|
|
case BOLD: |
|
|
|
case BOLD: |
|
|
|
fontName = BaseFont.HELVETICA_BOLD; |
|
|
|
fontName = BaseFont.HELVETICA_BOLD; |
|
|
@ -746,7 +736,7 @@ public class Font implements Comparable { |
|
|
|
* the font of a bigger element class
|
|
|
|
* the font of a bigger element class
|
|
|
|
* @return a <CODE>Font</CODE> |
|
|
|
* @return a <CODE>Font</CODE> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Font difference(Font font) { |
|
|
|
public com.fr.third.com.lowagie.text.Font difference(com.fr.third.com.lowagie.text.Font font) { |
|
|
|
if (font == null) return this; |
|
|
|
if (font == null) return this; |
|
|
|
// size
|
|
|
|
// size
|
|
|
|
float dSize = font.size; |
|
|
|
float dSize = font.size; |
|
|
@ -771,20 +761,20 @@ public class Font implements Comparable { |
|
|
|
} |
|
|
|
} |
|
|
|
// family
|
|
|
|
// family
|
|
|
|
if (font.baseFont != null) { |
|
|
|
if (font.baseFont != null) { |
|
|
|
return new Font(font.baseFont, dSize, dStyle, dColor); |
|
|
|
return new com.fr.third.com.lowagie.text.Font(font.baseFont, dSize, dStyle, dColor); |
|
|
|
} |
|
|
|
} |
|
|
|
if (font.getFamily() != UNDEFINED) { |
|
|
|
if (font.getFamily() != UNDEFINED) { |
|
|
|
return new Font(font.family, dSize, dStyle, dColor); |
|
|
|
return new com.fr.third.com.lowagie.text.Font(font.family, dSize, dStyle, dColor); |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.baseFont != null) { |
|
|
|
if (this.baseFont != null) { |
|
|
|
if (dStyle == style1) { |
|
|
|
if (dStyle == style1) { |
|
|
|
return new Font(this.baseFont, dSize, dStyle, dColor); |
|
|
|
return new com.fr.third.com.lowagie.text.Font(this.baseFont, dSize, dStyle, dColor); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return FontFactory.getFont(this.getFamilyname(), dSize, dStyle, |
|
|
|
return FontFactory.getFont(this.getFamilyname(), dSize, dStyle, |
|
|
|
dColor); |
|
|
|
dColor); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return new Font(this.family, dSize, dStyle, dColor); |
|
|
|
return new com.fr.third.com.lowagie.text.Font(this.family, dSize, dStyle, dColor); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|