1   // Copyright 2001-2005 FreeHEP
2   
3   package org.freehep.graphicsio.ps.test;
4   
5   import java.awt.Font;
6   import java.awt.font.FontRenderContext;
7   import java.awt.geom.AffineTransform;
8   import java.io.FileOutputStream;
9   import java.io.IOException;
10  import java.io.PrintStream;
11  
12  import org.freehep.graphics2d.font.CharTable;
13  import org.freehep.graphics2d.font.Lookup;
14  import org.freehep.graphicsio.font.FontIncluder;
15  import org.freehep.graphicsio.ps.PSFontEmbedder;
16  
17  /**
18   * TestClass for PSFontEmbedder.
19   * 
20   * @author Sami Kama
21   * @version $Id: TestPSFontEmbedder.java,v 1.3 2002/07/20 00:39:25 tonyj Exp $
22   */
23  
24  public class TestPSFontEmbedder {
25      protected PrintStream os;
26  
27      public void openFile() throws IOException {
28          this.os = new PrintStream(new FileOutputStream("FontEmbedderPSTest.ps"));
29      }
30  
31      public void writeFont() throws IOException {
32  
33          CharTable table = Lookup.getInstance().getTable("STDLatin");
34          // System.out.println(table);
35          AffineTransform aff = new AffineTransform(1, 0, 0, -1, 0, 0);
36  
37          FontRenderContext context = new FontRenderContext(aff, false, false);
38          // System.out.println(context);
39          // Font f = new Font("Lucida Sans Unicode", Font.PLAIN, 1000);
40          Font f = new Font("Arial", Font.PLAIN, 1000);
41          // System.out.println(f);
42          FontIncluder fe = new PSFontEmbedder(context, os);
43  
44          // System.out.println(fe.getUnicode());
45          // System.out.println("start include font");
46          // ??????? fe.includeFont(f, table, "STDLatin");
47          fe.includeFont(f, table, "ExampleFont");
48          // System.out.println(fe.getNODefinedChars());
49      }
50  
51      public void closeFile() throws IOException {
52          // ??????? os.println("\t/ExampleFont exch definefont pop");
53          os.println("/ExampleFont findfont 26 scalefont setfont");
54          os.println("66 72 moveto");
55          os.println("(ABC abc) show");
56          os.flush();
57          os.close();
58      }
59  
60      public static void main(String[] args) throws IOException {
61          TestPSFontEmbedder test = new TestPSFontEmbedder();
62          test.openFile();
63          test.writeFont();
64          test.closeFile();
65      }
66  }