@@ -1346,18 +1346,8 @@ def _get_fonts(self) -> Tuple[Set[str], Set[str]]:
13461346 :return: (Set of embedded fonts, set of unembedded fonts)
13471347 """
13481348 obj = self .get_object ()
1349- assert obj is not None
1350-
1351- fonts : Set [str ] = set ()
1352- embedded : Set [str ] = set ()
1353- if isinstance (obj , DictionaryObject ):
1354- f , e = _get_fonts_walk (
1355- cast (DictionaryObject , obj ["/Resources" ]), fonts , embedded
1356- )
1357- if f is not None :
1358- fonts = fonts .union (f )
1359- if e is not None :
1360- embedded = embedded .union (e )
1349+ assert isinstance (obj , DictionaryObject )
1350+ fonts , embedded = _get_fonts_walk (cast (DictionaryObject , obj ["/Resources" ]))
13611351 unembedded = fonts - embedded
13621352 return embedded , unembedded
13631353
@@ -1512,8 +1502,10 @@ def __iter__(self) -> Iterator[PageObject]:
15121502
15131503
15141504def _get_fonts_walk (
1515- obj : DictionaryObject , fnt : Set [str ], emb : Set [str ]
1516- ) -> Tuple [Optional [Set [str ]], Optional [Set [str ]]]:
1505+ obj : DictionaryObject ,
1506+ fnt : Optional [Set [str ]] = None ,
1507+ emb : Optional [Set [str ]] = None ,
1508+ ) -> Tuple [Set [str ], Set [str ]]:
15171509 """
15181510 If there is a key called 'BaseFont', that is a font that is used in the document.
15191511 If there is a key called 'FontName' and another key in the same dictionary object
@@ -1522,8 +1514,12 @@ def _get_fonts_walk(
15221514
15231515 We create and add to two sets, fnt = fonts used and emb = fonts embedded.
15241516 """
1517+ if fnt is None :
1518+ fnt = set ()
1519+ if emb is None :
1520+ emb = set ()
15251521 if not hasattr (obj , "keys" ):
1526- return None , None
1522+ return set (), set ()
15271523 fontkeys = ("/FontFile" , "/FontFile2" , "/FontFile3" )
15281524 if "/BaseFont" in obj :
15291525 fnt .add (cast (str , obj ["/BaseFont" ]))
0 commit comments