Index.java
2.47 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.fontengine.font.cff;
import com.adobe.fontengine.font.InvalidFontException;
import com.adobe.fontengine.font.UnsupportedFontException;
import com.adobe.fontengine.font.cff.CFFByteArray;
class Index {
public final CFFByteArray data;
public final int offset;
protected final int size;
protected final int entryCount;
protected final int[] entryOffsets;
Index(CFFByteArray data, int offset) throws InvalidFontException, UnsupportedFontException {
this.data = data;
this.offset = offset;
this.entryCount = data.getcard16(offset + 0);
this.entryOffsets = new int[this.entryCount + 1];
if (this.entryCount == 0) {
this.size = 2;
return;
}
int offSize = data.getOffSize(offset + 2);
int firstDataByteOffset = offset + 3 + offSize * (this.entryCount + 1);
for (int i = 0; i < this.entryCount + 1; ++i) {
this.entryOffsets[i] = firstDataByteOffset + data.getOffset(offset + 3 + offSize * i, offSize, "INDEX offset too big") - 1;
}
this.size = this.entryOffsets[this.entryCount] - offset;
}
public int size() {
return this.size;
}
public int getCount() {
return this.entryCount;
}
public int offsetOf(int entry) {
return this.entryOffsets[entry];
}
public int offsetFollowing(int entry) {
return this.entryOffsets[entry + 1];
}
public int sizeOf(int entry) {
return this.entryOffsets[entry + 1] - this.entryOffsets[entry];
}
public void stream(CFFByteArray.CFFByteArrayBuilder bb) throws InvalidFontException {
bb.addBytes(this.data, this.offset, this.size);
}
public static Cursor startIndex(CFFByteArray.CFFByteArrayBuilder bb, int n) {
if (n == 0) {
bb.addCard16(0);
return null;
}
bb.addCard16(n);
bb.addCard8(4);
bb.addCard32(1);
Cursor cursor = new Cursor();
cursor.offset = bb.getSize();
for (int i = 0; i < n; ++i) {
bb.addCard32(1);
}
cursor.base = bb.getSize() - 1;
return cursor;
}
public static Cursor elementEntered(CFFByteArray.CFFByteArrayBuilder bb, Cursor cursor) {
bb.setCard32(cursor.offset, bb.getSize() - cursor.base);
cursor.offset += 4;
return cursor;
}
public static class Cursor {
int base;
int offset;
}
}