| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
######################################################################################### |
|
2
|
|
|
|
|
|
|
# Package HiPi::Graphics::BitmapFont |
|
3
|
|
|
|
|
|
|
# Description : Monochrome OLED Font |
|
4
|
|
|
|
|
|
|
# Copyright : Copyright (c) 2018 Mark Dootson |
|
5
|
|
|
|
|
|
|
# License : This is free software; you can redistribute it and/or modify it under |
|
6
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
|
7
|
|
|
|
|
|
|
######################################################################################### |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package HiPi::Graphics::BitmapFont; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
######################################################################################### |
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use parent qw( HiPi::Class ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
16
|
1
|
|
|
1
|
|
65
|
use UNIVERSAL::require; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
17
|
1
|
|
|
1
|
|
38
|
use Carp; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
104
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
__PACKAGE__->create_ro_accessors( qw( name char_height space_width gap_width |
|
20
|
|
|
|
|
|
|
symbols kerning class cols rows bytes |
|
21
|
|
|
|
|
|
|
line_spacing) ); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION ='0.81'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use constant { |
|
26
|
1
|
|
|
|
|
440
|
MONO_OLED_DEFAULT_FONT => 'Mono10', |
|
27
|
1
|
|
|
1
|
|
8
|
}; |
|
|
1
|
|
|
|
|
2
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $fonts = { |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Mono10 => undef, |
|
32
|
|
|
|
|
|
|
Mono12 => undef, |
|
33
|
|
|
|
|
|
|
Mono14 => undef, |
|
34
|
|
|
|
|
|
|
Mono15 => undef, |
|
35
|
|
|
|
|
|
|
Mono19 => undef, |
|
36
|
|
|
|
|
|
|
Mono20 => undef, |
|
37
|
|
|
|
|
|
|
Mono26 => undef, |
|
38
|
|
|
|
|
|
|
Mono33 => undef, |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
MonoExtended11 => undef, |
|
41
|
|
|
|
|
|
|
MonoExtended13 => undef, |
|
42
|
|
|
|
|
|
|
MonoExtended15 => undef, |
|
43
|
|
|
|
|
|
|
MonoExtended17 => undef, |
|
44
|
|
|
|
|
|
|
MonoExtended21 => undef, |
|
45
|
|
|
|
|
|
|
MonoExtended23 => undef, |
|
46
|
|
|
|
|
|
|
MonoExtended30 => undef, |
|
47
|
|
|
|
|
|
|
MonoExtended38 => undef, |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Sans10 => undef, |
|
50
|
|
|
|
|
|
|
Sans12 => undef, |
|
51
|
|
|
|
|
|
|
Sans14 => undef, |
|
52
|
|
|
|
|
|
|
Sans15 => undef, |
|
53
|
|
|
|
|
|
|
Sans19 => undef, |
|
54
|
|
|
|
|
|
|
Sans20 => undef, |
|
55
|
|
|
|
|
|
|
Sans26 => undef, |
|
56
|
|
|
|
|
|
|
Sans33 => undef, |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
SansExtended11 => undef, |
|
59
|
|
|
|
|
|
|
SansExtended13 => undef, |
|
60
|
|
|
|
|
|
|
SansExtended15 => undef, |
|
61
|
|
|
|
|
|
|
SansExtended17 => undef, |
|
62
|
|
|
|
|
|
|
SansExtended21 => undef, |
|
63
|
|
|
|
|
|
|
SansExtended23 => undef, |
|
64
|
|
|
|
|
|
|
SansExtended30 => undef, |
|
65
|
|
|
|
|
|
|
SansExtended38 => undef, |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Serif9 => undef, |
|
68
|
|
|
|
|
|
|
Serif11 => undef, |
|
69
|
|
|
|
|
|
|
Serif14 => undef, |
|
70
|
|
|
|
|
|
|
Serif15 => undef, |
|
71
|
|
|
|
|
|
|
Serif17 => undef, |
|
72
|
|
|
|
|
|
|
Serif21 => undef, |
|
73
|
|
|
|
|
|
|
Serif26 => undef, |
|
74
|
|
|
|
|
|
|
Serif33 => undef, |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
SerifExtended9 => undef, |
|
77
|
|
|
|
|
|
|
SerifExtended12 => undef, |
|
78
|
|
|
|
|
|
|
SerifExtended16 => undef, |
|
79
|
|
|
|
|
|
|
SerifExtended17 => undef, |
|
80
|
|
|
|
|
|
|
SerifExtended20 => undef, |
|
81
|
|
|
|
|
|
|
SerifExtended24 => undef, |
|
82
|
|
|
|
|
|
|
SerifExtended29 => undef, |
|
83
|
|
|
|
|
|
|
SerifExtended37 => undef, |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
SansEPD15 => undef, |
|
86
|
|
|
|
|
|
|
SansEPD19 => undef, |
|
87
|
|
|
|
|
|
|
SansEPD23 => undef, |
|
88
|
|
|
|
|
|
|
SansEPD28 => undef, |
|
89
|
|
|
|
|
|
|
SansEPD31 => undef, |
|
90
|
|
|
|
|
|
|
SansEPD38 => undef, |
|
91
|
|
|
|
|
|
|
SansEPD50 => undef, |
|
92
|
|
|
|
|
|
|
SansEPD76 => undef, |
|
93
|
|
|
|
|
|
|
SansEPD102 => undef, |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
MonoEPD15 => undef, |
|
96
|
|
|
|
|
|
|
MonoEPD19 => undef, |
|
97
|
|
|
|
|
|
|
MonoEPD23 => undef, |
|
98
|
|
|
|
|
|
|
MonoEPD28 => undef, |
|
99
|
|
|
|
|
|
|
MonoEPD31 => undef, |
|
100
|
|
|
|
|
|
|
MonoEPD38 => undef, |
|
101
|
|
|
|
|
|
|
MonoEPD50 => undef, |
|
102
|
|
|
|
|
|
|
MonoEPD76 => undef, |
|
103
|
|
|
|
|
|
|
MonoEPD102 => undef, |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
SerifEPD16 => undef, |
|
106
|
|
|
|
|
|
|
SerifEPD20 => undef, |
|
107
|
|
|
|
|
|
|
SerifEPD22 => undef, |
|
108
|
|
|
|
|
|
|
SerifEPD27 => undef, |
|
109
|
|
|
|
|
|
|
SerifEPD33 => undef, |
|
110
|
|
|
|
|
|
|
SerifEPD37 => undef, |
|
111
|
|
|
|
|
|
|
SerifEPD50 => undef, |
|
112
|
|
|
|
|
|
|
SerifEPD76 => undef, |
|
113
|
|
|
|
|
|
|
SerifEPD103 => undef, |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
}; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $fontaliases = { |
|
118
|
|
|
|
|
|
|
Serif10 => 'Serif9', |
|
119
|
|
|
|
|
|
|
Serif12 => 'Serif11', |
|
120
|
|
|
|
|
|
|
Serif19 => 'Serif17', |
|
121
|
|
|
|
|
|
|
SerifExtended11 => 'SerifExtended9', |
|
122
|
|
|
|
|
|
|
SerifExtended13 => 'SerifExtended12', |
|
123
|
|
|
|
|
|
|
SerifExtended15 => 'SerifExtended16', |
|
124
|
|
|
|
|
|
|
SerifExtended21 => 'SerifExtended20', |
|
125
|
|
|
|
|
|
|
SerifExtended23 => 'SerifExtended24', |
|
126
|
|
|
|
|
|
|
SerifExtended30 => 'SerifExtended29', |
|
127
|
|
|
|
|
|
|
SerifExtended38 => 'SerifExtended37', |
|
128
|
|
|
|
|
|
|
SerifEPD15 => 'SerifEPD16', |
|
129
|
|
|
|
|
|
|
SerifEPD19 => 'SerifEPD20', |
|
130
|
|
|
|
|
|
|
SerifEPD23 => 'SerifEPD22', |
|
131
|
|
|
|
|
|
|
SerifEPD28 => 'SerifEPD27', |
|
132
|
|
|
|
|
|
|
SerifEPD31 => 'SerifEPD33', |
|
133
|
|
|
|
|
|
|
SerifEPD38 => 'SerifEPD37', |
|
134
|
|
|
|
|
|
|
SerifEPD102 => 'SerifEPD103', |
|
135
|
|
|
|
|
|
|
}; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub new { |
|
138
|
0
|
|
|
0
|
0
|
|
my($class, %params ) = @_; |
|
139
|
0
|
|
0
|
|
|
|
$params{class} //= 'hipi_2'; |
|
140
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(%params); |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub get_font { |
|
144
|
0
|
|
|
0
|
0
|
|
my($ref, $fontname) = @_; |
|
145
|
0
|
|
0
|
|
|
|
$fontname ||= MONO_OLED_DEFAULT_FONT; |
|
146
|
0
|
0
|
|
|
|
|
if( $fontaliases->{$fontname} ) { |
|
147
|
0
|
|
|
|
|
|
$fontname = $fontaliases->{$fontname}; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
0
|
0
|
|
|
|
|
unless(exists($fonts->{$fontname})) { |
|
151
|
0
|
|
|
|
|
|
my $default = MONO_OLED_DEFAULT_FONT; |
|
152
|
0
|
|
|
|
|
|
carp(qq('$fontname' is not a valid fontname. Substituted $default font)); |
|
153
|
0
|
|
|
|
|
|
$fontname = $default; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
0
|
0
|
|
|
|
|
return $fonts->{$fontname} if $fonts->{$fontname}; |
|
157
|
0
|
|
|
|
|
|
my $fontclass = 'HiPi::Graphics::BitmapFont::' . $fontname; |
|
158
|
0
|
|
|
|
|
|
$fontclass->use; |
|
159
|
0
|
|
|
|
|
|
$fonts->{$fontname} = $fontclass->new(); |
|
160
|
0
|
|
|
|
|
|
return $fonts->{$fontname}; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1; |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
__END__ |