Debian Codegraph @

contrib/perl/lib/Text/Gr2.pm

raw
1 # SPDX-License-Identifier: Artistic-1.0-Perl
2 # Copyright 2011, Simon Cozens & SIL International, All rights reserved.
3 package Text::Gr2;
4 use Text::Gr2::Face;
5 use Text::Gr2::Font;
6 use Text::Gr2::FeatureRef;
7 use Text::Gr2::FeatureVal;
8 use Text::Gr2::CharInfo;
9 use Text::Gr2::Segment;
10 use Text::Gr2::Slot;
11
12 use warnings;
13 use strict;
14
15 =head1 NAME
16
17 Text::Gr2 - Interface to SIL's Graphite2 rendering engine
18
19 =head1 VERSION
20
21 Version 0.01
22
23 =cut
24
25 our $VERSION = '0.01';
26
27 require XSLoader;
28 XSLoader::load('Text::Gr2', $VERSION);
29
30 sub _decode { my $c = pack("N*",$_[0]); $c=~/^[[:print:]]+/ ? $c : $_[0] }
31
32 =head1 SYNOPSIS
33
34 use Text::Gr2;
35 my $face = Text::Gr2::Face->open($fontfile, cache_size => 1000);
36 my $sized_font = $face->make_font($dpi*$pointsize/72);
37 my $seg = $sized_font->segment($face, $text);
38 my @chars = $seg->cinfos;
39 for ($seg->slots) {
40 layout_text($_->origin_X, $_->origin_Y, $chars[$c++]->unicode_char);
41 }
42
43 =head1 WHAT IS GRAPHITE?
44
45 Graphite is a I<back-end> rendering engine for complex, non-Roman
46 scripts. It will not lay out text for you. It I<will> help you to know
47 where characters in a string should be positioned - how wide accents
48 should be and where they go, what alternate character forms to use, and
49 so on.
50
51 B<This requires Graphite-enabled fonts>. Most fonts aren't; right now,
52 only a few fonts from the Graphite project itself are. See
53 http://graphite.sil.org for more details.
54
55 =head1 FUNCTIONS
56
57 For most purposes, the entry point to this API is through
58 C<< Text::Gr2::Face->open >>. The C<Text::Gr2> module itself
59 only provides two functions, for logging:
60
61 =head2 start_logging
62
63 Text::Gr2->start_logging($face, $fname);
64
65 =head2 stop_logging
66
67 END { Text::Gr2->stop_logging($face) }
68
69 Finishes writing the log for the given face.
70
71 =head1 INTERNAL METHODS
72
73 =head2 str_to_tag
74
75 =head2 tag_to_str
76
77 Convert between language/feature tags and ID numbers. This is
78 effectively done with a C<pack("N*")>.
79
80 =head1 SEE ALSO
81
82 L<Text::Gr2::Face>, L<Text::Gr2::FeatureRef>,
83 L<Text::Gr2::FeatureVal>, L<Text::Gr2::Font>,
84 L<Text::Gr2::Segment>
85
86 http://graphite.sil.org/
87
88 =cut
89
90 1; # End of Text::Gr2
91
92 __END__
93
94 =begin copyright
95
96 SPDX-License-Identifier: Artistic-1.0-Perl
97 Copyright 2011, Simon Cozens & SIL International, All rights reserved.
98
99 Author: Simon Cozens <[email protected]>
100
101 =end copyright