]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fix character set problems with Type 1 fonts
authorJeremias Maerki <jeremias@apache.org>
Mon, 2 Jun 2003 20:03:59 +0000 (20:03 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 2 Jun 2003 20:03:59 +0000 (20:03 +0000)
Establish WinAnsiEncoding in PS interpreter
Reencodes all fonts except Symbol and ZapfDingbats as WinAnsiEncoding
Financed by: CTB/McGraw-Hill

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196484 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/ps/PSProcSets.java

index d8ddf97e3dd405829cefb9e39340e55d67fc94ee..870490446a0f5de99205d1f0797a31d2bebbd1be 100644 (file)
@@ -55,6 +55,7 @@ import java.util.Iterator;
 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 @@ public final class PSProcSets {
         }
         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");
+    }
 
 }