ResourceFontData.java
3.15 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.agl.util.ULocale
*/
package com.adobe.fontengine.font.mac;
import com.adobe.agl.util.ULocale;
import com.adobe.fontengine.font.FontData;
import com.adobe.fontengine.font.InvalidFontException;
import com.adobe.fontengine.font.UnsupportedFontException;
import com.adobe.fontengine.font.WrapperFontData;
import com.adobe.fontengine.fontmanagement.Platform;
import com.adobe.fontengine.fontmanagement.fxg.FXGFontDescription;
import com.adobe.fontengine.fontmanagement.platform.PlatformFontDescription;
public class ResourceFontData
extends WrapperFontData {
private String rsrcFontName;
private String sfntName;
private ULocale locale;
private boolean isBold;
private boolean isItalic;
public ResourceFontData(FontData fontData, ULocale locale, String fontName, String sfntName, boolean isBold, boolean isItalic) {
super(fontData);
this.locale = locale;
this.rsrcFontName = fontName;
this.sfntName = sfntName;
this.isBold = isBold;
this.isItalic = isItalic;
}
public FXGFontDescription[] getFXGFontDescription(Platform platform, ULocale locale) throws InvalidFontException, UnsupportedFontException {
if ((platform == Platform.MAC_OSX || platform == null) && this.locale != null && this.rsrcFontName != null && ResourceFontData.isContainedWithin(this.locale, locale)) {
FXGFontDescription[] fxgDesc = new FXGFontDescription[]{new FXGFontDescription(Platform.MAC_OSX, this.locale, this.rsrcFontName, this.isBold, this.isItalic)};
return fxgDesc;
}
return new FXGFontDescription[0];
}
public PlatformFontDescription[] getPlatformFontDescription(Platform platform, ULocale locale) throws InvalidFontException, UnsupportedFontException {
PlatformFontDescription[] platformDesc = this.getFontData().getPlatformFontDescription(platform, locale);
if (platformDesc != null) {
return platformDesc;
}
if ((platform == Platform.MAC_OSX || platform == null) && this.locale != null && this.sfntName != null && ResourceFontData.isContainedWithin(this.locale, locale)) {
platformDesc = new PlatformFontDescription[]{new PlatformFontDescription(Platform.MAC_OSX, this.locale, this.sfntName)};
return platformDesc;
}
return new PlatformFontDescription[0];
}
private static boolean isContainedWithin(ULocale baseLocale, ULocale locale) {
if (locale == null) {
return true;
}
String baseLanguage = baseLocale.getLanguage();
if (baseLanguage != null && !baseLanguage.equals("") && !baseLanguage.equals(locale.getLanguage())) {
return false;
}
String baseCountry = baseLocale.getCountry();
if (baseCountry != null && !baseCountry.equals("") && !baseCountry.equals(locale.getCountry())) {
return false;
}
String baseScript = baseLocale.getScript();
if (baseScript != null && baseScript.equals("") && !baseScript.equals(locale.getScript())) {
return false;
}
return true;
}
}