|
|
|
@ -49,11 +49,13 @@
|
|
|
|
|
|
|
|
|
|
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.pdf.BaseFont; |
|
|
|
|
|
|
|
|
|
import java.awt.Color; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Contains all the specifications of a font: fontfamily, size, style and color. |
|
|
|
|
* <P> |
|
|
|
@ -133,6 +135,14 @@ public class Font implements Comparable {
|
|
|
|
|
/** the external font */ |
|
|
|
|
private BaseFont baseFont = null; |
|
|
|
|
|
|
|
|
|
private String fontName = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getFontName(){ |
|
|
|
|
return fontName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// constructors
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -141,7 +151,7 @@ public class Font implements Comparable {
|
|
|
|
|
* @param other |
|
|
|
|
* 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.size = other.size; |
|
|
|
|
this.style = other.style; |
|
|
|
@ -169,6 +179,13 @@ public class Font implements Comparable {
|
|
|
|
|
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. |
|
|
|
|
* |
|
|
|
@ -285,9 +302,9 @@ public class Font implements Comparable {
|
|
|
|
|
if (object == null) { |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
Font font; |
|
|
|
|
com.fr.third.com.lowagie.text.Font font; |
|
|
|
|
try { |
|
|
|
|
font = (Font) object; |
|
|
|
|
font = (com.fr.third.com.lowagie.text.Font) object; |
|
|
|
|
if (baseFont != null && !baseFont.equals(font.getBaseFont())) { |
|
|
|
|
return -2; |
|
|
|
|
} |
|
|
|
@ -335,35 +352,7 @@ public class Font implements Comparable {
|
|
|
|
|
* @return the familyname |
|
|
|
|
*/ |
|
|
|
|
public String getFamilyname() { |
|
|
|
|
String tmp = "unknown"; |
|
|
|
|
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; |
|
|
|
|
return getFontName(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -374,9 +363,10 @@ public class Font implements Comparable {
|
|
|
|
|
* A <CODE>String</CODE> representing a certain font-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 |
|
|
|
|
* index that is used for this family in this class. |
|
|
|
@ -697,7 +687,7 @@ public class Font implements Comparable {
|
|
|
|
|
encoding = BaseFont.ZAPFDINGBATS; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
case Font.HELVETICA: |
|
|
|
|
case com.fr.third.com.lowagie.text.Font.HELVETICA: |
|
|
|
|
switch (style & BOLDITALIC) { |
|
|
|
|
case BOLD: |
|
|
|
|
fontName = BaseFont.HELVETICA_BOLD; |
|
|
|
@ -746,7 +736,7 @@ public class Font implements Comparable {
|
|
|
|
|
* the font of a bigger element class
|
|
|
|
|
* @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; |
|
|
|
|
// size
|
|
|
|
|
float dSize = font.size; |
|
|
|
@ -771,20 +761,20 @@ public class Font implements Comparable {
|
|
|
|
|
} |
|
|
|
|
// family
|
|
|
|
|
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) { |
|
|
|
|
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 (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 { |
|
|
|
|
return FontFactory.getFont(this.getFamilyname(), dSize, dStyle, |
|
|
|
|
dColor); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return new Font(this.family, dSize, dStyle, dColor); |
|
|
|
|
return new com.fr.third.com.lowagie.text.Font(this.family, dSize, dStyle, dColor); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|