| 1 | package Font::Fontconfig; | ||||||||||||
| 2 | |||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 4 | ▶ | use Font::Fontconfig::Pattern; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 4 | our $VERSION = '0.01'; | |||||||||||
| 9 | |||||||||||||
| 10 | # list | ||||||||||||
| 11 | # | ||||||||||||
| 12 | # Returns a list of `Font::Fontconfig::Pattern`s that match the search criteria, | ||||||||||||
| 13 | # or all installed ones if no criteria are given | ||||||||||||
| 14 | # | ||||||||||||
| 15 | 4 | ▶ | sub list { | ||||||||||
|
Subroutine
list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 16 | 4 | my $class = shift; | |||||||||||
| 17 | 4 | my @options = @_; | |||||||||||
| 18 | |||||||||||||
| 19 | 4 | my @results = _execute_list( @options ); | |||||||||||
| 20 | |||||||||||||
| 21 | return map { | ||||||||||||
| 22 | 4 | Font::Fontconfig::Pattern->new_from_string( $_ ) | |||||||||||
| 23 | } @results | ||||||||||||
| 24 | } | ||||||||||||
| 25 | |||||||||||||
| 26 | |||||||||||||
| 27 | |||||||||||||
| 28 | 4 | ▶ | sub _execute_list { | ||||||||||
|
Subroutine
_execute_list: called CC=1 SCAR=0.0
| |||||||||||||
| 29 | 4 | my @options = @_; | |||||||||||
| 30 | |||||||||||||
| 31 | 4 | my $filters = _list_filters( \@options ); | |||||||||||
| 32 | 4 | my $include = _list_include( \@options ); | |||||||||||
| 33 | |||||||||||||
| 34 | 4 | my $command = | |||||||||||
| 35 | join( q{ }, 'fc-list', $filters ) | ||||||||||||
| 36 | . | ||||||||||||
| 37 | q{ : } | ||||||||||||
| 38 | . | ||||||||||||
| 39 | join( q{ }, @$include ) | ||||||||||||
| 40 | ; | ||||||||||||
| 41 | |||||||||||||
| 42 | 4 | my @results = _execute( $command ); | |||||||||||
| 43 | |||||||||||||
| 44 | return @results | ||||||||||||
| 45 | 4 | } | |||||||||||
| 46 | |||||||||||||
| 47 | |||||||||||||
| 48 | |||||||||||||
| 49 | 0 | ▶ | sub _execute { | ||||||||||
|
Subroutine
_execute: not called CC=1 SCAR=6.9
| |||||||||||||
| 50 | 0 | my $command = shift; | |||||||||||
| 51 | |||||||||||||
| 52 | 0 | my @results = `$command`; | |||||||||||
| 53 | |||||||||||||
| 54 | return @results | ||||||||||||
| 55 | 0 | } | |||||||||||
| 56 | |||||||||||||
| 57 | |||||||||||||
| 58 | |||||||||||||
| 59 | 4 | ▶ | sub _list_filters { | ||||||||||
|
Subroutine
_list_filters: called CC=1 SCAR=0.0
| |||||||||||||
| 60 | 4 | my $options = shift; | |||||||||||
| 61 | |||||||||||||
| 62 | 4 | my $font_family = _shell_escape(shift @$options ); | |||||||||||
| 63 | |||||||||||||
| 64 | 4 | return $font_family | |||||||||||
| 65 | } | ||||||||||||
| 66 | |||||||||||||
| 67 | |||||||||||||
| 68 | |||||||||||||
| 69 | 4 | ▶ | sub _list_include { | ||||||||||
|
Subroutine
_list_include: called CC=1 SCAR=0.0
| |||||||||||||
| 70 | 4 | return [ @Font::Fontconfig::Pattern::_internal_attributes ] | |||||||||||
| 71 | } | ||||||||||||
| 72 | |||||||||||||
| 73 | |||||||||||||
| 74 | |||||||||||||
| 75 | 4 | ▶ | sub _shell_escape { | ||||||||||
|
Subroutine
_shell_escape: called CC=2 SCAR=6.9
| |||||||||||||
| 76 | 4 | ▶ | my $text = shift // ''; | ||||||||||
|
Condition100%2/2
shift() // ""
MC/DC100%1/1
shift() // ""
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 77 | |||||||||||||
| 78 | 4 | $text =~ s/ /\\ /g; | |||||||||||
| 79 | |||||||||||||
| 80 | 4 | return $text | |||||||||||
| 81 | } | ||||||||||||
| 82 | |||||||||||||
| 83 | |||||||||||||
| 84 | |||||||||||||
| 85 | 4 | 1; | |||||||||||