54
54
import java .util .Set ;
55
55
56
56
/**
57
- *
57
+ *
58
58
* @author <a href="mailto:[email protected] ">Palash Ray</a>
59
59
*/
60
60
public abstract class OpenTypeFontTableReader implements Serializable {
61
61
62
62
private static final long serialVersionUID = 4826484598227913292L ;
63
63
protected final RandomAccessFileOrArray rf ;
64
64
protected final int tableLocation ;
65
-
65
+
66
66
protected List <OpenTableLookup > lookupList ;
67
67
protected OpenTypeScript scriptsType ;
68
68
protected OpenTypeFeature featuresType ;
@@ -79,11 +79,11 @@ protected OpenTypeFontTableReader(RandomAccessFileOrArray rf, int tableLocation,
79
79
this .gdef = gdef ;
80
80
this .unitsPerEm = unitsPerEm ;
81
81
}
82
-
82
+
83
83
public Glyph getGlyph (int index ) {
84
84
return indexGlyphMap .get (index );
85
85
}
86
-
86
+
87
87
public OpenTableLookup getLookupTable (int idx ) {
88
88
if (idx < 0 || idx >= lookupList .size ()) {
89
89
return null ;
@@ -94,11 +94,11 @@ public OpenTableLookup getLookupTable(int idx) {
94
94
public List <ScriptRecord > getScriptRecords () {
95
95
return scriptsType .getScriptRecords ();
96
96
}
97
-
97
+
98
98
public List <FeatureRecord > getFeatureRecords () {
99
99
return featuresType .getRecords ();
100
100
}
101
-
101
+
102
102
public List <FeatureRecord > getFeatures (String [] scripts , String language ) {
103
103
LanguageRecord rec = scriptsType .getLanguageRecord (scripts , language );
104
104
if (rec == null ) {
@@ -110,7 +110,7 @@ public List<FeatureRecord> getFeatures(String[] scripts, String language) {
110
110
}
111
111
return ret ;
112
112
}
113
-
113
+
114
114
public List <FeatureRecord > getSpecificFeatures (List <FeatureRecord > features , String [] specific ) {
115
115
if (specific == null ) {
116
116
return features ;
@@ -128,14 +128,14 @@ public List<FeatureRecord> getSpecificFeatures(List<FeatureRecord> features, Str
128
128
}
129
129
return recs ;
130
130
}
131
-
131
+
132
132
public FeatureRecord getRequiredFeature (String [] scripts , String language ) {
133
133
LanguageRecord rec = scriptsType .getLanguageRecord (scripts , language );
134
134
if (rec == null )
135
135
return null ;
136
136
return featuresType .getRecord (rec .featureRequired );
137
137
}
138
-
138
+
139
139
public List <OpenTableLookup > getLookups (FeatureRecord [] features ) {
140
140
IntHashtable hash = new IntHashtable ();
141
141
for (FeatureRecord rec : features ) {
@@ -158,7 +158,7 @@ public List<OpenTableLookup> getLookups(FeatureRecord feature) {
158
158
}
159
159
return ret ;
160
160
}
161
-
161
+
162
162
public boolean isSkip (int glyph , int flag ) {
163
163
return gdef .isSkip (glyph , flag );
164
164
}
@@ -183,18 +183,18 @@ public LanguageRecord getLanguageRecord(String otfScriptTag) {
183
183
}
184
184
return languageRecord ;
185
185
}
186
-
186
+
187
187
protected abstract OpenTableLookup readLookupTable (int lookupType , int lookupFlag , int [] subTableLocations )
188
188
throws java .io .IOException ;
189
189
190
190
protected final OtfClass readClassDefinition (int classLocation ) throws java .io .IOException {
191
191
return OtfClass .create (rf , classLocation );
192
192
}
193
-
193
+
194
194
protected final int [] readUShortArray (int size , int location ) throws java .io .IOException {
195
195
return OtfReadCommon .readUShortArray (rf , size , location );
196
196
}
197
-
197
+
198
198
protected final int [] readUShortArray (int size ) throws java .io .IOException {
199
199
return OtfReadCommon .readUShortArray (rf , size );
200
200
}
@@ -255,6 +255,9 @@ private void readLookupListTable(int lookupListTableLocation) throws java.io.IOE
255
255
int [] lookupTableLocations = readUShortArray (lookupCount , lookupListTableLocation );
256
256
// read LookUp tables
257
257
for (int lookupLocation : lookupTableLocations ) {
258
+ if (lookupLocation == 0 ) { // be tolerant to NULL offset in LookupList table
259
+ continue ;
260
+ }
258
261
readLookupTable (lookupLocation );
259
262
}
260
263
}
0 commit comments