001: /*
002: * Copyright (c) 2007, intarsys consulting GmbH
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * - Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * - Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * - Neither the name of intarsys nor the names of its contributors may be used
015: * to endorse or promote products derived from this software without specific
016: * prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
028: * POSSIBILITY OF SUCH DAMAGE.
029: */
030: package de.intarsys.pdf.font;
031:
032: import de.intarsys.font.FontStyle;
033: import de.intarsys.pdf.cds.CDSMatrix;
034: import de.intarsys.pdf.cos.COSBasedObject;
035: import de.intarsys.pdf.cos.COSDictionary;
036: import de.intarsys.pdf.cos.COSName;
037: import de.intarsys.pdf.cos.COSObject;
038:
039: /**
040: *
041: */
042: public class PDFontType3 extends PDFont {
043: // additional entries from a type 3 font dict
044: public static final COSName DK_FontBBox = COSName
045: .constant("FontBBox");
046:
047: public static final COSName DK_FontMatrix = COSName
048: .constant("FontMatrix");
049:
050: public static final COSName DK_CharProcs = COSName
051: .constant("CharProcs");
052:
053: public static final COSName DK_Resources = COSName
054: .constant("Resources");
055:
056: public static final COSName DK_ToUnicode = COSName
057: .constant("ToUnicode");
058:
059: /**
060: * The meta class implementation
061: */
062: static public class MetaClass extends PDFont.MetaClass {
063: protected MetaClass(Class instanceClass) {
064: super (instanceClass);
065: }
066:
067: protected COSBasedObject doCreateCOSBasedObject(COSObject object) {
068: return new PDFontType3(object);
069: }
070: }
071:
072: /** The meta class instance */
073: static public final MetaClass META = new MetaClass(MetaClass.class
074: .getDeclaringClass());
075:
076: /**
077: * @param object
078: */
079: public PDFontType3(COSObject object) {
080: super (object);
081: }
082:
083: /*
084: * (non-Javadoc)
085: *
086: * @see de.intarsys.pdf.font.PDFont#getUnderlinePosition()
087: */
088: public float getUnderlinePosition() {
089: return 0;
090: }
091:
092: /*
093: * (non-Javadoc)
094: *
095: * @see de.intarsys.pdf.font.PDFont#getUnderlineThickness()
096: */
097: public int getUnderlineThickness() {
098: return 0;
099: }
100:
101: /*
102: * (non-Javadoc)
103: *
104: * @see de.intarsys.pdf.pd.PDObject#cosGetExpectedSubtype()
105: */
106: protected COSName cosGetExpectedSubtype() {
107: return CN_Subtype_Type3;
108: }
109:
110: /*
111: * (non-Javadoc)
112: *
113: * @see de.intarsys.font.IFont#getFontFamilyName()
114: */
115: public String getFontFamilyName() {
116: return "Helvetica";
117: }
118:
119: public String getFontName() {
120: return "Helvetica";
121: }
122:
123: /*
124: * (non-Javadoc)
125: *
126: * @see de.intarsys.font.IFont#getFontStyle()
127: */
128: public FontStyle getFontStyle() {
129: return FontStyle.REGULAR;
130: }
131:
132: /*
133: * (non-Javadoc)
134: *
135: * @see de.intarsys.pdf.font.PDFont#isEmbedded()
136: */
137: public boolean isEmbedded() {
138: return true;
139: }
140:
141: /*
142: * (non-Javadoc)
143: *
144: * @see de.intarsys.pdf.font.PDFont#isSubset()
145: */
146: public boolean isSubset() {
147: return false;
148: }
149:
150: /*
151: * (non-Javadoc)
152: *
153: * @see java.lang.Object#toString()
154: */
155: public String toString() {
156: return cosGetSubtype() + "-Font "; //$NON-NLS-1$
157: }
158:
159: /*
160: * (non-Javadoc)
161: *
162: * @see de.intarsys.pdf.font.PDFont#createBuiltinFontDescriptor()
163: */
164: protected PDFontDescriptor createBuiltinFontDescriptor() {
165: return null;
166: }
167:
168: /*
169: * (non-Javadoc)
170: *
171: * @see de.intarsys.pdf.font.PDFont#getNextCID(byte[], int)
172: */
173: public CID getNextCID(byte[] bytes, int offset) {
174: return new CIDSelectorCode((bytes[offset] & 0xff));
175: }
176:
177: public COSDictionary cosGetCharProcs() {
178: return cosGetField(DK_CharProcs).asDictionary();
179: }
180:
181: public COSDictionary cosSetCharProcs(COSDictionary newDict) {
182: return cosSetField(DK_CharProcs, newDict).asDictionary();
183: }
184:
185: public CDSMatrix getFontMatrix() {
186: return CDSMatrix.createFromCOS(cosGetField(DK_FontMatrix)
187: .asArray());
188: }
189:
190: public void setMatrix(CDSMatrix fontMatrix) {
191: setFieldObject(DK_FontMatrix, fontMatrix);
192: }
193: }
|