CharUtil.java
2.24 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.agl.lang.UCharacter
*/
package com.adobe.fontengine;
import com.adobe.agl.lang.UCharacter;
import com.adobe.fontengine.CombiningSequence;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
public final class CharUtil {
private static final CombiningSequence emptySequence;
public static int compose(int[] usvs, int start, int limit) {
return emptySequence.compose(usvs, start, limit);
}
public static int[] mapStringFrom(int[] usvs, int start, int limit) {
int c = CharUtil.composeHangulSyllable(usvs, start, limit);
if (c != -1) {
return new int[]{c};
}
return emptySequence.map(usvs, start, limit);
}
public static int composeHangulSyllable(int[] usvs, int start, int limit) {
if (start + 2 <= limit && 4352 <= usvs[start] && usvs[start] <= 4371 && 4449 <= usvs[start + 1] && usvs[start + 1] <= 4470 && (limit == start + 3 && 4519 <= usvs[start + 2] && usvs[start + 2] <= 4547 || limit == start + 2)) {
int s = ((usvs[start] - 4352) * 21 + (usvs[start + 1] - 4449)) * 28 + 44032;
if (limit == start + 3) {
s += usvs[start + 2] - 4519;
}
return s;
}
return -1;
}
public static boolean isBase(int ch) {
return UCharacter.isBaseForm((int)ch);
}
public static boolean isCombining(int ch) {
int gc = UCharacter.getType((int)ch);
return gc == 8 || gc == 6 || gc == 7;
}
public static boolean isControl(int ch) {
int gc = UCharacter.getType((int)ch);
return gc == 16 || gc == 15;
}
static {
try {
InputStream is = CombiningSequence.class.getResourceAsStream("composer");
ObjectInputStream ois = new ObjectInputStream(is);
emptySequence = (CombiningSequence)ois.readObject();
ois.close();
}
catch (IOException e) {
throw new RuntimeException("cannot load AFE Composer resources", e);
}
catch (ClassNotFoundException e) {
throw new RuntimeException("cannot load AFE Composer resources", e);
}
}
}