From: Jeremias Maerki Date: Tue, 27 May 2003 14:05:49 +0000 (+0000) Subject: Use copy method from Commons IO X-Git-Tag: Root_Temp_KnuthStylePageBreaking~1445 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e261d72b6a5663db05beda713f102c4a9fc978bd;p=xmlgraphics-fop.git Use copy method from Commons IO Bugfix: Names in Unicode don't get extracted properly (#20239) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196460 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fonts/truetype/FontFileReader.java b/src/java/org/apache/fop/fonts/truetype/FontFileReader.java index 1c098a875..d141435c6 100644 --- a/src/java/org/apache/fop/fonts/truetype/FontFileReader.java +++ b/src/java/org/apache/fop/fonts/truetype/FontFileReader.java @@ -54,7 +54,7 @@ import java.io.InputStream; import java.io.File; import java.io.IOException; -import org.apache.fop.util.StreamUtilities; +import org.apache.commons.io.IOUtil; /** * Reads a TrueType font file into a byte array and @@ -75,7 +75,7 @@ public class FontFileReader { private void init(InputStream in) throws java.io.IOException { java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream(); try { - StreamUtilities.streamCopy(in, bout); + IOUtil.copy(in, bout); this.file = bout.toByteArray(); this.fsize = this.file.length; this.current = 0; @@ -341,7 +341,13 @@ public class FontFileReader { byte[] tmp = new byte[len]; System.arraycopy(file, current, tmp, 0, len); current += len; - return new String(tmp, "ISO-8859-1"); + final String encoding; + if ((tmp.length > 0) && (tmp[0] == 0)) { + encoding = "UnicodeBig"; + } else { + encoding = "ISO-8859-1"; + } + return new String(tmp, encoding); } /**