FontSet.java
3.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.fontengine.font.cff;
import com.adobe.fontengine.font.FontByteArray;
import com.adobe.fontengine.font.InvalidFontException;
import com.adobe.fontengine.font.UnsupportedFontException;
import com.adobe.fontengine.font.cff.CFFByteArray;
import com.adobe.fontengine.font.cff.CFFFont;
import com.adobe.fontengine.font.cff.CIDKeyedFont;
import com.adobe.fontengine.font.cff.CharStrings;
import com.adobe.fontengine.font.cff.Dict;
import com.adobe.fontengine.font.cff.Header;
import com.adobe.fontengine.font.cff.Index;
import com.adobe.fontengine.font.cff.NameIndex;
import com.adobe.fontengine.font.cff.NameKeyedFont;
import com.adobe.fontengine.font.cff.StringIndex;
import com.adobe.fontengine.font.cff.SyntheticFont;
import java.io.IOException;
final class FontSet {
protected final CFFByteArray data;
protected final Header header;
protected final NameIndex nameIndex;
protected final Index topDictIndex;
protected final StringIndex stringIndex;
protected final CharStrings globalSubrs;
public final CFFFont[] fonts;
public FontSet(FontByteArray buffer) throws IOException, InvalidFontException, UnsupportedFontException {
int i;
this.data = new CFFByteArray(buffer);
if (buffer.getSize() < 4) {
throw new InvalidFontException("CFFFontSet too small");
}
int offset = 0;
this.header = new Header(this.data, offset);
offset += this.header.size();
int majorVersion = this.header.getMajorVersion();
if (majorVersion != 1) {
throw new UnsupportedFontException("CFFFontSet major version " + majorVersion + " not supported");
}
this.nameIndex = new NameIndex(this.data, offset);
this.topDictIndex = new Index(this.data, offset += this.nameIndex.size());
this.stringIndex = new StringIndex(this.data, offset += this.topDictIndex.size());
this.globalSubrs = new CharStrings(this.data, offset += this.stringIndex.size());
this.fonts = new CFFFont[this.nameIndex.getCount()];
Dict[] syntheticTopDicts = new Dict[this.nameIndex.getCount()];
int[] syntheticBases = new int[this.nameIndex.getCount()];
for (i = 0; i < this.fonts.length; ++i) {
String name = this.nameIndex.getNthName(i);
if (name.length() != 0 && name.charAt(0) == '\u0000') continue;
Dict topDict = new Dict(this.data, this.topDictIndex.offsetOf(i), this.topDictIndex.sizeOf(i), this.stringIndex);
Dict.ROSValue rosOp = topDict.get(Dict.Key.ROS, false);
if (rosOp != null) {
this.fonts[i] = new CIDKeyedFont(this.stringIndex, this.globalSubrs, name, topDict, this.data, null);
continue;
}
Dict.IntegerValue syntheticBaseOp = topDict.get(Dict.Key.SyntheticBase, false);
if (syntheticBaseOp != null) {
syntheticTopDicts[i] = topDict;
syntheticBases[i] = syntheticBaseOp.value;
continue;
}
this.fonts[i] = new NameKeyedFont(this.stringIndex, this.globalSubrs, name, topDict, this.data, null);
}
for (i = 0; i < this.fonts.length; ++i) {
if (syntheticTopDicts[i] == null) continue;
this.fonts[i] = new SyntheticFont(this.stringIndex, this.fonts[syntheticBases[i]], this.nameIndex.getNthName(i), syntheticTopDicts[i], this.data, null);
}
}
}