line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Font::Selector; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
367243
|
use strict; |
|
3
|
|
|
|
|
19
|
|
|
3
|
|
|
|
|
86
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
139
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
1282
|
use Font::Fontconfig; |
|
3
|
|
|
|
|
7126
|
|
|
3
|
|
|
|
|
116
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
19
|
use List::Util qw/all/; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
287
|
|
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
23
|
use Exporter 'import'; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
600
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw/&grep_from_fontnames/; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# grep_from_fontnames |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
# This works on font-names, the litteral string, not on fontconfig patterns. |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
sub grep_from_fontnames { |
22
|
4
|
|
|
4
|
1
|
1599
|
my $class = shift; |
23
|
4
|
|
|
|
|
6
|
my $string = shift; |
24
|
4
|
|
|
|
|
9
|
my @fontnames = @_; |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
9
|
grep { _test_glyphs_for_fontname( $string, $_ ) } @fontnames |
|
5
|
|
|
|
|
89
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# _test_glyphs_for_fontname |
33
|
|
|
|
|
|
|
# |
34
|
|
|
|
|
|
|
# Hopefully we do the right thing here, further investigation might be needed to |
35
|
|
|
|
|
|
|
# check against Unicode libraries, where we can have canonical glyphs, combined |
36
|
|
|
|
|
|
|
# or split. |
37
|
|
|
|
|
|
|
# |
38
|
|
|
|
|
|
|
# There are opertunities to optimize the code: |
39
|
|
|
|
|
|
|
# - cache the font-pattern returned from Font::Fontconfig->list |
40
|
|
|
|
|
|
|
# - cache the results per fontname/glyph combination |
41
|
|
|
|
|
|
|
# - cache the results per fontname/string |
42
|
|
|
|
|
|
|
# |
43
|
|
|
|
|
|
|
sub _test_glyphs_for_fontname { |
44
|
5
|
|
|
5
|
|
6
|
my $string = shift; |
45
|
5
|
|
|
|
|
9
|
my $fontname = shift; |
46
|
|
|
|
|
|
|
|
47
|
5
|
|
|
|
|
16
|
my ($fc_pattern) = Font::Fontconfig->list( $fontname ); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
return !undef if |
50
|
|
|
|
|
|
|
defined $fc_pattern |
51
|
|
|
|
|
|
|
and |
52
|
5
|
100
|
66
|
6
|
|
58
|
all { $fc_pattern->contains_codepoint( ord $_ ) } split //, $string |
|
6
|
|
|
|
|
116
|
|
53
|
|
|
|
|
|
|
; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |