Lines 121-140
my $label_types = [
Link Here
|
121 |
{type => 'BAR', name => 'Barcode', desc => 'Only the barcode is printed.', selected => 0}, |
121 |
{type => 'BAR', name => 'Barcode', desc => 'Only the barcode is printed.', selected => 0}, |
122 |
]; |
122 |
]; |
123 |
|
123 |
|
124 |
my $font_types = [ |
124 |
#NOTE: this is needed to maintain current font ordering |
125 |
{type => 'TR', name => 'Times-Roman', selected => 0}, |
125 |
my @default_font_type_codes = ( |
126 |
{type => 'TB', name => 'Times-Bold', selected => 0}, |
126 |
"TR", |
127 |
{type => 'TI', name => 'Times-Italic', selected => 0}, |
127 |
"TB", |
128 |
{type => 'TBI', name => 'Times-Bold-Italic', selected => 0}, |
128 |
"TI", |
129 |
{type => 'C', name => 'Courier', selected => 0}, |
129 |
"TBI", |
130 |
{type => 'CB', name => 'Courier-Bold', selected => 0}, |
130 |
"C", |
131 |
{type => 'CO', name => 'Courier-Oblique', selected => 0}, |
131 |
"CB", |
132 |
{type => 'CBO', name => 'Courier-Bold-Oblique', selected => 0}, |
132 |
"CO", |
133 |
{type => 'H', name => 'Helvetica', selected => 0}, |
133 |
"CBO", |
134 |
{type => 'HO', name => 'Helvetica-Oblique', selected => 0}, |
134 |
"H", |
135 |
{type => 'HB', name => 'Helvetica-Bold', selected => 0}, |
135 |
"HO", |
136 |
{type => 'HBO', name => 'Helvetica-Bold-Oblique', selected => 0}, |
136 |
"HB", |
137 |
]; |
137 |
"HBO" |
|
|
138 |
); |
139 |
my %default_font_types = ( |
140 |
TR => {name => 'Times-Roman', }, |
141 |
TB => {name => 'Times-Bold', }, |
142 |
TI => {name => 'Times-Italic', }, |
143 |
TBI => {name => 'Times-Bold-Italic', }, |
144 |
C => {name => 'Courier', }, |
145 |
CB => {name => 'Courier-Bold', }, |
146 |
CO => {name => 'Courier-Oblique', }, |
147 |
CBO => {name => 'Courier-Bold-Oblique', }, |
148 |
H => {name => 'Helvetica', }, |
149 |
HO => {name => 'Helvetica-Oblique', }, |
150 |
HB => {name => 'Helvetica-Bold', }, |
151 |
HBO => {name => 'Helvetica-Bold-Oblique', }, |
152 |
); |
138 |
|
153 |
|
139 |
my $text_justification_types = [ |
154 |
my $text_justification_types = [ |
140 |
{type => 'L', name => 'Left', selected => 0}, |
155 |
{type => 'L', name => 'Left', selected => 0}, |
Lines 429-435
This function returns a reference to an array of hashes containing all font type
Link Here
|
429 |
=cut |
444 |
=cut |
430 |
|
445 |
|
431 |
sub get_font_types { |
446 |
sub get_font_types { |
432 |
return $font_types; |
447 |
my @available_fonts = (); |
|
|
448 |
my %available_font_lookup = %default_font_types; |
449 |
|
450 |
#Add new fonts or rename default fonts |
451 |
my $ttf = C4::Context->config('ttf'); |
452 |
if ($ttf && $ttf->{font} && ref $ttf->{font} eq 'ARRAY'){ |
453 |
foreach my $font ( @{$ttf->{font}} ){ |
454 |
if ($font->{type} && $font->{name} && $font->{content}){ |
455 |
$available_font_lookup{ $font->{type} } = { name => $font->{name}, }; |
456 |
} |
457 |
} |
458 |
} |
459 |
|
460 |
#Output default font types first (in default order) |
461 |
_use_font({ |
462 |
font_types => \@default_font_type_codes, |
463 |
font_lookup => \%available_font_lookup, |
464 |
available_fonts => \@available_fonts, |
465 |
}); |
466 |
|
467 |
#Output configured font types last (in alphabetical order) |
468 |
my @remaining_types = sort keys %available_font_lookup; |
469 |
_use_font({ |
470 |
font_types => \@remaining_types, |
471 |
font_lookup => \%available_font_lookup, |
472 |
available_fonts => \@available_fonts, |
473 |
}); |
474 |
|
475 |
return \@available_fonts; |
476 |
} |
477 |
|
478 |
sub _use_font { |
479 |
my ($args) = @_; |
480 |
my $font_types = $args->{font_types}; |
481 |
my $font_lookup = $args->{font_lookup}; |
482 |
my $available_fonts = $args->{available_fonts}; |
483 |
if ($font_types && $font_lookup && $available_fonts){ |
484 |
foreach my $font_type (@$font_types){ |
485 |
my $font = delete $font_lookup->{$font_type}; |
486 |
$font->{type} = $font_type; |
487 |
#FIXME: in future it would be good to remove this selected requirement, but needs template changes |
488 |
$font->{selected} = 0; |
489 |
push(@$available_fonts,$font); |
490 |
} |
491 |
} |
433 |
} |
492 |
} |
434 |
|
493 |
|
435 |
=head2 C4::Creators::Lib::get_text_justification_types() |
494 |
=head2 C4::Creators::Lib::get_text_justification_types() |
436 |
- |
|
|