1HarfBuzz::Shaper(3)   User Contributed Perl Documentation  HarfBuzz::Shaper(3)
2
3
4

NAME

6       HarfBuzz::Shaper - Use HarfBuzz for text shaping
7

SYNOPSIS

9           use HarfBuzz::Shaper;
10           my $hb = HarfBuzz::Shaper->new;
11           $hb->set_font('LiberationSans.ttf');
12           $hb->set_size(36);
13           $hb->set_text("Hello!");
14           my $info = $hb->shaper;
15
16       The result is an array of hashes, one element for each glyph to be
17       typeset.
18

DESCRIPTION

20       HarfBuzz::Shaper is a perl module that provides access to a small
21       subset of the native HarfBuzz library.
22
23       The subset is suitable for typesetting programs that need to deal with
24       complex languages like Devanagari.
25
26       This module is intended to be used with module Text::Layout. Feel free
27       to (ab)use it for other purposes.
28
29       Following the above example, the returned info is an array of hashes,
30       one element for each glyph to be typeset. The hash contains the
31       following items:
32
33           ax:   horizontal advance
34           ay:   vertical advance
35           dx:   horizontal offset
36           dy:   vertical offset
37           g:    glyph index in font (CId)
38           name: glyph name
39
40       Note that the number of glyphs does not necessarily match the number of
41       input characters!
42

METHODS

44   $hb = HarfBuzz::Shaper->new( [ options ] )
45       Creates a new shaper object.
46
47       Options:
48
49       ·   font = > font filename
50
51       ·   size = > text size
52
53   $hb->set_font( font filename [ , size ] )
54       Explicit way to set the font (and, optionally, the size) used for
55       shaping.
56
57       The font must be a TrueType or OpenType font. Font information is
58       cached internally, after the first call subsequent calls with the same
59       font filename are very fast.
60
61   $hb->set_size( size )
62       Explicit way to set the font size used for shaping.
63
64       Note that the font size will in general affect details of the
65       appearance, A 5 point fontsize magnified 10 times is not identical to
66       50 point font size.
67
68   $hb->set_text( text [ , ... ] )
69       Set the text to shape. Multiple arguments are concatenated.
70
71       Note that the text must be Perl strings.
72
73   $hb->set_features( feat [ , ... ] )
74       Sets persistent features for shaping. Features are strings as described
75       in
76       <https://harfbuzz.github.io/harfbuzz-hb-common.html#hb-feature-from-string>.
77
78       Multiple feature strings may be supplied.
79
80   $hb->add_features( feat [ , ... ] )
81       Just like set_features, but the specified features are added to the set
82       of persistent features.
83
84   $hb->set_language( lang )
85       Sets the language for shaping. lang must be a string containing a valid
86       BCP-47 language code.
87
88   $hb->get_language
89       Returns the language currently set for this shaper, as a string.
90
91   $info = $hb->shaper( [ ref to features ] )
92       Performs the shaping.
93
94       features is a reference to an array of feature strings. The features
95       will be added to the list of features already set with
96       set_features/add_features. If the first (or only) feature is "none" all
97       current features will be ignored and only subsequent features are taken
98       into account. Changes apply to this call only, the persistent set of
99       featutes is not modified.
100
101       Upon completion an array of hashes is returned with one element for
102       each glyph to be rendered.
103
104       The hash contains the following items:
105
106           ax:   horizontal advance
107           ay:   vertical advance
108           dx:   horizontal offset
109           dy:   vertical offset
110           g:    glyph index in font (CId)
111           name: glyph name
112
113       Note that the number of glyphs does not necessarily match the number of
114       input characters!
115

SEE ALSO

117       Text::Layout
118
119       HarfBuzz website and documentation:
120       <https://harfbuzz.github.io/index.html>.
121

BUGS AND DEFICIENCIES

123       It probably leaks memory. We'll see.
124

SUPPORT AND DOCUMENTATION

126       Development of this module takes place on GitHub:
127       https://github.com/sciurius/perl-HarfBuzz-Shaper.
128
129       You can find documentation for this module with the perldoc command.
130
131           perldoc HarfBuzz::Shaper
132
133       Please report any bugs or feature requests using the issue tracker on
134       GitHub.
135
136       HarfBuzz website and documentation:
137       <https://harfbuzz.github.io/index.html>.
138
140       Copyright (C) 2020 by Johan Vromans
141
142       This library is free software; you can redistribute it and/or modify it
143       under the same terms as Perl itself.
144
145
146
147perl v5.30.1                      2020-03-03               HarfBuzz::Shaper(3)
Impressum