PDFCosFontDescriptor.java
12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.io.stream.InputByteStream
* com.adobe.internal.pdftoolkit.core.cos.CosDictionary
* com.adobe.internal.pdftoolkit.core.cos.CosObject
* com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidParameterException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
* com.adobe.internal.pdftoolkit.core.types.ASName
* com.adobe.internal.pdftoolkit.core.types.ASString
*/
package com.adobe.internal.pdftoolkit.pdf.graphics.font;
import com.adobe.internal.io.stream.InputByteStream;
import com.adobe.internal.pdftoolkit.core.cos.CosDictionary;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidParameterException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.core.types.ASString;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosDictionary;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.graphics.PDFRectangle;
import com.adobe.internal.pdftoolkit.pdf.graphics.font.PDFCIDFontStyle;
import com.adobe.internal.pdftoolkit.pdf.graphics.font.PDFFontDescriptor;
import com.adobe.internal.pdftoolkit.pdf.graphics.font.PDFFontFile;
import com.adobe.internal.pdftoolkit.pdf.graphics.font.PDFFontStretch;
import java.util.List;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class PDFCosFontDescriptor
extends PDFCosDictionary {
private PDFCosFontDescriptor(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFCosFontDescriptor getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFCosFontDescriptor pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFCosFontDescriptor.class);
if (pdfObject == null) {
pdfObject = new PDFCosFontDescriptor(cosObject);
}
return pdfObject;
}
public static PDFCosFontDescriptor newInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosDictionary cosDictionary = PDFCosObject.newCosDictionary(pdfDocument);
return new PDFCosFontDescriptor((CosObject)cosDictionary);
}
ASName getFontName() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryNameValue(ASName.k_FontName);
}
void setFontName(ASName fontName) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryNameValue(ASName.k_FontName, fontName);
}
void setType(ASName fontName) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryNameValue(ASName.k_Type, fontName);
}
ASString getFontFamily() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryStringValue(ASName.k_FontFamily);
}
PDFFontStretch getFontStretch() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
ASName fontStretch = this.getDictionaryNameValue(ASName.k_FontStretch);
if (fontStretch == null) {
return null;
}
try {
return PDFFontStretch.newInstance(fontStretch);
}
catch (PDFInvalidParameterException e) {
throw new PDFInvalidDocumentException("Invalid value for font stretch.", (Throwable)e);
}
}
int getFontWeight() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
int kNormalWeight = 400;
if (this.containsKey(ASName.k_FontWeight)) {
return this.getDictionaryIntValue(ASName.k_FontWeight);
}
return kNormalWeight;
}
int getFlags() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryIntValue(ASName.k_Flags);
}
void setFlags(int flags) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryIntValue(ASName.k_Flags, flags);
}
boolean containsFontBBox() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.containsKey(ASName.k_FontBBox);
}
PDFRectangle getFontBBox() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFRectangle.getInstance(this.getDictionaryValue(ASName.k_FontBBox));
}
void setFontBBox(PDFRectangle fontBBox) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryValue(ASName.k_FontBBox, fontBBox.getCosObject());
}
double getItalicAngle() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryDoubleValue(ASName.k_ItalicAngle);
}
void setItalicAngle(double angle) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryDoubleValue(ASName.k_ItalicAngle, angle);
}
boolean containsAscent() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.containsKey(ASName.k_Ascent);
}
public double getAscent() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.containsAscent()) {
return this.getDictionaryDoubleValue(ASName.k_Ascent);
}
return 0.0;
}
void setAscent(double ascent) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryDoubleValue(ASName.k_Ascent, ascent);
}
boolean containsDescent() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.containsKey(ASName.k_Descent);
}
public double getDescent() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.containsDescent()) {
return this.getDictionaryDoubleValue(ASName.k_Descent);
}
return 0.0;
}
void setDescent(double descent) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryDoubleValue(ASName.k_Descent, descent);
}
double getLeading() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.containsKey(ASName.k_Leading)) {
return this.getDictionaryDoubleValue(ASName.k_Leading);
}
return 0.0;
}
boolean containsCapHeight() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.containsKey(ASName.k_CapHeight);
}
public double getCapHeight() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.containsCapHeight()) {
return this.getDictionaryDoubleValue(ASName.k_CapHeight);
}
return 0.0;
}
void setCapHeight(double capHight) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryDoubleValue(ASName.k_CapHeight, capHight);
}
double getXHeight() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.containsKey(ASName.k_XHeight)) {
return this.getDictionaryDoubleValue(ASName.k_XHeight);
}
return 0.0;
}
void setXHeight(double xHeight) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryDoubleValue(ASName.k_XHeight, xHeight);
}
boolean containsStemV() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.containsKey(ASName.k_StemV);
}
double getStemV() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.containsStemV()) {
return this.getDictionaryDoubleValue(ASName.k_StemV);
}
return 0.0;
}
void setStemV(double stemV) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryDoubleValue(ASName.k_StemV, stemV);
}
double getStemH() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.containsKey(ASName.k_StemH)) {
return this.getDictionaryDoubleValue(ASName.k_StemH);
}
return 0.0;
}
double getAvgWidth() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.containsKey(ASName.k_AvgWidth)) {
return this.getDictionaryDoubleValue(ASName.k_AvgWidth);
}
return 0.0;
}
double getMaxWidth() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.containsKey(ASName.k_MaxWidth)) {
return this.getDictionaryDoubleValue(ASName.k_MaxWidth);
}
return 0.0;
}
public double getMissingWidth() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.containsKey(ASName.k_MissingWidth)) {
return this.getDictionaryDoubleValue(ASName.k_MissingWidth);
}
return 0.0;
}
boolean containsEmbeddedFont() {
CosDictionary dict = this.getCosDictionary();
return dict.containsKey((Object)ASName.k_FontFile) || dict.containsKey((Object)ASName.k_FontFile2) || dict.containsKey((Object)ASName.k_FontFile3);
}
PDFFontFile getFontFile() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject cosObject = this.getDictionaryValue(ASName.k_FontFile);
if (cosObject != null) {
return PDFFontFile.getInstance(cosObject);
}
return null;
}
void setFontFile(PDFFontFile fontFile) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryValue(ASName.k_FontFile, fontFile);
}
PDFFontFile getFontFile2() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFFontFile.getInstance(this.getDictionaryValue(ASName.k_FontFile2));
}
void setFontFile2(PDFFontFile fontFile) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryValue(ASName.k_FontFile2, fontFile);
}
PDFFontFile getFontFile3() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFFontFile.getInstance(this.getDictionaryValue(ASName.k_FontFile3));
}
void setFontFile3(PDFFontFile fontFile) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryValue(ASName.k_FontFile3, fontFile);
}
ASString getCharSet() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryStringValue(ASName.k_CharSet);
}
PDFCIDFontStyle getStyle() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFCIDFontStyle.getInstance(this.getDictionaryValue(ASName.k_Style));
}
public ASName getLang() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryNameValue(ASName.k_Lang);
}
List<ASName> getFDKeys() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryDictionaryValue(ASName.k_FD).getKeys();
}
PDFFontDescriptor getFD(ASName name) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosDictionary fdDict = this.getDictionaryDictionaryValue(ASName.k_FD);
if (fdDict != null) {
return PDFFontDescriptor.getInstance(fdDict.get(name));
}
return null;
}
InputByteStream getCIDSet() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryStreamValue(ASName.k_CIDSet);
}
}