FallbackFontSet.java
7.49 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.agl.util.ULocale
*/
package com.adobe.fontengine.inlineformatting;
import com.adobe.agl.util.ULocale;
import com.adobe.fontengine.font.Font;
import com.adobe.fontengine.font.FontException;
import com.adobe.fontengine.fontmanagement.postscript.PostscriptFontDescription;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.TreeMap;
public final class FallbackFontSet
implements Serializable {
static final long serialVersionUID = 1;
private final HashMap fonts = new HashMap();
private static final ULocale REAL_ROOT = new ULocale("");
public FallbackFontSet() {
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public FallbackFontSet(FallbackFontSet ffs) {
FallbackFontSet fallbackFontSet = ffs;
synchronized (fallbackFontSet) {
for (Object locale : ffs.fonts.keySet()) {
ArrayList l = new ArrayList();
this.fonts.put(locale, l);
Iterator it2 = ((List)ffs.fonts.get(locale)).iterator();
while (it2.hasNext()) {
l.add(it2.next());
}
}
}
}
public void addFallbackFonts(ULocale locale, Font[] fontsToAdd) {
for (Font font : fontsToAdd) {
this.addFallbackFont(locale, font);
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public void addFallbackFont(ULocale locale, Font font) {
FallbackFontSet fallbackFontSet = this;
synchronized (fallbackFontSet) {
ArrayList<Font> l;
if (locale.equals((Object)ULocale.ROOT)) {
locale = REAL_ROOT;
}
if ((l = (ArrayList<Font>)this.fonts.get((Object)locale)) == null) {
l = new ArrayList<Font>();
this.fonts.put(locale, l);
}
l.add(font);
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public Iterator getFallbackFonts(ULocale locale) {
FallbackFontSet fallbackFontSet = this;
synchronized (fallbackFontSet) {
return new FallbackFontIterator(locale);
}
}
public boolean equals(Object otherObject) {
if (otherObject == this) {
return true;
}
if (otherObject == null || !(otherObject instanceof FallbackFontSet)) {
return false;
}
return this.fonts.equals(((FallbackFontSet)otherObject).fonts);
}
public int hashCode() {
return this.fonts.hashCode();
}
public boolean isEmpty() {
return this.fonts.isEmpty();
}
public boolean isEmpty(ULocale locale) {
return this.fonts.containsKey((Object)locale);
}
public String toString() {
TreeMap tempMap3;
TreeMap<String, ULocale> tempMap = new TreeMap<String, ULocale>();
for (ULocale locale : this.fonts.keySet()) {
tempMap.put(locale.getDisplayName(), locale);
}
HashMap tempMap1 = new HashMap();
for (String displayName : tempMap.keySet()) {
ULocale locale2 = (ULocale)tempMap.get(displayName);
TreeMap<String, TreeMap> tempMap2 = new TreeMap<String, TreeMap>();
for (Font f : (List)this.fonts.get((Object)locale2)) {
String tempKey;
tempMap3 = new TreeMap();
try {
PostscriptFontDescription[] descs = f.getPostscriptFontDescription();
for (int i = 0; i < descs.length; ++i) {
String name = descs[i].toString();
int count = 0;
if (tempMap3.containsKey(name)) {
count = (Integer)tempMap3.get(name);
}
tempMap3.put(name, new Integer(++count));
}
}
catch (FontException e) {
// empty catch block
}
char suffix = '0';
String string = tempKey = tempMap3.isEmpty() ? "" : (String)tempMap3.firstKey();
while (tempMap2.containsKey(tempKey + suffix)) {
suffix = (char)(suffix + '\u0001');
}
tempMap2.put(tempKey + suffix, tempMap3);
}
tempMap1.put(locale2, tempMap2);
}
StringBuffer sb = new StringBuffer();
for (String displayName2 : tempMap.keySet()) {
ULocale locale3 = (ULocale)tempMap.get(displayName2);
sb.append(displayName2);
sb.append(": ");
String prefix2 = "";
TreeMap tempMap2 = (TreeMap)tempMap1.get((Object)locale3);
Iterator it1 = tempMap2.keySet().iterator();
while (it1.hasNext()) {
tempMap3 = (TreeMap)tempMap2.get(it1.next());
sb.append(prefix2);
sb.append("{");
String prefix = "";
for (String name : tempMap3.keySet()) {
int count = (Integer)tempMap3.get(name);
while (count-- > 0) {
sb.append(prefix);
sb.append(name);
prefix = ", ";
}
}
sb.append("}");
sb.append(prefix2);
prefix2 = ", ";
}
sb.append("\n");
}
return sb.toString();
}
private final class FallbackFontIterator
implements Iterator {
private ULocale locale;
private Iterator localeIt;
public FallbackFontIterator(ULocale locale) {
this.locale = locale;
this.localeIt = null;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public boolean hasNext() {
FallbackFontIterator fallbackFontIterator = this;
synchronized (fallbackFontIterator) {
while (this.localeIt != null || this.locale != null) {
if (this.localeIt == null) {
List l = (List)FallbackFontSet.this.fonts.get((Object)this.locale);
if (l != null) {
this.localeIt = l.iterator();
}
this.locale = this.locale.getFallback();
continue;
}
if (this.localeIt.hasNext()) {
return true;
}
this.localeIt = null;
}
}
return false;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public Object next() throws NoSuchElementException {
FallbackFontIterator fallbackFontIterator = this;
synchronized (fallbackFontIterator) {
if (this.hasNext()) {
return this.localeIt.next();
}
}
throw new NoSuchElementException();
}
public void remove() throws UnsupportedOperationException {
throw new UnsupportedOperationException("cannot remove elements from a FallbackFontIterator");
}
}
}