Skip to content

feat: add text overflow detection to TextFrame#1114

Open
saggl wants to merge 1 commit intoscanny:masterfrom
saggl:feature/text-overflow-detection
Open

feat: add text overflow detection to TextFrame#1114
saggl wants to merge 1 commit intoscanny:masterfrom
saggl:feature/text-overflow-detection

Conversation

@saggl
Copy link

@saggl saggl commented Mar 21, 2026

Add new methods to detect and analyze text overflow before it occurs:

  • TextFrame.will_overflow(): Simple boolean check for overflow
  • TextFrame.overflow_info(): Detailed overflow metrics with OverflowInfo dataclass
  • TextFitter.will_fit(): Core overflow detection logic
  • TextFitter.measure_text_height(): Calculate required text height
  • TextFitter.calculate_overflow_metrics(): Detailed overflow analysis

The OverflowInfo dataclass provides:

  • will_overflow: Boolean indicator
  • required_height/available_height: Size metrics
  • overflow_height/overflow_percentage: Overflow amounts
  • estimated_lines: Line count estimate
  • fits_at_font_size: Recommended font size to fit

This enables proactive content validation to prevent text from being cut off at the bottom of text frames, addressing the issue where users don't know content will overflow until they open the presentation.

Includes comprehensive unit tests, feature tests, and examples.

Add new methods to detect and analyze text overflow before it occurs:

- TextFrame.will_overflow(): Simple boolean check for overflow
- TextFrame.overflow_info(): Detailed overflow metrics with OverflowInfo dataclass
- TextFitter.will_fit(): Core overflow detection logic
- TextFitter.measure_text_height(): Calculate required text height
- TextFitter.calculate_overflow_metrics(): Detailed overflow analysis

The OverflowInfo dataclass provides:
- will_overflow: Boolean indicator
- required_height/available_height: Size metrics
- overflow_height/overflow_percentage: Overflow amounts
- estimated_lines: Line count estimate
- fits_at_font_size: Recommended font size to fit

This enables proactive content validation to prevent text from being
cut off at the bottom of text frames, addressing the issue where users
don't know content will overflow until they open the presentation.

Includes comprehensive unit tests, feature tests, and examples.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant