blib/lib/Graphics/Primitive/Font.pm

filter: Statementstmt 82.9% 34 / 41 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 76.9% 40 / 52 SCAR 14.4
CC
4
Cov
76%
derive
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.2
« blib/lib/Graphics/Primitive/Oriented.pm ↑ Summary blib/lib/Graphics/Primitive/Insets.pm »
1 package Graphics::Primitive::Font;
2 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use MooseX::Storage;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 with 'MooseX::Clone';
7 2 with Storage (format => 'JSON', io => 'File');
8  
9 2 enum 'Graphics::Primitive::Font::AntialiasModes' => [
10 qw(default none gray subpixel)
11 ];
12 2 enum 'Graphics::Primitive::Font::HintMetrics' => [
13 'default', 'off', 'on'
14 ];
15 2 enum 'Graphics::Primitive::Font::HintStyles' => [
16 'default', 'none', 'slight', 'medium', 'full'
17 ];
18 2 enum 'Graphics::Primitive::Font::Slants' => [
19 'normal', 'italic', 'oblique'
20 ];
21 2 enum 'Graphics::Primitive::Font::SubpixelOrders' => [
22 qw(default rgb bgr vrgb vbgr)
23 ];
24 2 enum 'Graphics::Primitive::Font::Variants' => [
25 'normal', 'small-caps'
26 ];
27 2 enum 'Graphics::Primitive::Font::Weights' => [
28 'normal', 'bold'
29 ];
30  
31 2 has 'antialias_mode' => (
32 is => 'rw',
33 isa => 'Graphics::Primitive::Font::AntialiasModes',
34 default => 'default'
35 );
36 2 has 'family' => (
37 is => 'rw',
38 isa => 'Str',
39 default => 'Sans'
40 );
41 2 has 'hint_metrics' => (
42 is => 'rw',
43 isa => 'Graphics::Primitive::Font::HintMetrics',
44 default => 'default'
45 );
46 2 has 'hint_style' => (
47 is => 'rw',
48 isa => 'Graphics::Primitive::Font::HintStyles',
49 default => 'default'
50 );
51 has 'size' => (
52 is => 'rw',
53 isa => 'Num',
54 1 ▶ default => sub { 12 }
Subroutine __ANON__: called CC=1 SCAR=0.0
55 2 );
56 2 has 'slant' => (
57 is => 'rw',
58 isa => 'Graphics::Primitive::Font::Slants',
59 default => 'normal'
60 );
61 2 has 'subpixel_order' => (
62 is => 'rw',
63 isa => 'Graphics::Primitive::Font::SubpixelOrders',
64 default => 'default'
65 );
66 2 has 'variant' => (
67 is => 'rw',
68 isa => 'Graphics::Primitive::Font::Variants',
69 default => 'normal'
70 );
71 2 has 'weight' => (
72 is => 'rw',
73 isa => 'Graphics::Primitive::Font::Weights',
74 default => 'normal'
75 );
76  
77 2 __PACKAGE__->meta->add_method('face' => __PACKAGE__->can('family'));
78  
79 sub derive {
80 0 ▶ my ($self, $args) = @_;
Subroutine derive: not called CC=4 SCAR=30.0
Pod documented
81  
82 0 ▶ return unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
83 0 my $new = $self->clone;
84 0 foreach my $key (keys %{ $args }) {
85 0 ▶ $new->$key($args->{$key}) if($new->can($key));
Branch: 1 branch
BranchTrueFalseTotal
if $new->can($key) 0 0 0
86 }
87 0 return $new;
88 }
89  
90 2 __PACKAGE__->meta->make_immutable;
91  
92 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
93 2 1;
94 __END__
95 =head1 NAME
96  
97 Graphics::Primitive::Font - Text styling
98  
99 =head1 DESCRIPTION
100  
101 Graphics::Primitive::Font represents the various options that are available
102 when rendering text. The options here may or may not have an effect on your
103 rendering. They represent a cross-section of the features provided by
104 various drivers. Setting them should B<not> break anything, but may not
105 have an effect if the driver doesn't understand the option.
106  
107 =head1 SYNOPSIS
108  
109 use Graphics::Primitive::Font;
110  
111 my $font = Graphics::Primitive::Font->new({
112 family => 'Arial',
113 size => 12,
114 slant => 'normal'
115 });
116  
117 =head1 METHODS
118  
119 =head2 Constructor
120  
121 =over 4
122  
123 =back
124  
125 =head1 Attributes
126  
127 =head2 antialias_modes
128  
129 Set the antialiasing mode for this font. Possible values are default, none,
130 gray and subpixel.
131  
132 =head2 family
133  
134 Set this font's family.
135  
136 =head2 hint_metrics
137  
138 Controls whether to hint font metrics. Hinting means quantizing them so that
139 they are integer values in device space. This improves the consistency of
140 letter and line spacing, however it also means that text will be laid out
141 differently at different zoom factors. May not be supported by all drivers.
142  
143 =head2 hint_style
144  
145 Set the the type of hinting to do on font outlines. Hinting is the process of
146 fitting outlines to the pixel grid in order to improve the appearance of the
147 result. Since hinting outlines involves distorting them, it also reduces the
148 faithfulness to the original outline shapes. Not all of the outline hinting
149 styles are supported by all drivers. Options are default, none, slight,
150 medium and full.
151  
152 =head2 size
153  
154 Set/Get the size of this font.
155  
156 =head2 slant
157  
158 Set/Get the slant of this font. Valid values are normal, italic and oblique.
159  
160 =head2 subpixel_order
161  
162 Set the order of color elements within each pixel on the display device when
163 rendering with subpixel antialiasing. Value values are default, rgb, bgr,
164 vrgb and vbgr.
165  
166 =head2 variant
167  
168 Set/Get the variant of this font. Valid values are normal or small-caps.
169  
170 =head2 weight
171  
172 Set/Get the weight of this font. Value valies are normal and bold.
173  
174 =head1 METHODS
175  
176 =head2 new
177  
178 Creates a new Graphics::Primitive::Font.
179  
180 =head2 derive
181  
182 Clone this font but change one or more of it's attributes by passing in a
183 hashref of options:
184  
185 my $new = $font->derive({ attr => $newvalue });
186
187 The returned font will be identical to the cloned one, save the attributes
188 specified.
189  
190 =head1 AUTHOR
191  
192 Cory Watson, C<< <gphat@cpan.org> >>
193  
194 =head1 COPYRIGHT & LICENSE
195  
196 Copyright 2008-2010 by Cory G Watson.
197  
198 This program is free software; you can redistribute it and/or modify it
199 under the same terms as Perl itself.
« blib/lib/Graphics/Primitive/Oriented.pm ↑ Summary blib/lib/Graphics/Primitive/Insets.pm »