Author: lehmi
Date: Thu Mar 19 07:22:02 2026
New Revision: 1932381
Log:
PDFBOX-6175: extend ResourceCache so that PDCIDFont and PDFontDescriptor
instances can be shared if those are referenced multiple times
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/DefaultResourceCache.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ResourceCache.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDMMType1Font.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/DefaultResourceCache.java
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/DefaultResourceCache.java
Thu Mar 19 06:28:44 2026 (r1932380)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/DefaultResourceCache.java
Thu Mar 19 07:22:02 2026 (r1932381)
@@ -25,7 +25,9 @@ import java.util.Set;
import org.apache.pdfbox.cos.COSObject;
import
org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDPropertyList;
+import org.apache.pdfbox.pdmodel.font.PDCIDFont;
import org.apache.pdfbox.pdmodel.font.PDFont;
+import org.apache.pdfbox.pdmodel.font.PDFontDescriptor;
import org.apache.pdfbox.pdmodel.graphics.PDXObject;
import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
import org.apache.pdfbox.pdmodel.graphics.pattern.PDAbstractPattern;
@@ -54,7 +56,11 @@ public class DefaultResourceCache implem
new HashMap<>();
private final Map<Long, Integer> removedFonts = new HashMap<>();
private final Set<Long> stableFonts = new HashSet<>();
-
+
+ private final Map<COSObject, SoftReference<PDCIDFont>> cidFonts = new
HashMap<>();
+
+ private final Map<COSObject, SoftReference<PDFontDescriptor>>
fontDescriptors = new HashMap<>();
+
private final Map<COSObject, SoftReference<PDColorSpace>> colorSpaces =
new HashMap<>();
private final Map<Long, Integer> removedColorSpaces = new HashMap<>();
@@ -144,6 +150,58 @@ public class DefaultResourceCache implem
return font != null ? font.get() : null;
}
+ @Override
+ public PDCIDFont getCIDFont(COSObject indirect)
+ {
+ SoftReference<PDCIDFont> font = cidFonts.get(indirect);
+ return font != null ? font.get() : null;
+ }
+
+ @Override
+ public void put(COSObject indirect, PDCIDFont font)
+ {
+ cidFonts.put(indirect, new SoftReference<>(font));
+ }
+
+ @Override
+ public PDCIDFont removeCIDFont(COSObject indirect)
+ {
+ if (cidFonts.isEmpty())
+ {
+ return null;
+ }
+ SoftReference<PDCIDFont> font = cidFonts.remove(indirect);
+ return font != null ? font.get() : null;
+ }
+
+ @Override
+ public PDFontDescriptor getFontDescriptor(COSObject indirect)
+ {
+ if (fontDescriptors.isEmpty())
+ {
+ return null;
+ }
+ SoftReference<PDFontDescriptor> fontDescriptor =
fontDescriptors.get(indirect);
+ return fontDescriptor != null ? fontDescriptor.get() : null;
+ }
+
+ @Override
+ public void put(COSObject indirect, PDFontDescriptor fontDescriptor)
+ {
+ fontDescriptors.put(indirect, new SoftReference<>(fontDescriptor));
+ }
+
+ @Override
+ public PDFontDescriptor removeFontDescriptor(COSObject indirect)
+ {
+ if (fontDescriptors.isEmpty())
+ {
+ return null;
+ }
+ SoftReference<PDFontDescriptor> font =
fontDescriptors.remove(indirect);
+ return font != null ? font.get() : null;
+ }
+
@Override
public PDColorSpace getColorSpace(COSObject indirect)
{
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
Thu Mar 19 06:28:44 2026 (r1932380)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
Thu Mar 19 07:22:02 2026 (r1932381)
@@ -47,6 +47,8 @@ import org.apache.pdfbox.pdmodel.common.
import org.apache.pdfbox.pdmodel.common.PDMetadata;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.common.PDStream;
+import org.apache.pdfbox.pdmodel.font.PDFont;
+import org.apache.pdfbox.pdmodel.font.PDType0Font;
import org.apache.pdfbox.pdmodel.graphics.PDXObject;
import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
import org.apache.pdfbox.pdmodel.interactive.action.PDPageAdditionalActions;
@@ -141,14 +143,40 @@ public class PDPage implements COSObject
.forEach(resourceCache::removeColorSpace);
getIndirectResourceObjects(resources, COSName.EXT_G_STATE)
.forEach(resourceCache::removeExtState);
- getIndirectResourceObjects(resources, COSName.FONT)
- .forEach(resourceCache::removeFont);
getIndirectResourceObjects(resources, COSName.PATTERN)
.forEach(resourceCache::removePattern);
getIndirectResourceObjects(resources, COSName.PROPERTIES)
.forEach(resourceCache::removeProperties);
getIndirectResourceObjects(resources, COSName.SHADING)
.forEach(resourceCache::removeShading);
+ for (COSObject cosObject : getIndirectResourceObjects(resources,
COSName.FONT))
+ {
+ PDFont removedFont = resourceCache.removeFont(cosObject);
+ if (removedFont == null)
+ {
+ continue;
+ }
+ COSDictionary fontDict = removedFont.getCOSObject();
+ if (removedFont instanceof PDType0Font)
+ {
+ // remove PDCIDFont from cache
+ COSArray descendantFonts =
fontDict.getCOSArray(COSName.DESCENDANT_FONTS);
+ if (descendantFonts != null)
+ {
+ COSBase descendantFontBaseObject = descendantFonts.get(0);
+ if (descendantFontBaseObject instanceof COSObject)
+ {
+ resourceCache.removeCIDFont((COSObject)
descendantFontBaseObject);
+ }
+ }
+ }
+ COSObject fdIndirectObject =
fontDict.getCOSObject(COSName.FONT_DESC);
+ // remove PDFontDescriptor from cache
+ if (fdIndirectObject != null)
+ {
+ resourceCache.removeFontDescriptor(fdIndirectObject);
+ }
+ }
for (COSObject cosObject : getIndirectResourceObjects(resources,
COSName.XOBJECT))
{
PDXObject removedXObject = resourceCache.removeXObject(cosObject);
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ResourceCache.java
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ResourceCache.java
Thu Mar 19 06:28:44 2026 (r1932380)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ResourceCache.java
Thu Mar 19 07:22:02 2026 (r1932381)
@@ -19,7 +19,9 @@ package org.apache.pdfbox.pdmodel;
import org.apache.pdfbox.cos.COSObject;
import
org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDPropertyList;
+import org.apache.pdfbox.pdmodel.font.PDCIDFont;
import org.apache.pdfbox.pdmodel.font.PDFont;
+import org.apache.pdfbox.pdmodel.font.PDFontDescriptor;
import org.apache.pdfbox.pdmodel.graphics.PDXObject;
import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
import org.apache.pdfbox.pdmodel.graphics.pattern.PDAbstractPattern;
@@ -42,6 +44,22 @@ public interface ResourceCache
PDFont getFont(COSObject indirect);
/**
+ * Returns the PDCIDFont instance for the given indirect object, if it is
in the cache.
+ *
+ * @param indirect the indirect reference of the PDCIDFont instance to be
returned
+ * @return the cached instance of the PDCIDFont, if available
+ */
+ PDCIDFont getCIDFont(COSObject indirect);
+
+ /**
+ * Returns the PDFontDescriptor instance for the given indirect object, if
it is in the cache.
+ *
+ * @param indirect the indirect reference of the PDFontDescriptor instance
to be returned
+ * @return the cached instance of the PDFontDescriptor, if available
+ */
+ PDFontDescriptor getFontDescriptor(COSObject indirect);
+
+ /**
* Returns the color space resource for the given indirect object, if it
is in the cache.
*
* @param indirect the indirect reference of the colorspace to be returned
@@ -98,6 +116,22 @@ public interface ResourceCache
void put(COSObject indirect, PDFont font);
/**
+ * Puts the PDCIDFont instance of the given indirect object in the cache.
+ *
+ * @param indirect the indirect reference of the PDCIDFont to be cached
+ * @param font the font to be cached
+ */
+ void put(COSObject indirect, PDCIDFont cidFont);
+
+ /**
+ * Puts the PDFontDescriptor instance of the given indirect object in the
cache.
+ *
+ * @param indirect the indirect reference of the PDFontDescriptor to be
cached
+ * @param font the font to be cached
+ */
+ void put(COSObject indirect, PDFontDescriptor fontDescriptor);
+
+ /**
* Puts the given indirect color space resource in the cache.
*
* @param indirect the indirect reference of the colorspace to be cached
@@ -173,6 +207,24 @@ public interface ResourceCache
PDFont removeFont(COSObject indirect);
/**
+ * Removes the PDCIDFont instance for the given indirect object from the
cache.
+ *
+ * @param indirect the indirect reference of the PDCIDFont to be removed
+ *
+ * @return the removed PDCIDFont if present
+ */
+ PDCIDFont removeCIDFont(COSObject indirect);
+
+ /**
+ * Removes the PDFontDescriptor instance for the given indirect object
from the cache.
+ *
+ * @param indirect the indirect reference of the PDFontDescriptor to be
removed
+ *
+ * @return the removed PDFontDescriptor if present
+ */
+ PDFontDescriptor removeFontDescriptor(COSObject indirect);
+
+ /**
* Removes the given indirect shading resource from the cache.
*
* @param indirect the indirect reference of the shading to be removed
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
Thu Mar 19 06:28:44 2026 (r1932380)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
Thu Mar 19 07:22:02 2026 (r1932381)
@@ -34,8 +34,10 @@ import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.cos.COSNumber;
+import org.apache.pdfbox.cos.COSObject;
import org.apache.pdfbox.cos.COSStream;
import org.apache.pdfbox.io.RandomAccessRead;
+import org.apache.pdfbox.pdmodel.ResourceCache;
import org.apache.pdfbox.pdmodel.common.COSObjectable;
import org.apache.pdfbox.pdmodel.font.Standard14Fonts.FontName;
import org.apache.pdfbox.pdmodel.font.encoding.GlyphList;
@@ -101,34 +103,46 @@ public abstract class PDFont implements
* Constructor.
*
* @param fontDictionary Font dictionary.
+ * @param resourceCache ResourceCache, can be null.
*/
- protected PDFont(COSDictionary fontDictionary)
+ protected PDFont(COSDictionary fontDictionary, ResourceCache resourceCache)
{
dict = fontDictionary;
codeToWidthMap = new HashMap<>();
// standard 14 fonts use an AFM
afmStandard14 = Standard14Fonts.getAFM(getName()); // may be null (it
usually is)
- fontDescriptor = loadFontDescriptor();
+ fontDescriptor = loadFontDescriptor(resourceCache);
toUnicodeCMap = loadUnicodeCmap();
}
- private PDFontDescriptor loadFontDescriptor()
+ private PDFontDescriptor loadFontDescriptor(ResourceCache resourceCache)
{
+ COSObject fdIndirectObject = dict.getCOSObject(COSName.FONT_DESC);
+ if (fdIndirectObject != null && resourceCache != null)
+ {
+ PDFontDescriptor pdFontdescriptor =
resourceCache.getFontDescriptor(fdIndirectObject);
+ if (pdFontdescriptor != null)
+ {
+ return pdFontdescriptor;
+ }
+ }
COSDictionary fd = dict.getCOSDictionary(COSName.FONT_DESC);
if (fd != null)
{
- return new PDFontDescriptor(fd);
+ PDFontDescriptor pdFontdescriptor = new PDFontDescriptor(fd);
+ if (resourceCache != null && fdIndirectObject != null)
+ {
+ resourceCache.put(fdIndirectObject, pdFontdescriptor);
+ }
+ return pdFontdescriptor;
}
else if (afmStandard14 != null)
{
// build font descriptor from the AFM
return PDType1FontEmbedder.buildFontDescriptor(afmStandard14);
}
- else
- {
- return null;
- }
+ return null;
}
private CMap loadUnicodeCmap()
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
Thu Mar 19 06:28:44 2026 (r1932380)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
Thu Mar 19 07:22:02 2026 (r1932381)
@@ -135,22 +135,22 @@ public final class PDFontFactory
COSDictionary fd = dictionary.getCOSDictionary(COSName.FONT_DESC);
if (fd != null && fd.containsKey(COSName.FONT_FILE3))
{
- return new PDType1CFont(dictionary);
+ return new PDType1CFont(dictionary, resourceCache);
}
- return new PDType1Font(dictionary);
+ return new PDType1Font(dictionary, resourceCache);
}
else if (COSName.MM_TYPE1.equals(subType))
{
COSDictionary fd = dictionary.getCOSDictionary(COSName.FONT_DESC);
if (fd != null && fd.containsKey(COSName.FONT_FILE3))
{
- return new PDType1CFont(dictionary);
+ return new PDType1CFont(dictionary, resourceCache);
}
return new PDMMType1Font(dictionary);
}
else if (COSName.TRUE_TYPE.equals(subType))
{
- return new PDTrueTypeFont(dictionary);
+ return new PDTrueTypeFont(dictionary, resourceCache);
}
else if (COSName.TYPE3.equals(subType))
{
@@ -170,7 +170,7 @@ public final class PDFontFactory
fixType0Subtype(descendantFont, fontDescriptor,
fontTypeFromFont.getSubtype());
}
}
- return new PDType0Font(dictionary);
+ return new PDType0Font(dictionary, resourceCache);
}
else if (COSName.CID_FONT_TYPE0.equals(subType))
{
@@ -185,7 +185,7 @@ public final class PDFontFactory
// assuming Type 1 font (see PDFBOX-1988) because it seems that
Adobe Reader does this
// however, we may need more sophisticated logic perhaps looking
at the FontFile
LOG.warn("Invalid font subtype '{}'", subType);
- return new PDType1Font(dictionary);
+ return new PDType1Font(dictionary, resourceCache);
}
}
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDMMType1Font.java
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDMMType1Font.java
Thu Mar 19 06:28:44 2026 (r1932380)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDMMType1Font.java
Thu Mar 19 07:22:02 2026 (r1932381)
@@ -36,6 +36,6 @@ public class PDMMType1Font extends PDTyp
*/
public PDMMType1Font(COSDictionary fontDictionary) throws IOException
{
- super(fontDictionary);
+ super(fontDictionary, null);
}
}
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
Thu Mar 19 06:28:44 2026 (r1932380)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
Thu Mar 19 07:22:02 2026 (r1932381)
@@ -27,6 +27,7 @@ import org.apache.fontbox.FontBoxFont;
import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.ResourceCache;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.font.Standard14Fonts.FontName;
import org.apache.pdfbox.pdmodel.font.encoding.DictionaryEncoding;
@@ -71,10 +72,11 @@ public abstract class PDSimpleFont exten
* Constructor.
*
* @param fontDictionary Font dictionary.
+ * @param resourceCache ResourceCache, can be null.
*/
- PDSimpleFont(COSDictionary fontDictionary)
+ PDSimpleFont(COSDictionary fontDictionary, ResourceCache resourceCache)
{
- super(fontDictionary);
+ super(fontDictionary, resourceCache);
}
/**
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
Thu Mar 19 06:28:44 2026 (r1932380)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
Thu Mar 19 07:22:02 2026 (r1932381)
@@ -46,6 +46,7 @@ import org.apache.pdfbox.io.RandomAccess
import org.apache.pdfbox.io.RandomAccessReadBuffer;
import org.apache.pdfbox.io.RandomAccessReadBufferedFile;
import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.ResourceCache;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.common.PDStream;
import org.apache.pdfbox.pdmodel.font.Standard14Fonts.FontName;
@@ -97,12 +98,14 @@ public class PDTrueTypeFont extends PDSi
* Creates a new TrueType font from a Font dictionary.
*
* @param fontDictionary The font dictionary according to the PDF
specification.
+ * @param resourceCache ResourceCache, can be null.
*
* @throws IOException if the font could not be created
*/
- public PDTrueTypeFont(COSDictionary fontDictionary) throws IOException
+ public PDTrueTypeFont(COSDictionary fontDictionary, ResourceCache
resourceCache)
+ throws IOException
{
- super(fontDictionary);
+ super(fontDictionary, resourceCache);
TrueTypeFont ttfFont = null;
boolean fontIsDamaged = false;
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
Thu Mar 19 06:28:44 2026 (r1932380)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
Thu Mar 19 07:22:02 2026 (r1932381)
@@ -36,10 +36,12 @@ import org.apache.pdfbox.cos.COSArray;
import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.cos.COSObject;
import org.apache.pdfbox.io.RandomAccessRead;
import org.apache.pdfbox.io.RandomAccessReadBuffer;
import org.apache.pdfbox.io.RandomAccessReadBufferedFile;
import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.ResourceCache;
import org.apache.pdfbox.util.Matrix;
import org.apache.pdfbox.util.Vector;
@@ -56,7 +58,8 @@ public class PDType0Font extends PDFont
private final Set<Integer> noUnicode = new HashSet<>();
private final GsubData gsubData;
private final CmapLookup cmapLookup;
- private CMap cMap, cMapUCS2;
+ private CMap cMap;
+ private CMap cMapUCS2;
private boolean isCMapPredefined;
private boolean isDescendantCJK;
private PDCIDFontType2Embedder embedder;
@@ -66,11 +69,13 @@ public class PDType0Font extends PDFont
* Constructor for reading a Type0 font from a PDF file.
*
* @param fontDictionary The font dictionary according to the PDF
specification.
+ * @param resourceCache ResourceCache, can be null.
+ *
* @throws IOException if the descendant font is missing.
*/
- public PDType0Font(COSDictionary fontDictionary) throws IOException
+ public PDType0Font(COSDictionary fontDictionary, ResourceCache
resourceCache) throws IOException
{
- super(fontDictionary);
+ super(fontDictionary, resourceCache);
gsubData = GsubData.NO_DATA_FOUND;
cmapLookup = null;
@@ -94,7 +99,22 @@ public class PDType0Font extends PDFont
{
throw new IOException("Missing or wrong type in descendant font
dictionary");
}
- descendantFont = PDFontFactory.createDescendantFont((COSDictionary)
descendantFontDictBase, this);
+ COSBase descendantFontBaseObject = descendantFonts.get(0);
+ PDCIDFont cachedCIDFont = null;
+ if (resourceCache != null && descendantFontBaseObject instanceof
COSObject)
+ {
+ cachedCIDFont = resourceCache.getCIDFont((COSObject)
descendantFontBaseObject);
+ }
+ if (cachedCIDFont == null)
+ {
+ cachedCIDFont = PDFontFactory
+ .createDescendantFont((COSDictionary)
descendantFontDictBase, this);
+ if (resourceCache != null && descendantFontBaseObject instanceof
COSObject)
+ {
+ resourceCache.put((COSObject) descendantFontBaseObject,
cachedCIDFont);
+ }
+ }
+ descendantFont = cachedCIDFont;
readEncoding();
fetchCMapUCS2();
}
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
Thu Mar 19 06:28:44 2026 (r1932380)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
Thu Mar 19 07:22:02 2026 (r1932381)
@@ -36,6 +36,7 @@ import org.apache.fontbox.util.BoundingB
import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.io.RandomAccessRead;
+import org.apache.pdfbox.pdmodel.ResourceCache;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.common.PDStream;
import org.apache.pdfbox.pdmodel.font.encoding.Encoding;
@@ -70,11 +71,14 @@ public class PDType1CFont extends PDSimp
* Constructor.
*
* @param fontDictionary the corresponding dictionary
+ * @param resourceCache ResourceCache, can be null.
+ *
* @throws IOException it something went wrong
*/
- public PDType1CFont(COSDictionary fontDictionary) throws IOException
+ public PDType1CFont(COSDictionary fontDictionary, ResourceCache
resourceCache)
+ throws IOException
{
- super(fontDictionary);
+ super(fontDictionary, resourceCache);
boolean fontIsDamaged = false;
CFFType1Font cffEmbedded = null;
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
Thu Mar 19 06:28:44 2026 (r1932380)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
Thu Mar 19 07:22:02 2026 (r1932381)
@@ -36,6 +36,7 @@ import org.apache.pdfbox.cos.COSDictiona
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.cos.COSStream;
import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.ResourceCache;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.common.PDStream;
import org.apache.pdfbox.pdmodel.font.Standard14Fonts.FontName;
@@ -183,12 +184,14 @@ public class PDType1Font extends PDSimpl
* Creates a Type 1 font from a Font dictionary in a PDF.
*
* @param fontDictionary font dictionary.
+ * @param resourceCache ResourceCache, can be null.
+ *
* @throws IOException if there was an error initializing the font.
* @throws IllegalArgumentException if /FontFile3 was used.
*/
- public PDType1Font(COSDictionary fontDictionary) throws IOException
+ public PDType1Font(COSDictionary fontDictionary, ResourceCache
resourceCache) throws IOException
{
- super(fontDictionary);
+ super(fontDictionary, resourceCache);
PDFontDescriptor fd = getFontDescriptor();
Type1Font t1 = null;
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java
==============================================================================
---
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java
Thu Mar 19 06:28:44 2026 (r1932380)
+++
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java
Thu Mar 19 07:22:02 2026 (r1932381)
@@ -81,7 +81,7 @@ public class PDType3Font extends PDSimpl
*/
public PDType3Font(COSDictionary fontDictionary, ResourceCache
resourceCache) throws IOException
{
- super(fontDictionary);
+ super(fontDictionary, resourceCache);
this.resourceCache = resourceCache;
readEncoding();
}