KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > faceless > pdf > Type1Font


1 // $Id: Type1Font.java,v 1.4 2003/11/04 17:16:01 mike Exp $
2

3 package org.faceless.pdf;
4
5 import java.util.*;
6 import java.io.*;
7
8 /**
9  * <p>
10  * Create a new PostScript Type 1 font. This class of font is commonly
11  * used on UNIX systems. The standard 14 fonts are a special class of
12  * Type 1 font.
13  * </p>
14  * <p>
15  * Type 1 fonts give each character shape, or "glyph", a name, in the
16  * same way the PDF documents refer to glyphs by name (hardly surprising
17  * really, seeing as both Type 1 fonts and PDF documents are defined by
18  * Adobe). Because text written to the PDF via this library is specified
19  * in Unicode, Type 1 fonts need a "mapping" from Unicode character to
20  * Glyph name.
21  * </p>
22  * <p>
23  * For many fonts this isn't a problem. Font's based on the latin character
24  * set (more specifically, fonts implementing a subset of the Adobe
25  * Standard Glyph List) already have their mapping defined. Adobe have a
26  * naming standard for glyphs outside that list
27  * (the {@link PDFEncoding#ADOBE_EXTENDEDMAP}), and if that is followed
28  * then no further thought needs to be given to this issue.
29  * </p>
30  * <p>
31  * If the standard is not followed, it is necessary for the developer to
32  * supply a mapping from Unicode character to Glyph name. This takes the
33  * form of a <code>java.util.Map</code>, with a
34  * <code>java.lang.Character</code> representing a Unicode character as
35  * the key, and a corresponding <code>java.lang.String</code> representing
36  * the name of the glyph as the value. More information on mappings and
37  * encodings in general is given in the preamble to the {@link PDFEncoding}
38  * class.
39  * </p>
40  * @see PDFEncoding
41  * @see TrueTypeFont
42  * @see StandardFont
43  * @version $Revision: 1.4 $
44  */

45 public class Type1Font extends PDFSimpleFont
46 {
47     /**
48      * Create a new Type 1 font, using the standard
49      * {@link PDFEncoding#ADOBE_EXTENDEDMAP} mapping from unicode to glyph name.
50      *
51      * @param afm The <code>.afm</code> (Adobe Font Metrics) file specifying
52      * the metrics for this font
53      *
54      * @param pfb The <code>.pfb</code> or <code>.pfa</code> file containing
55      * the glyph shapes to be embedded in the PDF. If the font is not to be
56      * embedded, this should be null.
57      *
58      * @exception IOException If the <code>.afm</code> or </code>.pfb</code>
59      * InputStream can't be read or parsed
60      */

61     public Type1Font(InputStream afm, InputStream pfb)
62         throws IOException
63     {
64     super(new org.faceless.pdf2.Type1Font(afm,pfb));
65     }
66
67     /**
68      * <p>
69      * Create a new Type 1 font, using a user defined mapping from unicode to glyph name. The font
70      * can be embedded, which ensures that your viewers will see exactly the font you specified, at
71      * the cost of increasing the file size. If a font is not embedded and the viewer does not have
72      * the same font installed, the viewing software will substitute an "appropriate" font.
73      * </p>
74      *
75      * @param afm The <code>.afm</code> (Adobe Font Metrics) file specifying the
76      * metrics for this font
77      *
78      * @param pfb The <code>.pfb</code> or <code>.pfa</code> file containing the glyph
79      * shapes to be embedded in the PDF. If the font is not to be embedded, this should be null.
80      *
81      * @param mapping The mapping from unicode->glyph, as described in the class header above.
82      * @exception IOException If the <code>.afm</code> or </code>.pfb</code> file can't be read or parsed
83      */

84     public Type1Font(InputStream afm, InputStream pfb, Map mapping)
85         throws IOException
86     {
87     super(new org.faceless.pdf2.Type1Font(afm,pfb, mapping));
88     }
89 }
90
Popular Tags