@@ -139,25 +139,28 @@ def test_mupdf_subset_fonts2():
139139
140140def test_3677 ():
141141 pymupdf .TOOLS .set_subset_fontnames (True )
142- path = os .path .abspath (f'{ __file__ } /../../tests/resources/test_3677.pdf' )
143- font_names_expected = [
144- 'BCDEEE+Aptos' ,
145- 'BCDFEE+Aptos' ,
146- 'BCDGEE+Calibri-Light' ,
147- 'BCDHEE+Calibri-Light' ,
148- ]
149- font_names = list ()
150- with pymupdf .open (path ) as document :
151- for page in document :
152- for block in page .get_text ('dict' )['blocks' ]:
153- if block ['type' ] == 0 :
154- if 'lines' in block .keys ():
155- for line in block ['lines' ]:
156- for span in line ['spans' ]:
157- font_name = span ['font' ]
158- print (font_name )
159- font_names .append (font_name )
160- assert font_names == font_names_expected , f'{ font_names = } '
142+ try :
143+ path = os .path .abspath (f'{ __file__ } /../../tests/resources/test_3677.pdf' )
144+ font_names_expected = [
145+ 'BCDEEE+Aptos' ,
146+ 'BCDFEE+Aptos' ,
147+ 'BCDGEE+Calibri-Light' ,
148+ 'BCDHEE+Calibri-Light' ,
149+ ]
150+ font_names = list ()
151+ with pymupdf .open (path ) as document :
152+ for page in document :
153+ for block in page .get_text ('dict' )['blocks' ]:
154+ if block ['type' ] == 0 :
155+ if 'lines' in block .keys ():
156+ for line in block ['lines' ]:
157+ for span in line ['spans' ]:
158+ font_name = span ['font' ]
159+ print (font_name )
160+ font_names .append (font_name )
161+ assert font_names == font_names_expected , f'{ font_names = } '
162+ finally :
163+ pymupdf .TOOLS .set_subset_fontnames (False )
161164
162165
163166def test_3933 ():
0 commit comments