aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/codegen/fonts/font-file.xsl9
-rw-r--r--src/java/org/apache/fop/fonts/CustomFont.java16
-rw-r--r--src/java/org/apache/fop/fonts/FontMetrics.java7
-rw-r--r--src/java/org/apache/fop/fonts/FontReader.java5
-rw-r--r--src/java/org/apache/fop/fonts/LazyFont.java5
-rw-r--r--src/java/org/apache/fop/fonts/MutableFont.java7
-rw-r--r--src/java/org/apache/fop/fonts/apps/TTFReader.java9
-rw-r--r--src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java19
-rw-r--r--src/java/org/apache/fop/fonts/truetype/TTFFile.java61
-rw-r--r--src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java2
-rw-r--r--src/java/org/apache/fop/fonts/type1/Type1FontLoader.java5
-rw-r--r--src/java/org/apache/fop/render/afp/fonts/AFPFont.java7
-rw-r--r--src/java/org/apache/fop/render/java2d/FontMetricsMapper.java7
-rw-r--r--src/java/org/apache/fop/render/java2d/FontSetup.java9
14 files changed, 101 insertions, 67 deletions
diff --git a/src/codegen/fonts/font-file.xsl b/src/codegen/fonts/font-file.xsl
index 316d8a784..17d6de2e3 100644
--- a/src/codegen/fonts/font-file.xsl
+++ b/src/codegen/fonts/font-file.xsl
@@ -39,6 +39,7 @@ package org.apache.fop.fonts.base14;
<xsl:if test="count(kerning) &gt; 0">
import java.util.Map;
</xsl:if>
+import java.util.Set;
import org.apache.fop.fonts.FontType;
import org.apache.fop.fonts.Typeface;
import org.apache.fop.fonts.CodePointMapping;
@@ -46,7 +47,7 @@ import org.apache.fop.fonts.CodePointMapping;
public class <xsl:value-of select="class-name"/> extends Typeface {
private final static String fontName = "<xsl:value-of select="font-name"/>";
private final static String fullName = "<xsl:value-of select="full-name"/>";
- private final static String familyName = "<xsl:value-of select="family-name"/>";
+ private final static Set familyNames;
private final static String encoding = <xsl:choose><xsl:when test="$encoding != $native-encoding">"<xsl:value-of select="$encoding"/>"</xsl:when><xsl:otherwise>null</xsl:otherwise></xsl:choose>;
private final static int capHeight = <xsl:value-of select="cap-height"/>;
private final static int xHeight = <xsl:value-of select="x-height"/>;
@@ -72,6 +73,8 @@ public class <xsl:value-of select="class-name"/> extends Typeface {
Map pairs;
<xsl:apply-templates select="kerning"/>
</xsl:if>
+ familyNames = new java.util.HashSet();
+ familyNames.add("<xsl:value-of select="family-name"/>");
}
public <xsl:value-of select="class-name"/>() {
@@ -98,8 +101,8 @@ public class <xsl:value-of select="class-name"/> extends Typeface {
return fullName;
}
- public String getFamilyName() {
- return familyName;
+ public Set getFamilyNames() {
+ return familyNames;
}
public FontType getFontType() {
diff --git a/src/java/org/apache/fop/fonts/CustomFont.java b/src/java/org/apache/fop/fonts/CustomFont.java
index 8e2bb918e..f165fbd67 100644
--- a/src/java/org/apache/fop/fonts/CustomFont.java
+++ b/src/java/org/apache/fop/fonts/CustomFont.java
@@ -20,7 +20,9 @@
package org.apache.fop.fonts;
import java.io.IOException;
+import java.util.Collections;
import java.util.Map;
+import java.util.Set;
import javax.xml.transform.Source;
@@ -32,7 +34,7 @@ public abstract class CustomFont extends Typeface
private String fontName = null;
private String fullName = null;
- private String familyName = null;
+ private Set familyNames = null; //Set<String>
private String fontSubName = null;
private String embedFileName = null;
private String embedResourceName = null;
@@ -71,11 +73,11 @@ public abstract class CustomFont extends Typeface
}
/**
- * Return the font family.
- * @return the font family
+ * Returns the font family names.
+ * @return the font family names (a Set of Strings)
*/
- public String getFamilyName() {
- return familyName;
+ public Set getFamilyNames() {
+ return Collections.unmodifiableSet(this.familyNames);
}
/**
@@ -280,8 +282,8 @@ public abstract class CustomFont extends Typeface
}
/** {@inheritDoc} */
- public void setFamilyName(String name) {
- this.familyName = name;
+ public void setFamilyNames(Set names) {
+ this.familyNames = new java.util.HashSet(names);
}
/**
diff --git a/src/java/org/apache/fop/fonts/FontMetrics.java b/src/java/org/apache/fop/fonts/FontMetrics.java
index 2c4ada0ae..ce4b1ff00 100644
--- a/src/java/org/apache/fop/fonts/FontMetrics.java
+++ b/src/java/org/apache/fop/fonts/FontMetrics.java
@@ -20,6 +20,7 @@
package org.apache.fop.fonts;
import java.util.Map;
+import java.util.Set;
/**
@@ -40,10 +41,10 @@ public interface FontMetrics {
String getFullName();
/**
- * Returns the font's family name (Example: "Helvetica").
- * @return the font's family name
+ * Returns the font's family names as a Set of Strings (Example: "Helvetica").
+ * @return the font's family names (a Set of Strings)
*/
- String getFamilyName();
+ Set getFamilyNames();
/**
* Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").
diff --git a/src/java/org/apache/fop/fonts/FontReader.java b/src/java/org/apache/fop/fonts/FontReader.java
index f276ae995..51d90c7e5 100644
--- a/src/java/org/apache/fop/fonts/FontReader.java
+++ b/src/java/org/apache/fop/fonts/FontReader.java
@@ -23,6 +23,7 @@ package org.apache.fop.fonts;
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.xml.parsers.SAXParserFactory;
@@ -229,7 +230,9 @@ public class FontReader extends DefaultHandler {
} else if ("full-name".equals(localName)) {
multiFont.setFullName(content);
} else if ("family-name".equals(localName)) {
- multiFont.setFamilyName(content);
+ Set s = new java.util.HashSet();
+ s.add(content);
+ multiFont.setFamilyNames(s);
} else if ("ttc-name".equals(localName) && isCID) {
multiFont.setTTCName(content);
} else if ("encoding".equals(localName)) {
diff --git a/src/java/org/apache/fop/fonts/LazyFont.java b/src/java/org/apache/fop/fonts/LazyFont.java
index 45917aeef..cc05d31b8 100644
--- a/src/java/org/apache/fop/fonts/LazyFont.java
+++ b/src/java/org/apache/fop/fonts/LazyFont.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Map;
+import java.util.Set;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
@@ -208,9 +209,9 @@ public class LazyFont extends Typeface implements FontDescriptor {
}
/** {@inheritDoc} */
- public String getFamilyName() {
+ public Set getFamilyNames() {
load(true);
- return realFont.getFamilyName();
+ return realFont.getFamilyNames();
}
/**
diff --git a/src/java/org/apache/fop/fonts/MutableFont.java b/src/java/org/apache/fop/fonts/MutableFont.java
index 657239dcf..12260435d 100644
--- a/src/java/org/apache/fop/fonts/MutableFont.java
+++ b/src/java/org/apache/fop/fonts/MutableFont.java
@@ -20,6 +20,7 @@
package org.apache.fop.fonts;
import java.util.Map;
+import java.util.Set;
/**
@@ -41,10 +42,10 @@ public interface MutableFont {
void setFullName(String name);
/**
- * Sets the font's family name (Example: "Helvetica").
- * @param name the font's family name
+ * Sets the font's family names (Example: "Helvetica").
+ * @param name the font's family names (a Set of Strings)
*/
- void setFamilyName(String name);
+ void setFamilyNames(Set names);
/**
* Sets the path to the embeddable font file.
diff --git a/src/java/org/apache/fop/fonts/apps/TTFReader.java b/src/java/org/apache/fop/fonts/apps/TTFReader.java
index f7eeb89d7..c2cb4ecba 100644
--- a/src/java/org/apache/fop/fonts/apps/TTFReader.java
+++ b/src/java/org/apache/fop/fonts/apps/TTFReader.java
@@ -22,6 +22,7 @@ package org.apache.fop.fonts.apps;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -209,7 +210,7 @@ public class TTFReader extends AbstractFontReader {
if (!supported) {
return null;
}
- log.info("Font Family: " + ttfFile.getFamilyName());
+ log.info("Font Family: " + ttfFile.getFamilyNames());
if (ttfFile.isCFF()) {
throw new UnsupportedOperationException(
"OpenType fonts with CFF data are not supported, yet");
@@ -271,10 +272,12 @@ public class TTFReader extends AbstractFontReader {
root.appendChild(el);
el.appendChild(doc.createTextNode(ttf.getFullName()));
}
- if (ttf.getFamilyName() != null) {
+ Set familyNames = ttf.getFamilyNames();
+ if (familyNames.size() > 0) {
+ String familyName = (String)familyNames.iterator().next();
el = doc.createElement("family-name");
root.appendChild(el);
- el.appendChild(doc.createTextNode(ttf.getFamilyName()));
+ el.appendChild(doc.createTextNode(familyName));
}
el = doc.createElement("embed");
diff --git a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
index 4876a6f1d..759327ad0 100644
--- a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
+++ b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
@@ -22,7 +22,9 @@ package org.apache.fop.fonts.autodetect;
import java.io.IOException;
import java.net.URL;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -52,6 +54,13 @@ public class FontInfoFinder {
* @param triplet Collection that will take the generated triplets
*/
private void generateTripletsFromFont(CustomFont customFont, Collection triplets) {
+ if (log.isTraceEnabled()) {
+ log.trace("Font: " + customFont.getFullName()
+ + ", family: " + customFont.getFamilyNames()
+ + ", PS: " + customFont.getFontName()
+ + ", EmbedName: " + customFont.getEmbedFontName());
+ }
+
// default style and weight triplet vales (fallback)
String strippedName = customFont.getStrippedFontName();
String subName = customFont.getFontSubName();
@@ -70,9 +79,13 @@ public class FontInfoFinder {
if (!fullName.equals(strippedName)) {
triplets.add(new FontTriplet(strippedName, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL));
}
- String familyName = customFont.getFamilyName();
- if (!fullName.equals(familyName)) {
- triplets.add(new FontTriplet(familyName, style, weight));
+ Set familyNames = customFont.getFamilyNames();
+ Iterator iter = familyNames.iterator();
+ while (iter.hasNext()) {
+ String familyName = (String)iter.next();
+ if (!fullName.equals(familyName)) {
+ triplets.add(new FontTriplet(familyName, style, weight));
+ }
}
}
diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFile.java b/src/java/org/apache/fop/fonts/truetype/TTFFile.java
index b40202b7f..f46bcadd9 100644
--- a/src/java/org/apache/fop/fonts/truetype/TTFFile.java
+++ b/src/java/org/apache/fop/fonts/truetype/TTFFile.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -77,7 +78,7 @@ public class TTFFile {
private String postScriptName = "";
private String fullName = "";
private String notice = "";
- private String familyName = "";
+ private Set familyNames = new java.util.HashSet(); //Set<String>
private String subFamilyName = "";
private long italicAngle = 0;
@@ -538,34 +539,19 @@ public class TTFFile {
}
/**
- * Returns the Windows name of the font.
- * @return String The Windows name
- */
- public String getWindowsName() {
- return familyName + "," + subFamilyName;
- }
-
- /**
* Returns the PostScript name of the font.
* @return String The PostScript name
*/
public String getPostScriptName() {
return postScriptName;
- /*
- if ("Regular".equals(subFamilyName) || "Roman".equals(subFamilyName)) {
- return familyName;
- } else {
- return familyName + "," + subFamilyName;
- }
- */
}
/**
- * Returns the font family name of the font.
- * @return String The family name
+ * Returns the font family names of the font.
+ * @return Set The family names (a Set of Strings)
*/
- public String getFamilyName() {
- return familyName;
+ public Set getFamilyNames() {
+ return familyNames;
}
/**
@@ -1117,8 +1103,7 @@ public class TTFFile {
int l = in.readTTFUShort();
if (((platformID == 1 || platformID == 3)
- && (encodingID == 0 || encodingID == 1))
- && (k == 1 || k == 2 || k == 0 || k == 4 || k == 6)) {
+ && (encodingID == 0 || encodingID == 1))) {
in.seekSet(j + in.readTTFUShort());
String txt = in.readTTFString(l);
@@ -1130,26 +1115,30 @@ public class TTFFile {
}
switch (k) {
case 0:
- notice = txt;
+ if (notice.length() == 0) {
+ notice = txt;
+ }
break;
- case 1:
- familyName = txt;
+ case 1: //Font Family Name
+ case 16: //Preferred Family
+ familyNames.add(txt);
break;
case 2:
- subFamilyName = txt;
+ if (subFamilyName.length() == 0) {
+ subFamilyName = txt;
+ }
break;
case 4:
- fullName = txt;
+ if (fullName.length() == 0) {
+ fullName = txt;
+ }
break;
case 6:
- postScriptName = txt;
+ if (postScriptName.length() == 0) {
+ postScriptName = txt;
+ }
break;
- }
- if (!notice.equals("")
- && !fullName.equals("")
- && !postScriptName.equals("")
- && !familyName.equals("")
- && !subFamilyName.equals("")) {
+ default:
break;
}
}
@@ -1452,7 +1441,7 @@ public class TTFFile {
// Reset names
notice = "";
fullName = "";
- familyName = "";
+ familyNames.clear();
postScriptName = "";
subFamilyName = "";
}
@@ -1485,7 +1474,7 @@ public class TTFFile {
public void printStuff() {
System.out.println("Font name: " + postScriptName);
System.out.println("Full name: " + fullName);
- System.out.println("Family name: " + familyName);
+ System.out.println("Family name: " + familyNames);
System.out.println("Subfamily name: " + subFamilyName);
System.out.println("Notice: " + notice);
System.out.println("xHeight: " + (int)convertTTFUnit2PDFUnit(xHeight));
diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
index b179bd8fe..53f091f59 100644
--- a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
+++ b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
@@ -68,7 +68,7 @@ public class TTFFontLoader extends FontLoader {
returnFont.setFontName(ttf.getPostScriptName());
returnFont.setFullName(ttf.getFullName());
- returnFont.setFamilyName(ttf.getFamilyName());
+ returnFont.setFamilyNames(ttf.getFamilyNames());
returnFont.setFontSubFamilyName(ttf.getSubFamilyName());
//multiFont.setTTCName(ttcName)
returnFont.setCapHeight(ttf.getCapHeight());
diff --git a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
index a8f8b7613..336435b33 100644
--- a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
+++ b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
@@ -21,6 +21,7 @@ package org.apache.fop.fonts.type1;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Set;
import org.apache.fop.fonts.FontLoader;
import org.apache.fop.fonts.FontResolver;
@@ -63,7 +64,9 @@ public class Type1FontLoader extends FontLoader {
fullName = fullName.replace('-', ' '); //Hack! Try to emulate full name
returnFont.setFullName(fullName); //should be afm.getFullName()!!
//TODO not accurate: we need FullName from the AFM file but we don't have an AFM parser
- returnFont.setFamilyName(pfm.getWindowsName()); //should be afm.getFamilyName()!!
+ Set names = new java.util.HashSet();
+ names.add(pfm.getWindowsName()); //should be afm.getFamilyName()!!
+ returnFont.setFamilyNames(names);
returnFont.setCapHeight(pfm.getCapHeight());
returnFont.setXHeight(pfm.getXHeight());
returnFont.setAscender(pfm.getLowerCaseAscent());
diff --git a/src/java/org/apache/fop/render/afp/fonts/AFPFont.java b/src/java/org/apache/fop/render/afp/fonts/AFPFont.java
index 104ba84b1..2819cf12c 100644
--- a/src/java/org/apache/fop/render/afp/fonts/AFPFont.java
+++ b/src/java/org/apache/fop/render/afp/fonts/AFPFont.java
@@ -19,6 +19,7 @@
package org.apache.fop.render.afp.fonts;
import java.util.Map;
+import java.util.Set;
import org.apache.fop.fonts.FontType;
import org.apache.fop.fonts.Typeface;
@@ -59,8 +60,10 @@ public abstract class AFPFont extends Typeface {
}
/** {@inheritDoc} */
- public String getFamilyName() {
- return getFamilyName();
+ public Set getFamilyNames() {
+ Set s = new java.util.HashSet();
+ s.add(this.name);
+ return s;
}
/**
diff --git a/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java b/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java
index f5f92f741..19ecf1020 100644
--- a/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java
+++ b/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java
@@ -22,6 +22,7 @@ package org.apache.fop.render.java2d;
// Java
import java.awt.Graphics2D;
import java.util.Map;
+import java.util.Set;
import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.fonts.FontType;
@@ -87,8 +88,10 @@ public class FontMetricsMapper extends Typeface implements FontMetrics {
}
/** {@inheritDoc} */
- public String getFamilyName() {
- return getFontName();
+ public Set getFamilyNames() {
+ Set s = new java.util.HashSet();
+ s.add(this.family);
+ return s;
}
/**
diff --git a/src/java/org/apache/fop/render/java2d/FontSetup.java b/src/java/org/apache/fop/render/java2d/FontSetup.java
index df6e4a0de..5637bdee2 100644
--- a/src/java/org/apache/fop/render/java2d/FontSetup.java
+++ b/src/java/org/apache/fop/render/java2d/FontSetup.java
@@ -222,6 +222,15 @@ public class FontSetup {
continue; //skip
}
+ if (log.isTraceEnabled()) {
+ log.trace("AWT Font: " + f.getFontName()
+ + ", family: " + f.getFamily()
+ + ", PS: " + f.getPSName()
+ + ", Name: " + f.getName()
+ + ", Angle: " + f.getItalicAngle()
+ + ", Style: " + f.getStyle());
+ }
+
String searchName = FontUtil.stripWhiteSpace(f.getFontName()).toLowerCase();
String guessedStyle = FontUtil.guessStyle(searchName);
int guessedWeight = FontUtil.guessWeight(searchName);