sfntResourceHandler.java
3.29 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* 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.fontengine.font.Font;
import com.adobe.fontengine.font.FontLoadingException;
import com.adobe.fontengine.fontmanagement.FontLoader;
import com.adobe.internal.mac.resource.BasicResourceHandler;
import com.adobe.internal.mac.resource.ResourceParser;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class sfntResourceHandler
extends BasicResourceHandler {
private static final byte[] sfnt = new byte[]{115, 102, 110, 116};
FontLoader loader = new FontLoader();
Map<Integer, SfntResource> resources = new HashMap<Integer, SfntResource>();
int idToCreate = -1;
boolean createAllFonts = true;
public sfntResourceHandler() {
super(sfnt);
}
public sfntResourceHandler(int idToCreate) {
this();
this.idToCreate = idToCreate;
this.createAllFonts = false;
}
public void handleResource(ResourceParser.ResourceEntry entry, long length, InputStream stream) {
if (this.createAllFonts || this.idToCreate == entry.getID()) {
SfntResource resource = new SfntResource(entry.getID(), entry.getName(), entry.getScriptCode(), length);
Font font = null;
try {
font = this.loader.load(stream, (int)length, false);
}
catch (FontLoadingException e) {
resource.setException(e);
}
resource.setFont(font);
this.resources.put(new Integer(entry.getID()), resource);
}
}
public Map<Integer, SfntResource> getResources() {
return this.resources;
}
public static class SfntResource {
private String name;
private int script;
private long size;
private int id;
private Font font;
private Exception exception;
private SfntResource(int id, String name, int script, long size) {
this.size = size;
this.id = id;
this.name = name;
this.script = script;
}
public long getSize() {
return this.size;
}
public int getID() {
return this.id;
}
public String getName() {
return this.name;
}
public int getScriptCode() {
return this.script;
}
void setFont(Font font) {
this.font = font;
}
public Font getFont() {
return this.font;
}
void setException(Exception e) {
this.exception = e;
}
public Exception getException() {
return this.exception;
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("fontID = " + this.id);
sb.append(", name = " + this.name);
sb.append(", size = " + this.size);
sb.append(", font = " + this.font);
return sb.toString();
}
}
}