diff options
author | Jeremias Maerki <jeremias@apache.org> | 2007-01-26 11:06:01 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2007-01-26 11:06:01 +0000 |
commit | d490e2d0f660fac29aaaae3352c73d5755c91244 (patch) | |
tree | 2b899aeb48b96ccfee3a937414fc425d27dce1df /src | |
parent | 9fdb4963886c9699ac1506404e4acec12f686023 (diff) | |
download | xmlgraphics-fop-d490e2d0f660fac29aaaae3352c73d5755c91244.tar.gz xmlgraphics-fop-d490e2d0f660fac29aaaae3352c73d5755c91244.zip |
Fix for PDF corruption when a TrueType font with spaces in its name is embedded and no XML font metrics file for that font is used.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@500222 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/fop/fonts/MultiByteFont.java | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/java/org/apache/fop/fonts/MultiByteFont.java b/src/java/org/apache/fop/fonts/MultiByteFont.java index 2dd3846ed..1b9263d17 100644 --- a/src/java/org/apache/fop/fonts/MultiByteFont.java +++ b/src/java/org/apache/fop/fonts/MultiByteFont.java @@ -110,11 +110,34 @@ public class MultiByteFont extends CIDFont { } /** + * Removes all white space from a string (used primarily for font names) + * @param s the string + * @return the processed result + */ + public static String stripWhiteSpace(String s) { + StringBuffer sb = new StringBuffer(s.length()); + for (int i = 0, c = s.length(); i < c; i++) { + final char ch = s.charAt(i); + if (ch != ' ' + && ch != '\r' + && ch != '\n' + && ch != '\t') { + sb.append(ch); + } + } + return sb.toString(); + } + + private String getPrefixedFontName() { + return namePrefix + stripWhiteSpace(super.getFontName()); + } + + /** * @see org.apache.fop.fonts.CIDFont#getCidBaseFont() */ public String getCidBaseFont() { if (isEmbeddable()) { - return namePrefix + super.getFontName(); + return getPrefixedFontName(); } else { return super.getFontName(); } @@ -139,7 +162,7 @@ public class MultiByteFont extends CIDFont { */ public String getFontName() { if (isEmbeddable()) { - return namePrefix + super.getFontName(); + return getPrefixedFontName(); } else { return super.getFontName(); } |