1   // Copyright 2001, FreeHEP.
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   * @author Mark Donszelmann
16   * @version $Id: TTFFileTest.java 8584 2006-08-10 23:06:37Z duns $
17   */
18  public class TTFFileTest {
19  
20      public static void main(String[] args) throws Exception {
21          // String fontName = "win1.4/LucidaBrightRegular.ttf";
22          String fontName = "linux/LucidaBrightRegular.ttf";
23          // String fontName = "linux/LucidaBrightItalic.ttf";
24          // String fontName = "windows/LucidaBrightRegular.ttf";
25          // String fontName = "windows/LucidaTypewriterRegular.ttf";
26          if (args.length == 1) {
27              fontName = args[0];
28          }
29          TTFFont ttf = new TTFFile(fontName);
30  
31          // ttf.readAll();
32          System.out.println("\n---");
33          // ttf.show();
34  
35          TTFGlyfTable.Glyph glyph = ((TTFGlyfTable) ttf.getTable("glyf"))
36                  .getGlyph(120);
37          System.out.println();
38          System.out.println(glyph.toDetailedString());
39          // bbox chars: 188, 375, 198, 353
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  }