From bb6dd55147567b97aac0061e713321825bc32ef9 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Fri, 27 Aug 2010 18:07:13 +0000 Subject: Added support for multi-byte fonts git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript@990219 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/render/ps/PSTextPainter.java | 33 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'src/java/org/apache') diff --git a/src/java/org/apache/fop/render/ps/PSTextPainter.java b/src/java/org/apache/fop/render/ps/PSTextPainter.java index e3dace703..c5237fd80 100644 --- a/src/java/org/apache/fop/render/ps/PSTextPainter.java +++ b/src/java/org/apache/fop/render/ps/PSTextPainter.java @@ -45,6 +45,9 @@ import org.apache.xmlgraphics.ps.PSGenerator; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; +import org.apache.fop.fonts.FontMetrics; +import org.apache.fop.fonts.LazyFont; +import org.apache.fop.fonts.MultiByteFont; import org.apache.fop.svg.NativeTextPainter; import org.apache.fop.util.CharUtilities; @@ -427,14 +430,22 @@ public class PSTextPainter extends NativeTextPainter { textUtil.setCurrentFont(f, mapped); applyColor(paint, gen); + FontMetrics metrics = f.getFontMetrics(); + boolean multiByte = metrics instanceof MultiByteFont + || metrics instanceof LazyFont + && ((LazyFont) metrics).getRealFont() instanceof MultiByteFont; StringBuffer sb = new StringBuffer(); - sb.append('('); + sb.append(multiByte ? '<' : '('); for (int i = 0, c = this.currentChars.length(); i < c; i++) { char ch = this.currentChars.charAt(i); mapped = f.mapChar(ch); - PSGenerator.escapeChar(mapped, sb); + if (multiByte) { + sb.append(HexEncoder.encode(mapped)); + } else { + PSGenerator.escapeChar(mapped, sb); + } } - sb.append(')'); + sb.append(multiByte ? '>' : ')'); if (x || y) { sb.append("\n["); int idx = 0; @@ -512,10 +523,20 @@ public class PSTextPainter extends NativeTextPainter { textUtil.selectFont(f, mapped); textUtil.setCurrentFont(f, mapped); } - mapped = f.mapChar(this.currentChars.charAt(i)); //add glyph outlines to current path - char codepoint = (char)(mapped % 256); - gen.write("(" + codepoint + ")"); + mapped = f.mapChar(this.currentChars.charAt(i)); + FontMetrics metrics = f.getFontMetrics(); + boolean multiByte = metrics instanceof MultiByteFont + || metrics instanceof LazyFont + && ((LazyFont) metrics).getRealFont() instanceof MultiByteFont; + if (multiByte) { + gen.write('<'); + gen.write(HexEncoder.encode(mapped)); + gen.write('>'); + } else { + char codepoint = (char)(mapped % 256); + gen.write("(" + codepoint + ")"); + } gen.writeln(" false charpath"); if (iter.hasNext()) { -- cgit v1.2.3