FONDResourceHandler.java
3.65 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.io.ExtendedDataInputStream
* com.adobe.internal.mac.resource.BasicResourceHandler
* com.adobe.internal.mac.resource.ResourceParser
* com.adobe.internal.mac.resource.ResourceParser$ResourceEntry
*/
package com.adobe.fontengine.font.mac;
import com.adobe.internal.io.ExtendedDataInputStream;
import com.adobe.internal.mac.resource.BasicResourceHandler;
import com.adobe.internal.mac.resource.ResourceParser;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedHashSet;
import java.util.Set;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class FONDResourceHandler
extends BasicResourceHandler {
private static final byte[] FOND = new byte[]{70, 79, 78, 68};
private static final long ASSOCIATION_TABLE_OFFSET = 52;
private Set<Association> associations = new LinkedHashSet<Association>();
public FONDResourceHandler() {
super(FOND);
}
public void handleResource(ResourceParser.ResourceEntry entry, long length, InputStream stream) {
try {
ExtendedDataInputStream dis = new ExtendedDataInputStream(stream);
dis.skipFully(52);
int numberOfAssociations = dis.readUnsignedShort();
for (int associationIndex = 0; associationIndex <= numberOfAssociations; ++associationIndex) {
int size = dis.readUnsignedShort();
int style = dis.readUnsignedShort();
int fontID = dis.readUnsignedShort();
Association association = new Association(entry.getID(), fontID, entry.getName(), entry.getScriptCode(), size, style);
this.associations.add(association);
}
}
catch (IOException e) {
// empty catch block
}
}
public Set<Association> getAssociations() {
return this.associations;
}
public static class Association {
private static final int STYLE_BOLD = 1;
private static final int STYLE_ITALIC = 2;
private String name;
private int size;
private int style;
private int fontID;
private int script;
private int fondID;
private Association(int fondID, int fontID, String name, int script, int size, int style) {
this.fondID = fondID;
this.size = size;
this.style = style;
this.fontID = fontID;
this.name = name;
this.script = script;
}
public int getFondID() {
return this.fondID;
}
public int getSize() {
return this.size;
}
public int getStyle() {
return this.style;
}
public boolean isBold() {
return (this.style & 1) == 1;
}
public boolean isItalic() {
return (this.style & 2) == 2;
}
public int getFontID() {
return this.fontID;
}
public String getName() {
return this.name;
}
public int getScriptCode() {
return this.script;
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("fondID = " + this.fondID);
sb.append("fontID = " + this.fontID);
sb.append(", name = " + this.name);
sb.append(", size = " + this.size);
sb.append(", style = " + this.style);
sb.append(" (bold = " + this.isBold());
sb.append(", italic = " + this.isItalic() + ")");
return sb.toString();
}
}
}