jeremias 2003/06/02 13:03:59
Modified: src/java/org/apache/fop/render/ps PSProcSets.java
Log:
Fix character set problems with Type 1 fonts
Establish WinAnsiEncoding in PS interpreter
Reencodes all fonts except Symbol and ZapfDingbats as WinAnsiEncoding
Financed by: CTB/McGraw-Hill
Revision Changes Path
1.3 +41 -7 xml-fop/src/java/org/apache/fop/render/ps/PSProcSets.java
Index: PSProcSets.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/ps/PSProcSets.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PSProcSets.java 17 Apr 2003 15:35:20 -0000 1.2
+++ PSProcSets.java 2 Jun 2003 20:03:59 -0000 1.3
@@ -55,6 +55,7 @@
import java.util.Map;
import org.apache.fop.fonts.Font;
+import org.apache.fop.fonts.Glyphs;
import org.apache.fop.layout.FontInfo;
/**
@@ -225,19 +226,52 @@
}
gen.writeln("end def");
gen.writeln("%%EndResource");
+ defineWinAnsiEncoding(gen);
+
+ //Rewrite font encodings
enum = fonts.keySet().iterator();
while (enum.hasNext()) {
String key = (String)enum.next();
Font fm = (Font)fonts.get(key);
- gen.writeln("/" + fm.getFontName() + " findfont");
- gen.writeln("dup length dict begin");
- gen.writeln(" {1 index /FID ne {def} {pop pop} ifelse} forall");
- gen.writeln(" /Encoding ISOLatin1Encoding def");
- gen.writeln(" currentdict");
- gen.writeln("end");
- gen.writeln("/" + fm.getFontName() + " exch definefont pop");
+ if (null == fm.getEncoding()) {
+ //ignore (ZapfDingbats and Symbol run through here
+ //TODO: ZapfDingbats and Symbol should get getEncoding() fixed!
+ } else if ("WinAnsiEncoding".equals(fm.getEncoding())) {
+ gen.writeln("/" + fm.getFontName() + " findfont");
+ gen.writeln("dup length dict begin");
+ gen.writeln(" {1 index /FID ne {def} {pop pop} ifelse} forall");
+ gen.writeln(" /Encoding " + fm.getEncoding() + " def");
+ gen.writeln(" currentdict");
+ gen.writeln("end");
+ gen.writeln("/" + fm.getFontName() + " exch definefont pop");
+ } else {
+ System.out.println("Only WinAnsiEncoding is supported. Font '"
+ + fm.getFontName() + "' asks for: " + fm.getEncoding());
+ }
}
}
+ private static void defineWinAnsiEncoding(PSGenerator gen) throws IOException {
+ gen.writeln("/WinAnsiEncoding [");
+ for (int i = 0; i < Glyphs.WINANSI_ENCODING.length; i++) {
+ if (i > 0) {
+ if ((i % 5) == 0) {
+ gen.newLine();
+ } else {
+ gen.write(" ");
+ }
+ }
+ final char ch = Glyphs.WINANSI_ENCODING[i];
+ final String glyphname = Glyphs.charToGlyphName(ch);
+ if ("".equals(glyphname)) {
+ gen.write("/" + Glyphs.NOTDEF);
+ } else {
+ gen.write("/");
+ gen.write(glyphname);
+ }
+ }
+ gen.newLine();
+ gen.writeln("] def");
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]