App-Music-ChordPro

 view release on metacpan or  search on metacpan

lib/ChordPro/Output/PDF/Song.pm  view on Meta::CPAN

#! perl

use v5.26;

package main;

use utf8;
our $config;
our $options;

package ChordPro::Output::PDF::Song;

use Storable qw(dclone);
use Ref::Util qw(is_hashref is_arrayref is_coderef);
use Carp;
use feature 'state';
use ChordPro::Output::Common qw( roman fmt_subst );
use feature 'signatures';
no warnings qw( experimental::signatures );

use ChordPro::Files;
use ChordPro::Paths;
use ChordPro::Utils;
use ChordPro::Assets;

#my $ps;

use Text::Layout;

my $source;			# song source
my $structured = 0;		# structured data
my $suppress_empty_chordsline = 0;	# suppress chords line when empty
my $suppress_empty_lyricsline = 0;	# suppress lyrics line when blank
my $lyrics_only = 0;		# suppress all chord lines
my $inlinechords = 0;		# chords inline
my $inlineannots;		# format for inline annots
my $chordsunder = 0;		# chords under the lyrics
my $chordscol = 0;		# chords in a separate column
my $chordscapo = 0;		# capo in a separate column
my $propitems_re = propitems_re();

# Page classes.
my @classes = qw( first title default filler );

my $i_tag;
sub pr_label_maybe {
    my ( $ps, $x, $y ) = @_;
    my $tag = $i_tag // "";
    $i_tag = undef;
    prlabel( $ps, $tag, $x, $y ) if $tag ne "";
}

my $assets;
sub assets {
    my ( $id ) = @_;
    $assets->{$id};
}
# Images that go on all pages.
my @allpages;

use constant SIZE_ITEMS => [ qw( chord text chorus tab grid diagram
				 toc title footer label ) ];

sub generate_song {
    my ( $s, $opts ) = @_;

    warn("Generate song \"", $s->{title}, "\", ",
	 "page ", $opts->{page_num}, " (", $opts->{page_idx}, ")\n")
      if $config->{debug}->{pages} & 0x01;

    my $pr = $opts->{pr};
    my $pagectrl = $opts->{pagectrl};
    if ( $pr->{layout}->can("register_element") ) {
	$pr->{layout}->register_element



( run in 0.574 second using v1.01-cache-2.11-cpan-ceb78f64989 )