Module: Prawn::Rtl::Support::PrawnTextPatch

Included in:
Text::Formatted::Box
Defined in:
lib/prawn/rtl/support.rb

Overview

Patch module that intercepts Prawn’s text rendering to apply RTL transformations.

This module is prepended to Prawn::Text::Formatted::Box to automatically process RTL text before rendering. It intercepts the original_text method and applies Arabic letter connection and bidirectional text reordering to any text fragments that contain RTL characters.

Examples:

How it works internally

# When Prawn renders text, this patch:
# 1. Intercepts the text fragments
# 2. Applies RTL fixes to each fragment
# 3. Returns the processed fragments for rendering

Instance Method Summary collapse

Instance Method Details

#original_textArray<Hash>

Overrides the original_text method to apply RTL transformations.

Returns:

  • (Array<Hash>)

    array of text fragments with RTL text properly formatted



27
28
29
30
31
32
# File 'lib/prawn/rtl/support.rb', line 27

def original_text
  super.map do |h|
    h[:text] = Prawn::Rtl::Connector.fix_rtl(h[:text]) if h.key?(:text)
    h
  end
end