Layout

class text_renderer.layout.Layout[source]

Abstract base class for text layout management.

This class defines the interface for layout algorithms that determine how multiple text elements should be positioned relative to each other in a single image. Layout classes handle both positioning and text merging.

Subclasses must implement the apply method to define specific layout logic.

abstract apply(text_bboxes: List[BBox], img_bboxes: List[BBox]) List[BBox][source]

Apply layout algorithm to position text elements.

This method must be implemented by subclasses to define the specific layout algorithm for positioning multiple text elements.

Parameters:
  • text_bboxes (List[BBox]) – Text bounding boxes on image

  • img_bboxes (List[BBox]) – Image bounding boxes

Returns:

Modified image bounding boxes in same coordinate system

Return type:

List[BBox]

merge_texts(font_texts: List[FontText]) str[source]

Merge multiple text elements into a single string.

This method concatenates the text content from multiple FontText objects into a single string. The default implementation simply joins all texts together.

Parameters:

font_texts (List[FontText]) – List of FontText objects to merge

Returns:

Merged text content

Return type:

str