From cf177a0cde96b8aa50b5e6ad0e80437bb41983ac Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 7 Oct 2026 17:37:45 +0300 Subject: [PATCH] Extract descendant font refs --- src/core/catalog.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/core/catalog.js b/src/core/catalog.js index 8f2d45ce5bdd5..36d19beedc404 100644 --- a/src/core/catalog.js +++ b/src/core/catalog.js @@ -2061,6 +2061,7 @@ class ExtendedCatalog extends Catalog { let actualFont = fontObj; let cidFontType = null; let normalizedSubtype = null; + let descendantRef = null; let baseFont = null; let cidBaseFont = null; let encoding = null; @@ -2078,7 +2079,7 @@ class ExtendedCatalog extends Catalog { if (Array.isArray(descendantFonts) && descendantFonts.length > 0) { const cidFont = this.xref.fetchIfRef(descendantFonts[0]); - + descendantRef = descendantFonts[0]; if (cidFont instanceof Dict) { actualFont = cidFont; @@ -2135,6 +2136,7 @@ class ExtendedCatalog extends Catalog { return { cidFontType, normalizedSubtype, + descendantRef, baseFont, cidBaseFont, encoding, @@ -2148,6 +2150,7 @@ class ExtendedCatalog extends Catalog { return { cidFontType: null, normalizedSubtype: null, + descendantRef: null, baseFont: null, cidBaseFont: null, encoding: null, @@ -2200,6 +2203,7 @@ class ExtendedCatalog extends Catalog { const { cidFontType, normalizedSubtype, + descendantRef, baseFont, encoding, isComposite, @@ -2218,16 +2222,24 @@ class ExtendedCatalog extends Catalog { if (seenFonts.has(fontIdentity)) { const existing = seenFonts.get(fontIdentity); if ( - !existing.refs.some( + !fontRef || !existing.refs.some( r => r && - fontRef && r.num === fontRef.num && r.gen === fontRef.gen ) ) { existing.refs.push(fontRef); } + if ( + descendantRef && !existing.descendantRefs.some( + r => + r.num === descendantRef.num && + r.gen === descendantRef.gen + ) + ) { + existing.descendantRefs.push(descendantRef); + } existing.names[pageIndex] = fontName; continue; } @@ -2235,6 +2247,7 @@ class ExtendedCatalog extends Catalog { const fontInfo = { names: { [pageIndex]: fontName }, refs: [fontRef instanceof Ref ? fontRef : null], + descendantRefs: descendantRef instanceof Ref ? [descendantRef] : [], type: isComposite ? "Type0" : normalizedSubtype, subtype: normalizedSubtype, cidFontType,