IppFont.java
8.38 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
* Decompiled with CFR 0_118.
*/
package com.scene7.is.ipp.messages;
import com.scene7.is.ipp.messages.Ipp;
import com.scene7.is.ipp.messages.IppBool;
import com.scene7.is.ipp.messages.IppInt;
import com.scene7.is.ipp.messages.IppLongString;
import com.scene7.is.ipp.messages.Offset;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
public class IppFont {
private String name_;
private String postscriptName_;
private String file_;
private String metricsFile_;
private String customKerningFile_;
private boolean bold_;
private boolean italic_;
public IppFont(String name, String postscriptName, String file, String metricsFile, String customKerningFile, boolean bold, boolean italic) {
this.name_ = name;
this.postscriptName_ = postscriptName;
this.file_ = file;
this.metricsFile_ = metricsFile;
this.customKerningFile_ = customKerningFile;
this.bold_ = bold;
this.italic_ = italic;
}
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[");
buffer.append("name: ").append(String.valueOf(this.name_)).append(" ");
buffer.append("postscriptName: ").append(String.valueOf(this.postscriptName_)).append(" ");
buffer.append("file: ").append(String.valueOf(this.file_)).append(" ");
buffer.append("metricsFile: ").append(String.valueOf(this.metricsFile_)).append(" ");
buffer.append("customKerningFile: ").append(String.valueOf(this.customKerningFile_)).append(" ");
buffer.append("bold: ").append(String.valueOf(this.bold_)).append(" ");
buffer.append("italic: ").append(String.valueOf(this.italic_)).append(" ");
buffer.append("]");
return buffer.toString();
}
public boolean equals(Object o) {
if (!(o instanceof IppFont)) {
return false;
}
IppFont e = (IppFont)o;
if (!this.name_.equals(e.name_)) {
return false;
}
if (!this.postscriptName_.equals(e.postscriptName_)) {
return false;
}
if (!this.file_.equals(e.file_)) {
return false;
}
if (!this.metricsFile_.equals(e.metricsFile_)) {
return false;
}
if (!this.customKerningFile_.equals(e.customKerningFile_)) {
return false;
}
if (this.bold_ != e.bold_) {
return false;
}
if (this.italic_ != e.italic_) {
return false;
}
return true;
}
public static IppFont Unstuff(byte[] arr, Offset arrayPos) {
Ipp.Assert((arrayPos.val & 3) == 0, "IppFont align");
String name = IppLongString.Unstuff(arr, arrayPos);
String postscriptName = IppLongString.Unstuff(arr, arrayPos);
String file = IppLongString.Unstuff(arr, arrayPos);
String metricsFile = IppLongString.Unstuff(arr, arrayPos);
String customKerningFile = IppLongString.Unstuff(arr, arrayPos);
boolean bold = IppBool.Unstuff(arr, arrayPos);
boolean italic = IppBool.Unstuff(arr, arrayPos);
return new IppFont(name, postscriptName, file, metricsFile, customKerningFile, bold, italic);
}
public static IppFont[] UnstuffArray(byte[] arr, Offset arrayPos) {
Ipp.Assert((arrayPos.val & 3) == 0, "IppFont alignemt");
int count = IppInt.Unstuff(arr, arrayPos);
int size = IppInt.Unstuff(arr, arrayPos);
Ipp.Assert(count == 0 || size >= 28, "IppFont count");
Offset roff = new Offset(IppInt.Unstuff(arr, arrayPos));
Offset loff = new Offset(roff.val);
IppFont[] result = new IppFont[count];
for (int i = 0; i < count; ++i) {
loff.val = roff.val;
result[i] = IppFont.Unstuff(arr, loff);
roff.val += size;
}
return result;
}
public static IppFont[] UnstuffFixedArray(byte[] arr, Offset arrayPos, int count) {
IppFont[] result = new IppFont[count];
for (int i = 0; i < count; ++i) {
result[i] = IppFont.Unstuff(arr, arrayPos);
}
return result;
}
public static void Stuff(byte[] arr, Offset arrayPos, Offset varPos, IppFont val) {
Ipp.Assert((arrayPos.val & 3) == 0, "IppFont align");
if (val != null) {
IppLongString.Stuff(arr, arrayPos, varPos, val.name());
IppLongString.Stuff(arr, arrayPos, varPos, val.postscriptName());
IppLongString.Stuff(arr, arrayPos, varPos, val.file());
IppLongString.Stuff(arr, arrayPos, varPos, val.metricsFile());
IppLongString.Stuff(arr, arrayPos, varPos, val.customKerningFile());
IppBool.Stuff(arr, arrayPos, varPos, val.bold());
IppBool.Stuff(arr, arrayPos, varPos, val.italic());
} else {
Ipp.StuffNullBytes(arr, arrayPos, 28);
}
}
public static void StuffArray(byte[] arr, Offset arrayPos, Offset varPos, IppFont[] val) {
Ipp.Assert((arrayPos.val & 3) == 0, "IppFont stuffarray align");
int len = val != null ? val.length : 0;
IppInt.Stuff(arr, arrayPos, varPos, len);
IppInt.Stuff(arr, arrayPos, varPos, 28);
Ipp.StuffOffset(arr, arrayPos, varPos, len > 0 ? 4 : 1);
Offset varvarPos = new Offset(varPos.val + 28 * len);
for (int i = 0; i < len; ++i) {
IppFont.Stuff(arr, varPos, varvarPos, val[i]);
}
varPos.val = varvarPos.val;
}
public static void StuffFixedArray(byte[] arr, Offset arrayPos, Offset varPos, int count, IppFont[] val) {
Ipp.Assert(val.length == count, "IppFont count");
for (int i = 0; i < count; ++i) {
IppFont.Stuff(arr, arrayPos, varPos, val[i]);
}
}
public static void Print(Writer tf, String label, IppFont it) throws IOException {
String ll = label + "IppFont: ";
if (it == null) {
tf.write(ll + "NULL!!\n");
return;
}
tf.write(ll + "\n");
IppLongString.Print(tf, ll + "name: ", it.name());
IppLongString.Print(tf, ll + "postscriptName: ", it.postscriptName());
IppLongString.Print(tf, ll + "file: ", it.file());
IppLongString.Print(tf, ll + "metricsFile: ", it.metricsFile());
IppLongString.Print(tf, ll + "customKerningFile: ", it.customKerningFile());
IppBool.Print(tf, ll + "bold: ", it.bold());
IppBool.Print(tf, ll + "italic: ", it.italic());
}
public static void PrintArray(Writer tf, String label, IppFont[] it) throws IOException {
String ll = label + "IppFont Array, length: ";
tf.write(ll);
if (it == null) {
tf.write("NULL!!!\n");
return;
}
tf.write("" + it.length + "\n");
for (int i = 0; i < it.length; ++i) {
ll = label + "IppFont[" + String.valueOf(i) + "]: ";
IppFont.Print(tf, ll, it[i]);
}
}
public void adjustVarPos(Offset varPos) {
try {
varPos.val += this.name_.getBytes("UTF-8").length + 1;
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
try {
varPos.val += this.postscriptName_.getBytes("UTF-8").length + 1;
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
try {
varPos.val += this.file_.getBytes("UTF-8").length + 1;
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
try {
varPos.val += this.metricsFile_.getBytes("UTF-8").length + 1;
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
try {
varPos.val += this.customKerningFile_.getBytes("UTF-8").length + 1;
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
}
public String name() {
return this.name_;
}
public String postscriptName() {
return this.postscriptName_;
}
public String file() {
return this.file_;
}
public String metricsFile() {
return this.metricsFile_;
}
public String customKerningFile() {
return this.customKerningFile_;
}
public boolean bold() {
return this.bold_;
}
public boolean italic() {
return this.italic_;
}
}