Don't warn about missing hyphenation characters for fonts such as Symbol and ZapfDingbats which don't have the default hyphenation character. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@594067 13f79535-47bb-0310-9956-ffa450edef68tags/fop-0_95beta
@@ -30,7 +30,6 @@ | |||
<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"> | |||
@@ -48,7 +47,7 @@ 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 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"/>; |
@@ -24,6 +24,8 @@ import org.apache.commons.logging.LogFactory; | |||
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. | |||
@@ -127,17 +129,40 @@ public final class CommonHyphenation { | |||
*/ | |||
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) |
@@ -80,6 +80,14 @@ public class Font { | |||
this.fontSize = fontSize; | |||
} | |||
/** | |||
* Returns the associated font metrics object. | |||
* @return the font metrics | |||
*/ | |||
public FontMetrics getFontMetrics() { | |||
return this.metric; | |||
} | |||
/** | |||
* Returns the font's ascender. | |||
* @return the ascender |
@@ -103,8 +103,8 @@ public class SingleByteFont extends CustomFont { | |||
if (d != 0) { | |||
return d; | |||
} else { | |||
log.warn("Glyph " + (int) c + " not available in font " | |||
+ getFontName()); | |||
log.warn("Glyph " + (int)c + " (0x" + Integer.toHexString(c) | |||
+ ") not available in font " + getFontName()); | |||
return '#'; | |||
} | |||
} |
@@ -100,8 +100,11 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { | |||
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 { |