| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Amuse::Compile::Fonts::File; |
|
2
|
62
|
|
|
62
|
|
67803
|
use strict; |
|
|
62
|
|
|
|
|
146
|
|
|
|
62
|
|
|
|
|
1938
|
|
|
3
|
62
|
|
|
62
|
|
377
|
use warnings; |
|
|
62
|
|
|
|
|
148
|
|
|
|
62
|
|
|
|
|
1515
|
|
|
4
|
62
|
|
|
62
|
|
334
|
use utf8; |
|
|
62
|
|
|
|
|
138
|
|
|
|
62
|
|
|
|
|
363
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
62
|
|
|
62
|
|
1917
|
use Moo; |
|
|
62
|
|
|
|
|
11768
|
|
|
|
62
|
|
|
|
|
368
|
|
|
7
|
62
|
|
|
62
|
|
22942
|
use File::Basename qw//; |
|
|
62
|
|
|
|
|
180
|
|
|
|
62
|
|
|
|
|
1563
|
|
|
8
|
62
|
|
|
62
|
|
482
|
use File::Spec; |
|
|
62
|
|
|
|
|
187
|
|
|
|
62
|
|
|
|
|
2158
|
|
|
9
|
62
|
|
|
62
|
|
1026
|
use Types::Standard qw/Maybe Str Enum ArrayRef/; |
|
|
62
|
|
|
|
|
79125
|
|
|
|
62
|
|
|
|
|
478
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Text::Amuse::Compile::Fonts::File - font file object |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 ACCESSORS |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head2 file |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
The filename. Required |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 shape |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
The shape of the font. Must be regular, bold, italic or bolditalic. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 format |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Built lazily from the filename, validating it and crashing if it's not |
|
28
|
|
|
|
|
|
|
otf or ttf. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 mimetype |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Built lazily from the filename, validating it and crashing if it's not |
|
33
|
|
|
|
|
|
|
otf or ttf |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 basename |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
The basename of the font, includin the extension. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 basename_and_ext |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Alias for C |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 extension |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
The file extension, including the dot. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 dirname |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
The directory, including the trailing slash. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 css_font_weight |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
C or C depending on the shape |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 css_font_style |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
C or C depending on the shape |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has file => (is => 'ro', |
|
62
|
|
|
|
|
|
|
required => 1, |
|
63
|
|
|
|
|
|
|
isa => sub { |
|
64
|
|
|
|
|
|
|
die "$_[0] is not a font file" |
|
65
|
|
|
|
|
|
|
unless $_[0] && -f $_[0] && $_[0] =~ m/\.(ttf|otf)\z/i |
|
66
|
|
|
|
|
|
|
}); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
has shape => (is => 'ro', |
|
69
|
|
|
|
|
|
|
required => 1, |
|
70
|
|
|
|
|
|
|
isa => Enum[qw/regular bold italic bolditalic/]); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has format => (is => 'lazy', |
|
73
|
|
|
|
|
|
|
isa => Str); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has mimetype => (is => 'lazy', |
|
76
|
|
|
|
|
|
|
isa => Str); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has _parsed_path => (is => 'lazy', |
|
79
|
|
|
|
|
|
|
isa => ArrayRef); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _build__parsed_path { |
|
82
|
104
|
|
|
104
|
|
898
|
my $self = shift; |
|
83
|
104
|
50
|
|
|
|
356
|
if (my $file = $self->file) { |
|
84
|
104
|
|
|
|
|
3708
|
my ($filename, $dirs, $suffix) = File::Basename::fileparse(File::Spec->rel2abs($file), |
|
85
|
|
|
|
|
|
|
qr/\.(ttf|otf)\z/i); |
|
86
|
104
|
|
|
|
|
2204
|
return [ $filename . $suffix , $dirs, $suffix ]; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
else { |
|
89
|
0
|
|
|
|
|
0
|
return [ '', '', '' ]; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# my ($filename, $dirs, $suffix) = fileparse($path, @suffixes); |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub basename { |
|
96
|
193
|
|
|
193
|
1
|
8834
|
shift->_parsed_path->[0]; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub basename_and_ext { |
|
100
|
101
|
|
|
101
|
1
|
2035
|
shift->_parsed_path->[0]; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub dirname { |
|
104
|
35
|
|
|
35
|
1
|
4864
|
shift->_parsed_path->[1]; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub extension { |
|
108
|
65
|
|
|
65
|
1
|
1815
|
shift->_parsed_path->[2]; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub _build_format { |
|
112
|
64
|
|
|
64
|
|
11412
|
my $self = shift; |
|
113
|
64
|
50
|
|
|
|
152
|
if (my $ext = $self->extension) { |
|
114
|
64
|
|
|
|
|
917
|
my %map = ( |
|
115
|
|
|
|
|
|
|
'.woff' => 'woff', |
|
116
|
|
|
|
|
|
|
'.ttf' => 'truetype', |
|
117
|
|
|
|
|
|
|
'.otf' => 'opentype', |
|
118
|
|
|
|
|
|
|
); |
|
119
|
64
|
50
|
|
|
|
193
|
if (my $type = $map{lc($ext)}) { |
|
120
|
64
|
|
|
|
|
1131
|
return $type; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
} |
|
123
|
0
|
|
|
|
|
0
|
die "Bad file format without extension " . $self->file; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub _build_mimetype { |
|
127
|
64
|
|
|
64
|
|
11808
|
my $self = shift; |
|
128
|
64
|
50
|
|
|
|
1069
|
if (my $format = $self->format) { |
|
129
|
64
|
|
|
|
|
1410
|
my %map = ( |
|
130
|
|
|
|
|
|
|
woff => 'application/font-woff', |
|
131
|
|
|
|
|
|
|
truetype => 'application/x-font-ttf', |
|
132
|
|
|
|
|
|
|
opentype => 'application/x-font-opentype', |
|
133
|
|
|
|
|
|
|
); |
|
134
|
64
|
|
|
|
|
1099
|
return $map{$format}; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
0
|
|
|
|
|
0
|
return; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub css_font_weight { |
|
140
|
48
|
|
|
48
|
1
|
6617
|
my $self = shift; |
|
141
|
48
|
|
|
|
|
164
|
my %map = ( |
|
142
|
|
|
|
|
|
|
regular => "normal", |
|
143
|
|
|
|
|
|
|
bold => "bold", |
|
144
|
|
|
|
|
|
|
italic => "normal", |
|
145
|
|
|
|
|
|
|
bolditalic => "bold", |
|
146
|
|
|
|
|
|
|
); |
|
147
|
48
|
|
|
|
|
239
|
return $map{$self->shape}; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub css_font_style { |
|
151
|
48
|
|
|
48
|
1
|
1570
|
my $self = shift; |
|
152
|
48
|
|
|
|
|
142
|
my %map = ( |
|
153
|
|
|
|
|
|
|
regular => "normal", |
|
154
|
|
|
|
|
|
|
bold => "normal", |
|
155
|
|
|
|
|
|
|
italic => "italic", |
|
156
|
|
|
|
|
|
|
bolditalic => "italic", |
|
157
|
|
|
|
|
|
|
); |
|
158
|
48
|
|
|
|
|
164
|
return $map{$self->shape}; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |