The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Ascii::Text - module for generating ASCII text in various fonts and styles

VERSION

Version 0.15

SYNOPSIS

        use Ascii::Text;

        my $foo = Ascii::Text->new(
                color => 'red',
                align => 'center'
        );

        $foo->("Hello World");

         _   _        _  _                 _    _              _      _
        | | | |      | || |               | |  | |            | |    | |
        | |_| |  ___ | || |  ___          | |  | |  ___   _ _ | |  __| |
        |  _  | / _ \| || | / _ \         | |/\| | / _ \ | '_|| | / _` |
        | | | ||  __/| || || (_) |        \  /\  /| (_) || |  | || (_| |
        \_| |_/ \___||_||_| \___/          \/  \/  \___/ |_|  |_| \__,_|

SUBROUTINES/METHODS

new

Instantiate a new Ascii::Text object.

        my $ascii = Ascii::Text->new(
                font => 'Boomer',
                max_width => 100
        );

render

Render the passed string as ascii text. By default this will print to the terminal.

        $ascii->render("Hello World");

...

You can capture lines of text instead by passing an array reference as the second argument.

        my $lines = [];
        $ascii->render("Hello World", $lines);
        print join "", @{$lines};

stringify

Stringify the ascii text. Optionally you can pass an additional true value which will wrap the ascii text removing trailing empty lines which maybe unused based on the character set.

        $ascii->stringify("Hello World");

        $ascii->stringify("Hello World", 1);

ATTRIBUTES

max_width

Set/Get the max width of a line of text by default this uses Term::Size::ReadKey so that the max width of your terminal is used.

        $ascii->max_width(100);

pad

Set/Get the left padding of the text on a line. When "align" is set to center or right this value will become redundant. The default value is 0.

        $ascii->pad(10);

font

Set/Get the reference to the font class.

        $ascii->font("Boomer");

align

Set/Get the alignment of the text on the line. Options are left, center or right.

        $ascii->align('right');

color

Set/Get the font color

        $ascii->color("red");

color_map

Override the default ANSI color map.

        $ascii->color_map({
                red => "\e[31m",
                ...
        });

fh

A filehandle to print the ascii text.

        open my $fh, '>', 'test.txt';
        $ascii->fh($fh);
        $ascii->("Hello World");

AUTHOR

LNATION, <email at lnation.org>

BUGS

Please report any bugs or feature requests to bug-ascii-text at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Ascii-Text. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Ascii::Text

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2024 by LNATION.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)