Skip to content

Commit cdb94e8

Browse files
committed
PDFBOX-6146: don't load duplicate content (helps avoiding broken content but also saves space), as suggested by james
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1931302 13f79535-47bb-0310-9956-ffa450edef68
1 parent ac86541 commit cdb94e8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ private Map<String, ScriptTable> readScriptList(TTFDataStream data, long offset)
179179
}
180180
for (int i = 0; i < scriptCount; i++)
181181
{
182+
if (resultScriptList.get(scriptTags[i]) != null)
183+
{
184+
// PDFBOX-6146
185+
continue;
186+
}
182187
ScriptTable scriptTable = readScriptTable(data, offset + scriptOffsets[i]);
183188
resultScriptList.put(scriptTags[i], scriptTable);
184189
}
@@ -315,9 +320,16 @@ else if (offset + lookups[i] > data.getOriginalDataSize())
315320
}
316321
}
317322
LookupTable[] lookupTables = new LookupTable[lookupCount];
323+
Map<Integer, LookupTable> lookupTableMap = new HashMap<>(); // PDFBOX-6146
318324
for (int i = 0; i < lookupCount; i++)
319325
{
320-
lookupTables[i] = readLookupTable(data, offset + lookups[i]);
326+
LookupTable lookupTable = lookupTableMap.get(lookups[i]);
327+
if (lookupTable == null)
328+
{
329+
lookupTable = readLookupTable(data, offset + lookups[i]);
330+
lookupTableMap.put(lookups[i], lookupTable);
331+
}
332+
lookupTables[i] = lookupTable;
321333
}
322334
return new LookupListTable(lookupCount, lookupTables);
323335
}

0 commit comments

Comments
 (0)