File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 11from dataclasses import dataclass , field
2- from typing import Optional
32
43from pypdf .generic import DictionaryObject
54
@@ -29,10 +28,10 @@ class FontDescriptor:
2928 character_widths : dict [str , int ] = field (default_factory = dict )
3029
3130 @classmethod
32- def from_font_resource (cls , pdf_font_dict : DictionaryObject ) -> "Optional[ FontDescriptor] " :
31+ def from_font_resource (cls , pdf_font_dict : DictionaryObject ) -> "FontDescriptor" :
3332 from pypdf ._codecs .core_fontmetrics import CORE_FONT_METRICS # noqa: PLC0415
3433 # Prioritize information from the PDF font dictionary
35- font_name = pdf_font_dict .get ("/BaseFont" , "Unknown" )
36- if font_name [ 1 :] in CORE_FONT_METRICS :
37- return CORE_FONT_METRICS . get ( font_name [ 1 :])
34+ font_name = pdf_font_dict .get ("/BaseFont" , "Unknown" ). removeprefix ( "/" )
35+ if font_name in CORE_FONT_METRICS :
36+ return CORE_FONT_METRICS [ font_name ]
3837 return cls (name = font_name )
You can’t perform that action at this time.
0 commit comments