PostscriptTokenParser.java
1.7 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.fontengine.font.postscript;
import com.adobe.fontengine.font.OrigFontType;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class PostscriptTokenParser {
private static final Pattern origFontTypePattern = Pattern.compile("/OrigFontType\\s*/((?:" + OrigFontType.kTYPE1.toString() + ")|(?:" + OrigFontType.kTRUETYPE.toString() + ")|(?:" + OrigFontType.kOCF.toString() + ")|(?:" + OrigFontType.kCID.toString() + "))(\\s+def)", 0);
private static final Pattern fsTypePattern = Pattern.compile("/FSType\\s*(-?\\d+)(\\s+def)", 0);
public static Integer getFSType(String v) {
Matcher m;
if (v != null && (m = fsTypePattern.matcher(v)).find()) {
int startPos = m.start(1);
int endPos = m.start(2);
return new Integer(Integer.parseInt(v.substring(startPos, endPos)));
}
return null;
}
public static OrigFontType getOrigFontType(String v) {
Matcher m;
if (v != null && (m = origFontTypePattern.matcher(v)).find()) {
int endPos;
int startPos = m.start(1);
String s = v.substring(startPos, endPos = m.start(2));
if (s.equals(OrigFontType.kTYPE1.toString())) {
return OrigFontType.kTYPE1;
}
if (s.equals(OrigFontType.kTRUETYPE.toString())) {
return OrigFontType.kTRUETYPE;
}
if (s.equals(OrigFontType.kCID.toString())) {
return OrigFontType.kCID;
}
if (s.equals(OrigFontType.kOCF.toString())) {
return OrigFontType.kOCF;
}
}
return null;
}
}