The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Font::TTF::OpenTypeLigatures - Transforms OpenType glyphs based on GSUB tables

VERSION

Version 0.01

SYNOPSIS

    use Font::TTF::OpenTypeLigatures;

    my $foo = Font::TTF::OpenTypeLigatures->new($fontfile, %options);
    @glyph_ids = $foo->substitute(@glyph_ids);
    ...

DESCRIPTION

This module is a building block for fine typography systems implemented in Perl. It reads the GSUB table of OpenType fonts to transform glyphs based on selected OpenType features. The most common use of this is to implement ligatures, but OpenType supports a variety of features such as alternates, old-style numbers, non-Roman contextual substitutions and so on.

METHODS

new

The constructor takes a font file path and a set of options. The options will determine which substitutions are performed. The default options will substitute ligatures in Latin-script texts. You may supply:

script

Four-letter code for the script in which your text is written. (See http://www.microsoft.com/typography/developers/opentype/scripttags.aspx for a list of these.)

lang

Three-letter language tag. If this is not given, or there are no special features for this language, the default language for the script is used.

features

This is a regular expression matching the features you want to support. The default is liga.

If there are any problems, the constructor will die with an error message.

substitute

This performs contextual substitution on a list of numeric glyph IDs, returning a substituted list.

stream

    my $substitutor = $self->stream( \&output );
    for (@glyphids) { $substitutor->($_) }

This creates a stateful closure subroutine which acts as a glyph-by-glyph substitution stream. Once a substitution is processed, or no substitution is needed for the glyph ID stream, the closure calls the provided output subroutine.

This allows you to interpose the stream in between an input and output mechanism, and not worry about maintaining ligature substitution state yourself.

Passing -1 to the substitutor drains the stream.

AUTHOR

Simon Cozens, <simon at cpan.org>

BUGS

Please report any bugs or feature requests to bug-font-ttf-opentypeligatures at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Font-TTF-OpenTypeLigatures. 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 Font::TTF::OpenTypeLigatures

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2011 Simon Cozens.

This program is released under the following license: Perl