PDFSimpleFontData.java
2.42 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
*/
package com.adobe.internal.pdftoolkit.pdf.content.processor;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.pdf.content.processor.FontWidthStore;
import com.adobe.internal.pdftoolkit.pdf.graphics.font.PDFFontSimple;
import com.adobe.internal.pdftoolkit.pdf.graphics.font.impl.PDFFontUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
class PDFSimpleFontData {
private Double[] widths = new Double[256];
private Boolean applyHeuristicsToGetSpaceCharWidth;
private Map<Long, int[]> charCodeUnicodeMap = new HashMap<Long, int[]>();
private FontWidthStore fontWidthStore;
PDFSimpleFontData() {
}
double getWidth(int charcode, PDFFontSimple fontSimple) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
Double width = this.widths[charcode];
if (width == null) {
this.widths[charcode] = width = Double.valueOf(PDFFontUtils.getGlyphWidth(false, fontSimple, charcode)[0]);
}
return width;
}
boolean applyHeuristicsToGetSpaceCharWidth(PDFFontSimple fontSimple) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.applyHeuristicsToGetSpaceCharWidth == null) {
this.applyHeuristicsToGetSpaceCharWidth = fontSimple.applyHeuristicsToGetSpaceCharWidth();
}
return this.applyHeuristicsToGetSpaceCharWidth;
}
List getCharCodesFromFont(byte[] bytes, boolean fetchUnicode, PDFFontSimple fontSimple) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (fetchUnicode) {
return fontSimple.getCharCodes(bytes, true, this.charCodeUnicodeMap);
}
return fontSimple.getCharCodes(bytes, false);
}
public FontWidthStore getFontWidthStore() {
return this.fontWidthStore;
}
public void setFontWidthStore(FontWidthStore fontWidthStore) {
this.fontWidthStore = fontWidthStore;
}
}