line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Font::Selector; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
361668
|
use strict; |
|
3
|
|
|
|
|
19
|
|
|
3
|
|
|
|
|
85
|
|
4
|
3
|
|
|
3
|
|
19
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
133
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
1238
|
use Font::Fontconfig; |
|
3
|
|
|
|
|
6920
|
|
|
3
|
|
|
|
|
101
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
22
|
use List::Util qw/all/; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
276
|
|
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
21
|
use Exporter 'import'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
567
|
|
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
|
1464
|
my $class = shift; |
23
|
4
|
|
|
|
|
5
|
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
|
|
7
|
my $string = shift; |
45
|
5
|
|
|
|
|
8
|
my $fontname = shift; |
46
|
|
|
|
|
|
|
|
47
|
5
|
|
|
|
|
15
|
my ($fc_pattern) = Font::Fontconfig->list( $fontname ); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
return !undef if |
50
|
|
|
|
|
|
|
defined $fc_pattern |
51
|
|
|
|
|
|
|
and |
52
|
5
|
100
|
66
|
6
|
|
56
|
all { $fc_pattern->contains_codepoint( ord $_ ) } split //, $string |
|
6
|
|
|
|
|
168
|
|
53
|
|
|
|
|
|
|
; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |