Skip to content

Respect rotated character directions with use_text_flow - #1414

Open
iAlturki wants to merge 1 commit into
jsvine:developfrom
iAlturki:fix_text_flow_character_direction
Open

iAlturki wants to merge 1 commit into
jsvine:developfrom
iAlturki:fix_text_flow_character_direction

Conversation

@iAlturki

Copy link
Copy Markdown

With use_text_flow=True, word boundaries are tested using the upright char_dir even for rotated character groups. For example, a clockwise-rotated ALPHA BETA is returned as nine single-letter words, although the reported word direction is ttb.

Use get_char_dir() for each group's orientation, matching the existing line-based extraction path and word metadata. This also respects the legacy horizontal_ltr=False and vertical_ttb=False options. Character order from the PDF is preserved.

The two new regression tests use the existing issue-848.pdf fixture. They cover top-to-bottom and bottom-to-top rotated text, legacy right-to-left/bottom-to-top directions, extraction with and without extra_attrs=["fontname"], and preservation of returned source characters. Changelog and contributor credit are included as requested by CONTRIBUTING.md.

Validation on Linux, CPython 3.12.3:

  • Original source with the new tests: 173 passed, 2 failed; both failures are the new regressions.
  • Fixed source: 175 passed, no skips, plus HTML coverage generation.
  • Black, isort, Flake8, strict mypy, and git diff --check pass.

Actual word boxes from the same synthetic input PDF:

Original single-letter words and fixed whole-word extraction

Offline interactive demo and reproduction instructions include the generated PDF, exact word bounds, source commits, and capture script. The proof assets are on a separate branch; this PR contains the fix, tests, changelog, and contributor entry.

Prepared with AI assistance. Commit author: iAlturki.

Copilot AI balanced review requested due to automatic review settings October 15, 2026 13:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants