1
2 package org.freehep.graphicsio.font.truetype.test;
3
4 import java.awt.Rectangle;
5
6 import javax.swing.JFrame;
7
8 import org.freehep.graphicsio.font.truetype.TTFFile;
9 import org.freehep.graphicsio.font.truetype.TTFFont;
10 import org.freehep.graphicsio.font.truetype.TTFGlyfTable;
11 import org.freehep.graphicsio.font.truetype.TTFHeadTable;
12
13
14
15
16
17
18 public class TTFFileTest {
19
20 public static void main(String[] args) throws Exception {
21
22 String fontName = "linux/LucidaBrightRegular.ttf";
23
24
25
26 if (args.length == 1) {
27 fontName = args[0];
28 }
29 TTFFont ttf = new TTFFile(fontName);
30
31
32 System.out.println("\n---");
33
34
35 TTFGlyfTable.Glyph glyph = ((TTFGlyfTable) ttf.getTable("glyf"))
36 .getGlyph(120);
37 System.out.println();
38 System.out.println(glyph.toDetailedString());
39
40 Rectangle maxCharBounds = ((TTFHeadTable) ttf.getTable("head"))
41 .getMaxCharBounds();
42 JFrame frame = new JFrame("TTF Test");
43 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
44 frame.getContentPane().add(new GlyphPanel(glyph, maxCharBounds));
45 frame.pack();
46 frame.setVisible(true);
47
48 ttf.close();
49 }
50
51 }