Debian Codegraph @

contrib/perl/lib/Text/Gr2/Face.pm

raw
1 # SPDX-License-Identifier: Artistic-1.0-Perl
2 # Copyright (C) 2011 Simon Cozens
3 package Text::Gr2::Face;
4
5 =head1 NAME
6
7 Text::Gr2::Face - Open and manipulate Graphite font files
8
9 =head1 METHODS
10
11 =head2 open
12
13 Text::Gr2::Face->open( $font, %options )
14
15 This is the main entry point to Graphite2. It expects the full pathname
16 of a Graphite-enabled TrueType font. (Note: only about three or four fonts
17 right now are Graphite enabled.)
18
19 =cut
20
21 sub open {
22 my ($self, $ff, %opts) = @_;
23 my $opt = 0;
24 $opt |= 1 if $opts{dumb_rendering};
25 $opt |= 2 if $opts{preload_glyphs};
26 $opt |= 4 if $opts{cache_cmap};
27
28 if ($opts{cache_size}) {
29 $self->make_file_face_with_seg_cache($ff,$opts{cache_size},$opt);
30 } else {
31 $self->make_file_face($ff,$opt);
32 }
33 }
34
35 =head2 features
36
37 Returns a list of L<Gr2::FeatureRef> objects representing features
38 that this font possesses.
39
40 =cut
41
42 sub features {
43 my $self = shift;
44 map { $self->fref($_) } (0..$self->n_fref() -1)
45 }
46
47 =head2 languages
48
49 Returns a list of language codes that the font services.
50
51 =cut
52
53 sub languages {
54 my $self = shift;
55 map { Text::Gr2::_decode($self->lang_by_index($_)) } 0..$self->n_languages-1;
56 }
57
58 =head2 make_font
59
60 $font = $face->make_font($dpi*$pointsize/72)
61
62 Scales a face to a given font size, by point size/DPI.
63
64 =head1 INTERNAL METHODS
65
66 =head2 featureval_for_lang
67
68 Get feature values for a given language or default
69
70 =head2 n_fref
71
72 Return the number of feature references in this face.
73
74 =head2 fref
75
76 Return a given feature reference by index.
77
78 =head2 n_languages
79
80 Return the number of languages that this face supports.
81
82 =head2 lang_by_index
83
84 Return a given language code by index.
85
86 =head2 find_fref
87
88 Get feature reference for a given feature id from a face
89
90 =head2 make_file_face
91
92 =head2 make_file_face_with_seg_cache
93
94 Low-level methods to create a face from a font file.
95
96 =head2 n_glyphs
97
98 Return the number of glyphs in this face.
99
100 =cut
101
102 1;