<xsl:output method="text"/>
<xsl:param name="encoding" select="/font-metrics/encoding"/>
- <xsl:variable name="native-encoding" select="/font-metrics/encoding"/>
<xsl:variable name="glyphs" select="document('encodings.xml')/encoding-set/encoding[@id=$encoding]/glyph"/>
<xsl:template match="font-metrics">
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 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 String encoding = "<xsl:value-of select="$encoding"/>";
private final static int capHeight = <xsl:value-of select="cap-height"/>;
private final static int xHeight = <xsl:value-of select="x-height"/>;
private final static int ascender = <xsl:value-of select="ascender"/>;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fonts.FontMetrics;
+import org.apache.fop.fonts.Typeface;
/**
* Store all common hyphenation properties.
*/
public char getHyphChar(org.apache.fop.fonts.Font font) {
char hyphChar = hyphenationCharacter.getCharacter();
+ if (font.hasChar(hyphChar)) {
+ return hyphChar; //short-cut
+ }
char effHyphChar = hyphChar;
- if (font.hasChar(effHyphChar)) {
- //nop
- } else if (font.hasChar(HYPHEN_MINUS)) {
+ boolean warn = false;
+ if (font.hasChar(HYPHEN_MINUS)) {
effHyphChar = HYPHEN_MINUS;
+ warn = true;
} else if (font.hasChar(MINUS_SIGN)) {
effHyphChar = MINUS_SIGN;
+ FontMetrics metrics = font.getFontMetrics();
+ if (metrics instanceof Typeface) {
+ Typeface typeface = (Typeface)metrics;
+ if ("SymbolEncoding".equals(typeface.getEncoding())) {
+ //SymbolEncoding doesn't have HYPHEN_MINUS, so replace by MINUS_SIGN
+ } else {
+ //only warn if the encoding is not SymbolEncoding
+ warn = true;
+ }
+ }
} else {
effHyphChar = ' ';
+ FontMetrics metrics = font.getFontMetrics();
+ if (metrics instanceof Typeface) {
+ Typeface typeface = (Typeface)metrics;
+ if ("ZapfDingbatsEncoding".equals(typeface.getEncoding())) {
+ //ZapfDingbatsEncoding doesn't have HYPHEN_MINUS, so replace by ' '
+ } else {
+ //only warn if the encoding is not ZapfDingbatsEncoding
+ warn = true;
+ }
+ }
}
- if (hyphChar != effHyphChar) {
+ if (warn) {
log.warn("Substituted specified hyphenation character (0x"
+ Integer.toHexString(hyphChar)
+ ") with 0x" + Integer.toHexString(effHyphChar)
if (fm instanceof LazyFont && ((LazyFont)fm).getRealFont() == null) {
continue;
} else if (null == fm.getEncoding()) {
- //ignore (ZapfDingbats and Symbol run through here
- //TODO: ZapfDingbats and Symbol should get getEncoding() fixed!
+ //ignore (ZapfDingbats and Symbol used to run through here, kept for safety reasons)
+ } else if ("SymbolEncoding".equals(fm.getEncoding())) {
+ //ignore (no encoding redefinition)
+ } else if ("ZapfDingbatsEncoding".equals(fm.getEncoding())) {
+ //ignore (no encoding redefinition)
} else if ("WinAnsiEncoding".equals(fm.getEncoding())) {
redefineFontEncoding(gen, fm.getFontName(), fm.getEncoding());
} else {