1Text::Bidi::Paragraph(3U)ser Contributed Perl DocumentatiToenxt::Bidi::Paragraph(3)
2
3
4

NAME

6       Text::Bidi::Paragraph - Run the bidi algorithm on one paragraph
7

VERSION

9       version 2.15
10

SYNOPSIS

12           use Text::Bidi::Paragraph;
13
14           my $par = new Text::Bidi::Paragraph $logical;
15           my $offset = 0;
16           my $width = 80;
17           while ( $offset < $p->len ) {
18               my $v = $p->visual($offset, $width);
19               say $v;
20               $offset += $width;
21           }
22

DESCRIPTION

24       This class provides the main interface for applying the bidi algorithm
25       in full generality. In the case where the paragraph can be formatted at
26       once, "log2vis" in Text::Bidi can be used as a shortcut.
27
28       A paragraph is processed by creating a Text::Bidi::Paragraph object:
29
30           $par = new Text::Bidi::Paragraph $logical;
31
32       Here $logical is the text of the paragraph. This applies the first
33       stages of the bidi algorithm: computation of the embedding levels. Once
34       this is done, the text can be displayed using the "visual" method,
35       which does the reordering.
36

METHODS

38   new
39           my $par = new Text::Bidi::Paragraph $logical, ...;
40
41       Create a new object corresponding to a text $logical in logical order.
42       The other arguments are key-value pairs. The only ones that have a
43       meaning at the moment are bd, which supplies the Text::Bidi object to
44       use, dir, which prescribes the direction of the paragraph, and shape,
45       which determines shaping flags. The value of dir is a constant in
46       "Text::Bidi::Par::" (e.g., $Text::Bidi::Par::RTL; see
47       Text::Bidi::Constants). The value of shape is a constant from
48       fribidi_shape_arabic(3). If it is "undef", no shaping is done. If it is
49       missing, default shaping will be performed if the paragraph contains
50       Arabic text.
51
52       Note that the mere creation of $par runs the bidi algorithm on the
53       given text $logical up to the point of reordering (which is dealt with
54       in "visual").
55
56   par
57           my $logical = $par->par;
58
59       Returns the logical (input) text corresponding to this paragraph.
60
61   dir
62           my $dir = $par->dir;
63
64       Returns the direction of this paragraph, a constant in the
65       $Text::Bidi::Par:: namespace.
66
67   len
68           my $len = $par->len;
69
70       The length of this paragraph.
71
72   types
73           my $types = $par->types;
74
75       The Bidi types of the characters in this paragraph. Each element of
76       @$types is a constant in the $Text::Bidi::Type:: namespace.
77
78   levels
79           my $levels = $par->levels;
80
81       The embedding levels for this paragraph. Each element of @$levels is an
82       integer.
83
84   bd
85           my $bd = $par->bd;
86
87       The Text::Bidi object used to interface with libfribidi.
88
89   map
90           my $map = $par->map;
91
92       The map from the logical text to the visual, i.e., the values in $map
93       are indices in the logical string, so that the $i-th character of the
94       visual string is the character that occurs at "$map->[$i]" in the
95       logical string.
96
97       This is updated on each call to "visual", so that the map for the full
98       paragraph is correct only after calling "visual" for the whole text.
99
100   type_names
101           @types = $par->type_names;
102
103       Returns the list of bidi types as strings
104
105   is_rtl
106           my $rtl = $par->is_rtl;
107
108       Returns true if the direction of the paragraph is "RTL" (right to
109       left).
110
111   ar_props
112           $props = $self->ar_props
113
114       Return the shaping properties (TODO)
115
116   shaped
117           $shaped = $self->shaped(flags)
118
119       Return the shaped paragraph, and fix ar_props (TODO)
120
121   visual
122           my $visual = $par->visual($offset, $length, $flags);
123
124       Return the visual representation of the part of the paragraph $par
125       starting at $offset and of length $length. $par is a
126       Text::Bidi::Paragraph object. All arguments are optional, with $offset
127       defaulting to 0 and $length to the length till the end of the paragraph
128       (see below from $flags).
129
130       Note that this method does not take care of right-justifying the text
131       if the paragraph direction is "RTL". Hence a typical application might
132       look as follows:
133
134           my $visual = $par->visual($offset, $width, $flags);
135           my $len = length($visual);
136           $visual = (' ' x ($width - $len)) . $visual if $par->is_rtl;
137
138       Note also that the length of the result might be strictly less than
139       $length.
140
141       The $flags argument, if defined, should be either a hashref or an
142       integer.  If it is a number, its meaning is the same as in
143       fribidi_reorder_line(3).  A hashref is converted to the corresponding
144       values for keys whose value is true. The keys should be the same as the
145       constants in fribidi-types.h, with the prefix "FRIBIDI_FLAGS_" removed.
146
147       In addition, the $flags hashref may contain lower-case keys. The only
148       one recognised at the moment is break. Its value, if given, should be a
149       string at which the line should be broken. Hence, if this key is given,
150       the actual length is potentially reduced, so that the line breaks at
151       the given string (if possible). A typical value for break is ' '.
152

SEE ALSO

154       Text::Bidi
155

AUTHOR

157       Moshe Kamensky <kamensky@cpan.org>
158
160       This software is copyright (c) 2015 by Moshe Kamensky.
161
162       This is free software; you can redistribute it and/or modify it under
163       the same terms as the Perl 5 programming language system itself.
164
165
166
167perl v5.32.0                      2020-07-28          Text::Bidi::Paragraph(3)
Impressum