diff options
author | Jeremias Maerki <jeremias@apache.org> | 2007-11-12 08:52:11 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2007-11-12 08:52:11 +0000 |
commit | 44187d0d1e9916f2d872f4cb4e73d1209fc65191 (patch) | |
tree | 418bf514c53a3ee1e85aeda72f2cb6b078e9004f /src/java/org/apache/fop/fo/properties/CommonHyphenation.java | |
parent | 66f4f9aa79343ec31afbf0a2fbe4a5359ff649ec (diff) | |
download | xmlgraphics-fop-44187d0d1e9916f2d872f4cb4e73d1209fc65191.tar.gz xmlgraphics-fop-44187d0d1e9916f2d872f4cb4e73d1209fc65191.zip |
Better solution for missing hyphenation character problem.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@594054 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/properties/CommonHyphenation.java')
-rw-r--r-- | src/java/org/apache/fop/fo/properties/CommonHyphenation.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/fo/properties/CommonHyphenation.java b/src/java/org/apache/fop/fo/properties/CommonHyphenation.java index d08d18312..28f44fbce 100644 --- a/src/java/org/apache/fop/fo/properties/CommonHyphenation.java +++ b/src/java/org/apache/fop/fo/properties/CommonHyphenation.java @@ -19,6 +19,8 @@ package org.apache.fop.fo.properties; +import org.apache.commons.logging.Log; +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; @@ -29,6 +31,9 @@ import org.apache.fop.fo.expr.PropertyException; * Public "structure" allows direct member access. */ public final class CommonHyphenation { + + /** Logger */ + protected static Log log = LogFactory.getLog(CommonHyphenation.class); private static final PropertyCache cache = new PropertyCache(); @@ -111,6 +116,47 @@ public final class CommonHyphenation { } + private static final char HYPHEN_MINUS = '-'; + private static final char MINUS_SIGN = '\u2212'; + + /** + * Returns the effective hyphenation character for a font. The hyphenation character specified + * in XSL-FO may be substituted if it's not available in the font. + * @param font the font + * @return the effective hyphenation character. + */ + public char getHyphChar(org.apache.fop.fonts.Font font) { + char hyphChar = hyphenationCharacter.getCharacter(); + char effHyphChar = hyphChar; + if (font.hasChar(effHyphChar)) { + //nop + } else if (font.hasChar(HYPHEN_MINUS)) { + effHyphChar = HYPHEN_MINUS; + } else if (font.hasChar(MINUS_SIGN)) { + effHyphChar = MINUS_SIGN; + } else { + effHyphChar = ' '; + } + if (hyphChar != effHyphChar) { + log.warn("Substituted specified hyphenation character (0x" + + Integer.toHexString(hyphChar) + + ") with 0x" + Integer.toHexString(effHyphChar) + + " because the font doesn't have the specified hyphenation character: " + + font.getFontTriplet()); + } + return effHyphChar; + } + + /** + * Returns the IPD for the hyphenation character for a font. + * @param font the font + * @return the IPD in millipoints for the hyphenation character. + */ + public int getHyphIPD(org.apache.fop.fonts.Font font) { + char hyphChar = getHyphChar(font); + return font.getCharWidth(hyphChar); + } + /** {@inheritDoc */ public boolean equals(Object obj) { if (obj == this) { |