struct

Bidi::BidiInfo

Inherits Bidi::BidiInfoCommon < Struct < Value < Object

Main structure for bidirectional analysis of UTF-8 text

Contains the results of bidi analysis for potentially multiple paragraphs. This is the primary entry point for analyzing mixed-direction text.

Properties:

  • text: The original input text
  • original_classes: BidiClass for each byte in the text
  • levels: Embedding level for each byte in the text (after resolution)
  • paragraphs: Information about each paragraph in the text

This matches the Rust BidiInfo<'text> struct.

Constructors

new(text : String, original_classes : Array(BidiClass), levels : Array(Level), paragraphs : Array(ParagraphInfo))
Source
new(text : String, default_para_level : Level | Nil = nil) : BidiInfo

Creates a new BidiInfo by analyzing text with the default data source

Parameters:

  • text: The UTF-8 text to analyze
  • default_para_level: Optional base paragraph level (nil for auto-detection)

Returns: BidiInfo with analysis results

Source
new_with_data_source(data_source : BidiDataSource, text : String, default_para_level : Level | Nil = nil) : BidiInfo

Creates a new BidiInfo with a custom data source for bidi data

This is the lower-level constructor that allows customizing the Unicode data source. Most users should use BidiInfo.new() instead.

Parameters:

  • data_source: Custom BidiDataSource for bidi class lookups
  • text: The UTF-8 text to analyze
  • default_para_level: Optional base paragraph level

Returns: BidiInfo with analysis results

Source

Class methods

reorder_visual(levels : Array(Level)) : Array(Int32)
Source

Instance methods

levels
Source
levels=(levels : Array(Level))
Source
original_classes
Source
original_classes=(original_classes : Array(BidiClass))
Source
paragraphs
Source
paragraphs=(paragraphs : Array(ParagraphInfo))
Source
reorder_line(para : ParagraphInfo, line : Range(Int32, Int32)) : String

Reorders a line of text for visual display

Applies the Unicode Bidirectional Algorithm to reorder text within a line for proper visual display. This is the main method for getting text in the correct order for rendering.

Parameters:

  • para: The paragraph containing the line
  • line: Byte range within the text representing the line

Returns: The reordered text as a String

Note: Uses byte_slice for correct UTF-8 handling with multi-byte characters.

Source
reordered_levels(para : ParagraphInfo, line : Range(Int32, Int32)) : Array(Level)
Source
reordered_levels_per_char(para : ParagraphInfo, line : Range(Int32, Int32)) : Array(Level)
Source
text
Source
text=(text : String)
Source
visual_runs(para : ParagraphInfo, line : Range(Int32, Int32)) : Tuple(Array(Level), Array(Range(Int32, Int32)))

Finds visual runs within a line

Returns level runs in visual order as required by the Unicode Bidi Algorithm. The first return value is levels after applying L1-L2 rules. The second return value is runs (contiguous same-level ranges) in visual order.

Parameters:

  • para: The paragraph containing the line
  • line: Byte range within the text

Returns: Tuple of (Array(Level), Array(Range(Int32, Int32)))

Source