GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Text::Bidi::Paragraph(3) User Contributed Perl Documentation Text::Bidi::Paragraph(3)

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

version 2.15

    use Text::Bidi::Paragraph;

    my $par = new Text::Bidi::Paragraph $logical;
    my $offset = 0;
    my $width = 80;
    while ( $offset < $p->len ) {
        my $v = $p->visual($offset, $width);
        say $v;
        $offset += $width;
    }

This class provides the main interface for applying the bidi algorithm in full generality. In the case where the paragraph can be formatted at once, "log2vis" in Text::Bidi can be used as a shortcut.

A paragraph is processed by creating a Text::Bidi::Paragraph object:

    $par = new Text::Bidi::Paragraph $logical;

Here $logical is the text of the paragraph. This applies the first stages of the bidi algorithm: computation of the embedding levels. Once this is done, the text can be displayed using the "visual" method, which does the reordering.

    my $par = new Text::Bidi::Paragraph $logical, ...;

Create a new object corresponding to a text $logical in logical order. The other arguments are key-value pairs. The only ones that have a meaning at the moment are bd, which supplies the Text::Bidi object to use, dir, which prescribes the direction of the paragraph, and shape, which determines shaping flags. The value of dir is a constant in "Text::Bidi::Par::" (e.g., $Text::Bidi::Par::RTL; see Text::Bidi::Constants). The value of shape is a constant from fribidi_shape_arabic(3). If it is "undef", no shaping is done. If it is missing, default shaping will be performed if the paragraph contains Arabic text.

Note that the mere creation of $par runs the bidi algorithm on the given text $logical up to the point of reordering (which is dealt with in "visual").

    my $logical = $par->par;

Returns the logical (input) text corresponding to this paragraph.

    my $dir = $par->dir;

Returns the direction of this paragraph, a constant in the $Text::Bidi::Par:: namespace.

    my $len = $par->len;

The length of this paragraph.

    my $types = $par->types;

The Bidi types of the characters in this paragraph. Each element of @$types is a constant in the $Text::Bidi::Type:: namespace.

    my $levels = $par->levels;

The embedding levels for this paragraph. Each element of @$levels is an integer.

    my $bd = $par->bd;

The Text::Bidi object used to interface with libfribidi.

    my $map = $par->map;

The map from the logical text to the visual, i.e., the values in $map are indices in the logical string, so that the $i-th character of the visual string is the character that occurs at "$map->[$i]" in the logical string.

This is updated on each call to "visual", so that the map for the full paragraph is correct only after calling "visual" for the whole text.

    @types = $par->type_names;

Returns the list of bidi types as strings

    my $rtl = $par->is_rtl;

Returns true if the direction of the paragraph is "RTL" (right to left).

    $props = $self->ar_props

Return the shaping properties (TODO)

    $shaped = $self->shaped(flags)

Return the shaped paragraph, and fix ar_props (TODO)

    my $visual = $par->visual($offset, $length, $flags);

Return the visual representation of the part of the paragraph $par starting at $offset and of length $length. $par is a Text::Bidi::Paragraph object. All arguments are optional, with $offset defaulting to 0 and $length to the length till the end of the paragraph (see below from $flags).

Note that this method does not take care of right-justifying the text if the paragraph direction is "RTL". Hence a typical application might look as follows:

    my $visual = $par->visual($offset, $width, $flags);
    my $len = length($visual);
    $visual = (' ' x ($width - $len)) . $visual if $par->is_rtl;

Note also that the length of the result might be strictly less than $length.

The $flags argument, if defined, should be either a hashref or an integer. If it is a number, its meaning is the same as in fribidi_reorder_line(3). A hashref is converted to the corresponding values for keys whose value is true. The keys should be the same as the constants in fribidi-types.h, with the prefix "FRIBIDI_FLAGS_" removed.

In addition, the $flags hashref may contain lower-case keys. The only one recognised at the moment is break. Its value, if given, should be a string at which the line should be broken. Hence, if this key is given, the actual length is potentially reduced, so that the line breaks at the given string (if possible). A typical value for break is ' '.

Text::Bidi

Moshe Kamensky <kamensky@cpan.org>

This software is copyright (c) 2015 by Moshe Kamensky.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2018-09-24 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.