01: /*
02: * $Id: Type0Font.java,v 1.2 2007/12/20 18:33:32 rbair Exp $
03: *
04: * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
05: * Santa Clara, California 95054, U.S.A. All rights reserved.
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20: */
21:
22: package com.sun.pdfview.font;
23:
24: import java.io.IOException;
25:
26: import com.sun.pdfview.PDFObject;
27:
28: /**
29: * Type 0 fonts are composite fonts with a CMAP to map between
30: * source character codes and destination fonts/codes
31: *
32: * @author Jonathan Kaplan
33: */
34: public class Type0Font extends PDFFont {
35:
36: /**
37: * The decendant fonts, indexed by font number from the CMAP
38: */
39: PDFFont[] fonts;
40:
41: /** Creates a new instance of Type0Font */
42: public Type0Font(String baseFont, PDFObject fontObj,
43: PDFFontDescriptor descriptor) throws IOException {
44: super (baseFont, descriptor);
45:
46: PDFObject[] descendantFonts = fontObj.getDictRef(
47: "DescendantFonts").getArray();
48:
49: fonts = new PDFFont[descendantFonts.length];
50:
51: for (int i = 0; i < descendantFonts.length; i++) {
52: fonts[i] = PDFFont.getFont(descendantFonts[i], null);
53: }
54: }
55:
56: /**
57: * Get a descendant font of this font by fontId
58: */
59: public PDFFont getDescendantFont(int fontID) {
60: return fonts[fontID];
61: }
62:
63: /**
64: * Get a character from the first font in the descendant fonts array
65: */
66: protected PDFGlyph getGlyph(char src, String name) {
67: return (getDescendantFont(0).getGlyph(src, name));
68: }
69: }
|