Author: lehmi
Date: Mon Jul  6 15:26:33 2026
New Revision: 1935960

Log:
PDFBOX-6175: remove the extension of the ResourceCache as a descendant font 
refers to its parent font, so that it can't be shared or cached

Modified:
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/DefaultResourceCache.java
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ResourceCache.java
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDMMType1Font.java
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/DefaultResourceCache.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/DefaultResourceCache.java
        Mon Jul  6 15:05:23 2026        (r1935959)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/DefaultResourceCache.java
        Mon Jul  6 15:26:33 2026        (r1935960)
@@ -25,9 +25,7 @@ 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;
@@ -57,10 +55,6 @@ public class DefaultResourceCache implem
     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<>();
@@ -154,58 +148,6 @@ 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/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java  
    Mon Jul  6 15:05:23 2026        (r1935959)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java  
    Mon Jul  6 15:26:33 2026        (r1935960)
@@ -47,8 +47,6 @@ 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;
@@ -149,34 +147,7 @@ public class PDPage implements COSObject
                 .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);
-            }
-        }
+        getIndirectResourceObjects(resources, 
COSName.FONT).forEach(resourceCache::removeFont);
         for (COSObject cosObject : getIndirectResourceObjects(resources, 
COSName.XOBJECT))
         {
             PDXObject removedXObject = resourceCache.removeXObject(cosObject);

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ResourceCache.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ResourceCache.java
       Mon Jul  6 15:05:23 2026        (r1935959)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ResourceCache.java
       Mon Jul  6 15:26:33 2026        (r1935960)
@@ -19,9 +19,7 @@ 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;
@@ -44,28 +42,6 @@ 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
-     */
-    default PDCIDFont getCIDFont(COSObject indirect)
-    {
-        return null;
-    }
-
-    /**
-     * 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
-     */
-    default PDFontDescriptor getFontDescriptor(COSObject indirect)
-    {
-        return null;
-    }
-
-    /**
      * 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
@@ -122,28 +98,6 @@ 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 cidFont the font to be cached
-     */
-    default void put(COSObject indirect, PDCIDFont cidFont)
-    {
-        // default implementation to preserve binary compatibility
-    }
-
-    /**
-     * Puts the PDFontDescriptor instance of the given indirect object in the 
cache.
-     * 
-     * @param indirect the indirect reference of the PDFontDescriptor to be 
cached
-     * @param fontDescriptor the font to be cached
-     */
-    default void put(COSObject indirect, PDFontDescriptor fontDescriptor)
-    {
-        // default implementation to preserve binary compatibility
-    }
-
-    /**
      * Puts the given indirect color space resource in the cache.
      * 
      * @param indirect the indirect reference of the colorspace to be cached
@@ -226,30 +180,6 @@ public interface ResourceCache
     {
         return null;
     }
-
-    /**
-     * 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
-     */
-    default PDCIDFont removeCIDFont(COSObject indirect)
-    {
-        return null;
-    }
-
-    /**
-     * 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
-     */
-    default PDFontDescriptor removeFontDescriptor(COSObject indirect)
-    {
-        return null;
-    }
 
     /**
      * Removes the given indirect shading resource from the cache.

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
 Mon Jul  6 15:05:23 2026        (r1935959)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
 Mon Jul  6 15:26:33 2026        (r1935960)
@@ -34,10 +34,8 @@ 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;
@@ -103,39 +101,24 @@ public abstract class PDFont implements
      * Constructor.
      *
      * @param fontDictionary Font dictionary.
-     * @param resourceCache ResourceCache, can be null.
      */
-    protected PDFont(COSDictionary fontDictionary, ResourceCache resourceCache)
+    protected PDFont(COSDictionary fontDictionary)
     {
         dict = fontDictionary;
         codeToWidthMap = new HashMap<>();
 
         // standard 14 fonts use an AFM
         afmStandard14 = Standard14Fonts.getAFM(getName()); // may be null (it 
usually is)
-        fontDescriptor = loadFontDescriptor(resourceCache);
+        fontDescriptor = loadFontDescriptor();
         toUnicodeCMap = loadUnicodeCmap();
     }
 
-    private PDFontDescriptor loadFontDescriptor(ResourceCache resourceCache)
+    private PDFontDescriptor loadFontDescriptor()
     {
-        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)
         {
-            PDFontDescriptor pdFontdescriptor = new PDFontDescriptor(fd);
-            if (resourceCache != null && fdIndirectObject != null)
-            {
-                resourceCache.put(fdIndirectObject, pdFontdescriptor);
-            }
-            return pdFontdescriptor;
+            return new PDFontDescriptor(fd);
         }
         else if (afmStandard14 != null)
         {

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
  Mon Jul  6 15:05:23 2026        (r1935959)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
  Mon Jul  6 15:26:33 2026        (r1935960)
@@ -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, resourceCache);
+                return new PDType1CFont(dictionary);
             }
-            return new PDType1Font(dictionary, resourceCache);
+            return new PDType1Font(dictionary);
         }
         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, resourceCache);
+                return new PDType1CFont(dictionary);
             }
-            return new PDMMType1Font(dictionary, resourceCache);
+            return new PDMMType1Font(dictionary);
         }
         else if (COSName.TRUE_TYPE.equals(subType))
         {
-            return new PDTrueTypeFont(dictionary, resourceCache);
+            return new PDTrueTypeFont(dictionary);
         }
         else if (COSName.TYPE3.equals(subType))
         {
@@ -170,7 +170,7 @@ public final class PDFontFactory
                     fixType0Subtype(descendantFont, fontDescriptor, 
fontTypeFromFont.getSubtype());
                 }
             }
-            return new PDType0Font(dictionary, resourceCache);
+            return new PDType0Font(dictionary);
         }
         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, resourceCache);
+            return new PDType1Font(dictionary);
         }
     }
 

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDMMType1Font.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDMMType1Font.java
  Mon Jul  6 15:05:23 2026        (r1935959)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDMMType1Font.java
  Mon Jul  6 15:26:33 2026        (r1935960)
@@ -17,7 +17,6 @@
 package org.apache.pdfbox.pdmodel.font;
 
 import org.apache.pdfbox.cos.COSDictionary;
-import org.apache.pdfbox.pdmodel.ResourceCache;
 
 import java.io.IOException;
 
@@ -34,26 +33,11 @@ public class PDMMType1Font extends PDTyp
      * @param fontDictionary font dictionary
      * 
      * @throws IOException if the font could not be read
-     * 
-     * @deprecated use {@link #PDMMType1Font(COSDictionary, ResourceCache)} 
instead
-     */
-    public PDMMType1Font(COSDictionary fontDictionary) throws IOException
-    {
-        this(fontDictionary, null);
-    }
-
-    /**
-     * Creates an MMType1Font from a Font dictionary in a PDF.
-     *
-     * @param fontDictionary font dictionary
-     * @param resourceCache ResourceCache, can be null.
-     * 
-     * @throws IOException if the font could not be read
      */
-    public PDMMType1Font(COSDictionary fontDictionary, ResourceCache 
resourceCache)
+    public PDMMType1Font(COSDictionary fontDictionary)
             throws IOException
     {
-        super(fontDictionary, resourceCache);
+        super(fontDictionary);
     }
 
 }

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
   Mon Jul  6 15:05:23 2026        (r1935959)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
   Mon Jul  6 15:26:33 2026        (r1935960)
@@ -27,7 +27,6 @@ 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;
@@ -72,11 +71,10 @@ public abstract class PDSimpleFont exten
      * Constructor.
      *
      * @param fontDictionary Font dictionary.
-     * @param resourceCache ResourceCache, can be null.
      */
-    PDSimpleFont(COSDictionary fontDictionary, ResourceCache resourceCache)
+    PDSimpleFont(COSDictionary fontDictionary)
     {
-        super(fontDictionary, resourceCache);
+        super(fontDictionary);
     }
 
     /**

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
 Mon Jul  6 15:05:23 2026        (r1935959)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
 Mon Jul  6 15:26:33 2026        (r1935960)
@@ -46,7 +46,6 @@ 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;
@@ -98,26 +97,11 @@ public class PDTrueTypeFont extends PDSi
      * @param fontDictionary The font dictionary according to the PDF 
specification.
      * 
      * @throws IOException if the font could not be created
-     * 
-     * @deprecated use {@link #PDTrueTypeFont(COSDictionary, ResourceCache)} 
instead
-     */
-    public PDTrueTypeFont(COSDictionary fontDictionary) throws IOException
-    {
-        this(fontDictionary, null);
-    }
-
-    /**
-     * 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, ResourceCache 
resourceCache)
+    public PDTrueTypeFont(COSDictionary fontDictionary)
             throws IOException
     {
-        super(fontDictionary, resourceCache);
+        super(fontDictionary);
 
         TrueTypeFont ttfFont = null;
         boolean fontIsDamaged = false;

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
    Mon Jul  6 15:05:23 2026        (r1935959)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
    Mon Jul  6 15:26:33 2026        (r1935960)
@@ -36,12 +36,10 @@ 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;
 
@@ -70,24 +68,10 @@ public class PDType0Font extends PDFont
      * 
      * @param fontDictionary The font dictionary according to the PDF 
specification.
      * @throws IOException if the descendant font is missing.
-     * 
-     * @deprecated use {@link #PDType0Font(COSDictionary, ResourceCache)} 
instead
      */
     public PDType0Font(COSDictionary fontDictionary) throws IOException
     {
-        this(fontDictionary, null);
-    }
-
-    /**
-     * 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, ResourceCache 
resourceCache) throws IOException
-    {
-        super(fontDictionary, resourceCache);
+        super(fontDictionary);
 
         gsubData = GsubData.NO_DATA_FOUND;
         cmapLookup = null;
@@ -106,27 +90,12 @@ public class PDType0Font extends PDFont
         {
             throw new IOException("Missing descendant font dictionary");
         }
-        if (!COSName.FONT.equals(
-                ((COSDictionary) 
descendantFontDictBase).getCOSName(COSName.TYPE, COSName.FONT)))
+        COSDictionary descendantFontDict = (COSDictionary) 
descendantFontDictBase;
+        if (!COSName.FONT.equals(descendantFontDict.getCOSName(COSName.TYPE, 
COSName.FONT)))
         {
             throw new IOException("Missing or wrong type in descendant font 
dictionary");
         }
-        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;
+        descendantFont = 
PDFontFactory.createDescendantFont(descendantFontDict, this);
         readEncoding();
         fetchCMapUCS2();
     }

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
   Mon Jul  6 15:05:23 2026        (r1935959)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
   Mon Jul  6 15:26:33 2026        (r1935960)
@@ -36,7 +36,6 @@ 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;
@@ -73,26 +72,11 @@ public class PDType1CFont extends PDSimp
      * @param fontDictionary the corresponding dictionary
      * 
      * @throws IOException it something went wrong
-     * 
-     * @deprecated use {@link #PDType1CFont(COSDictionary, ResourceCache)} 
instead
-     */
-    public PDType1CFont(COSDictionary fontDictionary) throws IOException
-    {
-        this(fontDictionary, null);
-    }
-
-    /**
-     * Constructor.
-     * 
-     * @param fontDictionary the corresponding dictionary
-     * @param resourceCache ResourceCache, can be null.
-     * 
-     * @throws IOException it something went wrong
      */
-    public PDType1CFont(COSDictionary fontDictionary, ResourceCache 
resourceCache)
+    public PDType1CFont(COSDictionary fontDictionary)
             throws IOException
     {
-        super(fontDictionary, resourceCache);
+        super(fontDictionary);
 
         boolean fontIsDamaged = false;
         CFFType1Font cffEmbedded = null;

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
    Mon Jul  6 15:05:23 2026        (r1935959)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
    Mon Jul  6 15:26:33 2026        (r1935960)
@@ -36,7 +36,6 @@ 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;
@@ -187,26 +186,10 @@ public class PDType1Font extends PDSimpl
      * 
      * @throws IOException if there was an error initializing the font.
      * @throws IllegalArgumentException if /FontFile3 was used.
-     * 
-     * @deprecated use {@link #PDType1Font(COSDictionary, ResourceCache)} 
instead
      */
     public PDType1Font(COSDictionary fontDictionary) throws IOException
     {
-        this(fontDictionary, null);
-    }
-
-    /**
-     * 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, ResourceCache 
resourceCache) throws IOException
-    {
-        super(fontDictionary, resourceCache);
+        super(fontDictionary);
 
         PDFontDescriptor fd = getFontDescriptor();
         Type1Font t1 = null;

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java
    Mon Jul  6 15:05:23 2026        (r1935959)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java
    Mon Jul  6 15:26:33 2026        (r1935960)
@@ -81,7 +81,7 @@ public class PDType3Font extends PDSimpl
      */
     public PDType3Font(COSDictionary fontDictionary, ResourceCache 
resourceCache) throws IOException
     {
-        super(fontDictionary, resourceCache);
+        super(fontDictionary);
         this.resourceCache = resourceCache;
         readEncoding();
     }

Reply via email to