IntelligentResolver.java
1.85 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.fontengine.fontmanagement;
import com.adobe.fontengine.font.Font;
import com.adobe.fontengine.font.FontImpl;
import com.adobe.fontengine.font.FontLoadingException;
import com.adobe.fontengine.font.InvalidFontException;
import com.adobe.fontengine.font.UnsupportedFontException;
import com.adobe.fontengine.fontmanagement.CacheSupportInfo;
import com.adobe.fontengine.fontmanagement.URLFont;
public final class IntelligentResolver {
public static Font choosePreferredFont(Font f1, Font f2, boolean preferFirst) throws UnsupportedFontException, InvalidFontException, FontLoadingException {
String f2FontType;
CacheSupportInfo f1Desc = ((FontImpl)f1).getCacheSupportInfo();
CacheSupportInfo f2Desc = ((FontImpl)f2).getCacheSupportInfo();
String f1FontType = f1Desc.getFontType();
if (!f1FontType.equals(f2FontType = f2Desc.getFontType())) {
if (f1FontType.equals("OpenTypeFont")) {
return f1;
}
if (f2FontType.equals("OpenTypeFont")) {
return f2;
}
if (f1FontType.equals("Type1Font")) {
return f1;
}
return f2;
}
if (f1FontType.equals("OpenTypeFont")) {
if (f1Desc.isCFF() && !f2Desc.isCFF()) {
return f1;
}
if (!f1Desc.isCFF() && f2Desc.isCFF()) {
return f2;
}
}
if (f1Desc.getNumGlyphs() > f2Desc.getNumGlyphs()) {
return f1;
}
if (f1Desc.getNumGlyphs() < f2Desc.getNumGlyphs()) {
return f2;
}
if (f1.getClass() != f2.getClass()) {
if (f1 instanceof URLFont) {
return f1;
}
return f2;
}
return preferFirst ? f1 : f2;
}
}