View | Details | Raw Unified | Return to bug 25384
Collapse All | Expand All

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

Return to bug 25384