1
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
19
20
21
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
35 AffineTransform aff = new AffineTransform(1, 0, 0, -1, 0, 0);
36
37 FontRenderContext context = new FontRenderContext(aff, false, false);
38
39
40 Font f = new Font("Arial", Font.PLAIN, 1000);
41
42 FontIncluder fe = new PSFontEmbedder(context, os);
43
44
45
46
47 fe.includeFont(f, table, "ExampleFont");
48
49 }
50
51 public void closeFile() throws IOException {
52
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 }