From d490e2d0f660fac29aaaae3352c73d5755c91244 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Fri, 26 Jan 2007 11:06:01 +0000 Subject: [PATCH] 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 --- .../org/apache/fop/fonts/MultiByteFont.java | 27 +++++++++++++++++-- status.xml | 4 +++ 2 files changed, 29 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 @@ -109,12 +109,35 @@ public class MultiByteFont extends CIDFont { this.cidType = cidType; } + /** + * 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(); } diff --git a/status.xml b/status.xml index 1527275c1..4117095fc 100644 --- a/status.xml +++ b/status.xml @@ -28,6 +28,10 @@ + + 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. + Fix for ClassCastException when fo:wrapper was used as direct child of fo:flow. Note: "id" attributes are still not handled properly on fo:wrapper! -- 2.39.5