line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Amuse::Compile::Fonts::Family; |
2
|
61
|
|
|
61
|
|
393
|
use utf8; |
|
61
|
|
|
|
|
136
|
|
|
61
|
|
|
|
|
355
|
|
3
|
61
|
|
|
61
|
|
1766
|
use strict; |
|
61
|
|
|
|
|
115
|
|
|
61
|
|
|
|
|
1191
|
|
4
|
61
|
|
|
61
|
|
270
|
use warnings; |
|
61
|
|
|
|
|
146
|
|
|
61
|
|
|
|
|
2154
|
|
5
|
61
|
|
|
61
|
|
327
|
use Types::Standard qw/Str Enum StrMatch InstanceOf Bool HashRef ArrayRef/; |
|
61
|
|
|
|
|
121
|
|
|
61
|
|
|
|
|
455
|
|
6
|
61
|
|
|
61
|
|
63245
|
use Moo; |
|
61
|
|
|
|
|
26695
|
|
|
61
|
|
|
|
|
346
|
|
7
|
61
|
|
|
61
|
|
22596
|
use Text::Amuse::Utils; |
|
61
|
|
|
|
|
3369
|
|
|
61
|
|
|
|
|
54292
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Text::Amuse::Compile::Fonts::Family - font family object |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 ACCESSORS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head2 name |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
The font family name. Required. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 desc |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
The font family description. Arbitrary string. Required. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 type |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
The font type: must be serif, sans or mono. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 FONT FILES |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
These accessors aren't strictly required. If provided, they should be |
30
|
|
|
|
|
|
|
an instance of L. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 regular |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 italic |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 bold |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 bolditalic |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 languages |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
An optional arrayref of language codes. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 METHODS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 has_files |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Return true if all the 4 font slots are filled. This means we know the |
49
|
|
|
|
|
|
|
physical location of the files, not just its name. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 is_sans |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Return true if the family is a sans font |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 is_mono |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Return true if the family is a mono font |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 is_serif |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Return true if the family is a serif font |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 font_files |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Return an arrayref with the four L |
66
|
|
|
|
|
|
|
objects. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 language_names |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
An arrayref with the C codes mapped to their babel equivalent. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 has_languages |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Return true if the font family has languages set. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 for_babel_language($babel_lang) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 for_language_code($iso_code) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Return true if the family has the given language set (babel and iso version) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 babel_font_name |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 babel_font_options |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
has name => (is => 'ro', |
90
|
|
|
|
|
|
|
isa => StrMatch[ qr{\A[a-zA-Z0-9 ]+\z} ], |
91
|
|
|
|
|
|
|
required => 1); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
has desc => (is => 'ro', |
94
|
|
|
|
|
|
|
isa => Str, |
95
|
|
|
|
|
|
|
required => 1); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
has type => (is => 'ro', |
98
|
|
|
|
|
|
|
required => 1, |
99
|
|
|
|
|
|
|
isa => Enum[qw/serif sans mono/]); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
has regular => (is => 'ro', isa => InstanceOf[qw/Text::Amuse::Compile::Fonts::File/]); |
102
|
|
|
|
|
|
|
has italic => (is => 'ro', isa => InstanceOf[qw/Text::Amuse::Compile::Fonts::File/]); |
103
|
|
|
|
|
|
|
has bold => (is => 'ro', isa => InstanceOf[qw/Text::Amuse::Compile::Fonts::File/]); |
104
|
|
|
|
|
|
|
has bolditalic => (is => 'ro', isa => InstanceOf[qw/Text::Amuse::Compile::Fonts::File/]); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
has has_files => (is => 'lazy', isa => Bool); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _build_has_files { |
109
|
653
|
|
|
653
|
|
18822
|
my $self = shift; |
110
|
653
|
50
|
100
|
|
|
2395
|
if ($self->regular && |
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
111
|
|
|
|
|
|
|
$self->italic && |
112
|
|
|
|
|
|
|
$self->bold && |
113
|
|
|
|
|
|
|
$self->bolditalic) { |
114
|
27
|
|
|
|
|
353
|
return 1; |
115
|
|
|
|
|
|
|
} |
116
|
626
|
|
|
|
|
7823
|
return 0; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
has languages => (is => 'ro', isa => ArrayRef, default => sub { [] }); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
has language_names => (is => 'lazy', isa => ArrayRef); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub _build_language_names { |
124
|
10035
|
|
|
10035
|
|
62903
|
my $self = shift; |
125
|
10035
|
|
|
|
|
11470
|
return [ map { Text::Amuse::Utils::get_latex_lang($_) } @{ $self->languages } ]; |
|
1579
|
|
|
|
|
3832
|
|
|
10035
|
|
|
|
|
110141
|
|
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
has babel_font_args => (is => 'lazy', isa => HashRef); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub _build_babel_font_args { |
131
|
622
|
|
|
622
|
|
5644
|
my $self = shift; |
132
|
622
|
|
|
|
|
1659
|
my $name = $self->name; |
133
|
622
|
|
|
|
|
943
|
my @args; |
134
|
622
|
100
|
|
|
|
8564
|
if ($self->has_files) { |
135
|
22
|
|
|
|
|
220
|
my $regular; |
136
|
22
|
50
|
|
|
|
87
|
if ($self->regular->dirname =~ m/\A([A-Za-z0-9\.\/_-]+)\z/) { |
137
|
22
|
|
|
|
|
359
|
push @args, Path => $1; |
138
|
22
|
|
|
|
|
73
|
$name = $regular = $self->regular->basename_and_ext; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
else { |
141
|
0
|
|
|
|
|
0
|
warn $self->regular->dirname . " does not look like a path which can be embedded." . |
142
|
|
|
|
|
|
|
" Please make sure the fonts are installed in a standard TeX location\n"; |
143
|
|
|
|
|
|
|
} |
144
|
22
|
50
|
|
|
|
333
|
if ($regular) { |
145
|
22
|
|
|
|
|
80
|
my %shapes = ( |
146
|
|
|
|
|
|
|
bold => 'BoldFont', |
147
|
|
|
|
|
|
|
italic => 'ItalicFont', |
148
|
|
|
|
|
|
|
bolditalic => 'BoldItalicFont', |
149
|
|
|
|
|
|
|
); |
150
|
22
|
|
|
|
|
81
|
foreach my $shape (sort keys %shapes) { |
151
|
66
|
50
|
|
|
|
209
|
if (my $file = $self->$shape->basename_and_ext) { |
152
|
66
|
|
|
|
|
744
|
push @args, $shapes{$shape}, $file; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
return { |
158
|
622
|
|
|
|
|
19608
|
name => $name, |
159
|
|
|
|
|
|
|
opts => \@args, |
160
|
|
|
|
|
|
|
}; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub babel_font_name { |
164
|
838
|
|
|
838
|
1
|
11611
|
shift->babel_font_args->{name}; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub babel_font_options { |
168
|
838
|
|
|
838
|
1
|
2866
|
my ($self, @args) = @_; |
169
|
838
|
50
|
|
|
|
2174
|
die "args must come in pairs" if @args % 2; |
170
|
838
|
50
|
|
|
|
1325
|
push @args, @{$self->babel_font_args->{opts} || [] }; |
|
838
|
|
|
|
|
12936
|
|
171
|
838
|
|
|
|
|
14091
|
my @list; |
172
|
838
|
|
|
|
|
2784
|
while (my @pair = splice @args, 0, 2) { |
173
|
677
|
|
|
|
|
2648
|
push @list, join('=', @pair); |
174
|
|
|
|
|
|
|
} |
175
|
838
|
|
|
|
|
2935
|
return join(",%\n ", @list) |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub is_serif { |
179
|
24531
|
|
|
24531
|
1
|
45769
|
return shift->type eq 'serif'; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub is_mono { |
183
|
24531
|
|
|
24531
|
1
|
45105
|
return shift->type eq 'mono'; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub is_sans { |
187
|
24427
|
|
|
24427
|
1
|
45820
|
return shift->type eq 'sans'; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub font_files { |
191
|
24
|
|
|
24
|
1
|
4079
|
my $self = shift; |
192
|
24
|
|
|
|
|
131
|
return [ $self->regular, $self->italic, $self->bold, $self->bolditalic ]; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub has_languages { |
196
|
13277
|
|
|
13277
|
1
|
18431
|
return scalar(@{shift->language_names}); |
|
13277
|
|
|
|
|
171928
|
|
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub for_babel_language { |
200
|
2175
|
|
|
2175
|
1
|
191931
|
my ($self, $lang) = @_; |
201
|
2175
|
|
|
|
|
2990
|
return scalar(grep { $lang eq $_ } @{$self->language_names}); |
|
2163
|
|
|
|
|
19028
|
|
|
2175
|
|
|
|
|
28627
|
|
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub for_language_code { |
205
|
3
|
|
|
3
|
1
|
789
|
my ($self, $lang) = @_; |
206
|
3
|
|
|
|
|
4
|
return scalar(grep { $lang eq $_ } @{$self->languages}); |
|
4
|
|
|
|
|
18
|
|
|
3
|
|
|
|
|
13
|
|
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
1; |