NAME

HarfBuzz::Shaper - Use HarfBuzz for text shaping

SYNOPSIS

    use HarfBuzz::Shaper;
    my $hb = HarfBuzz::Shaper->new;
    $hb->set_font('LiberationSans.ttf');
    $hb->set_size(36);
    $hb->set_text("Hello!");
    my $info = $hb->shaper;

The result is an array of hashes, one element for each glyph to be typeset.

DESCRIPTION

HarfBuzz::Shaper is a perl module that provides access to a small subset of the native HarfBuzz library.

The subset is suitable for typesetting programs that need to deal with complex languages like Devanagari.

This module is intended to be used with module Text::Layout. Feel free to (ab)use it for other purposes.

Following the above example, the returned info is an array of hashes, one element for each glyph to be typeset. The hash contains the following items:

    ax:   horizontal advance
    ay:   vertical advance
    dx:   horizontal offset
    dy:   vertical offset
    g:    glyph index in font (CId)
    name: glyph name

Note that the number of glyphs does not necessarily match the number of input characters!

METHODS

$hb = HarfBuzz::Shaper->new( [ options ] )

Creates a new shaper object.

Options:

  • font = > font filename

  • size = > text size

$hb->set_font( font filename [ , size ] )

Explicit way to set the font (and, optionally, the size) used for shaping.

$hb->set_size( size )

Explicit way to set the font size used for shaping.

$hb->set_text( text [ , ... ] )

Set the text to shape. Multiple arguments are concacenated.

Note that the text must be Perl strings.

$info = $hb->shaper()

Performs the shaping. Upon completion an array of hashes is returned as described above.

SEE ALSO

Text::Layout

HarfBuzz website and documentation: https://harfbuzz.github.io/index.html.

DEPENDENCIES

This module requires the HarfBuzz library to be installed on your system.

BUGS AND DEFICIENCIES

It probably leaks memory. We'll see.

SUPPORT AND DOCUMENTATION

Development of this module takes place on GitHub: https://github.com/sciurius/perl-HarfBuzz-Shaper.

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

    perldoc HarfBuzz::Shaper

Please report any bugs or feature requests using the issue tracker on GitHub.

HarfBuzz website and documentation: https://harfbuzz.github.io/index.html.

COPYRIGHT AND LICENCE

Copyright (C) 2020 by Johan Vromans

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