Skip to content

Commit f4e9285

Browse files
committed
Remove code duplication
1 parent abb5130 commit f4e9285

File tree

1 file changed

+0
-39
lines changed

1 file changed

+0
-39
lines changed

pypdf/_page.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151

5252
from ._cmap import (
5353
build_char_map,
54-
build_font_width_map,
55-
compute_font_width,
56-
get_actual_str_key,
5754
)
5855
from ._protocols import PdfCommonDocProtocol
5956
from ._text_extraction import (
@@ -1656,42 +1653,6 @@ def _debug_for_extract(self) -> str: # pragma: no cover
16561653
out += "No Font\n"
16571654
return out
16581655

1659-
def _get_actual_font_widths(
1660-
self,
1661-
cmap: Tuple[
1662-
Union[str, Dict[int, str]], Dict[str, str], str, Optional[DictionaryObject]
1663-
],
1664-
text_operands: str,
1665-
font_size: float,
1666-
space_width: float
1667-
) -> Tuple[float, float, float]:
1668-
font_widths: float = 0
1669-
font_name: str = cmap[2]
1670-
if font_name not in self._font_width_maps:
1671-
if cmap[3] is None:
1672-
font_width_map: Dict[Any, float] = {}
1673-
space_char = " "
1674-
actual_space_width: float = space_width
1675-
font_width_map["default"] = actual_space_width * 2
1676-
else:
1677-
space_char = get_actual_str_key(" ", cmap[0], cmap[1])
1678-
font_width_map = build_font_width_map(cmap[3], space_width * 2)
1679-
actual_space_width = compute_font_width(font_width_map, space_char)
1680-
if actual_space_width == 0:
1681-
actual_space_width = space_width
1682-
self._font_width_maps[font_name] = (font_width_map, space_char, actual_space_width)
1683-
font_width_map = self._font_width_maps[font_name][0]
1684-
space_char = self._font_width_maps[font_name][1]
1685-
actual_space_width = self._font_width_maps[font_name][2]
1686-
1687-
if text_operands:
1688-
for char in text_operands:
1689-
if char == space_char:
1690-
font_widths += actual_space_width
1691-
continue
1692-
font_widths += compute_font_width(font_width_map, char)
1693-
return (font_widths * font_size, space_width * font_size, font_size)
1694-
16951656
def _extract_text(
16961657
self,
16971658
obj: Any,

0 commit comments

Comments
 (0)