App-Music-ChordPro

 view release on metacpan or  search on metacpan

lib/ChordPro.pm  view on Meta::CPAN

    # Parse the input(s).
    use ChordPro::Songbook;
    my $s = ChordPro::Songbook->new;
    my $res;

    # Shortcut a2crd conversion.
    if ( $options->{a2crd} ) {
	require ChordPro::A2Crd;
	$res = ChordPro::A2Crd::a2crd();
	push( @$res, '' );
	goto WRITE_OUTPUT;
    }

    # Check for metadata in filelist. Actually, this works on the
    # command line as well, but don't tell anybody.
    progress( phase => "Parsing", index => 0, total => 0+@ARGV )
      if @ARGV > 1;
    foreach my $file ( @ARGV ) {
	my $opts;
	if ( $file =~ /^--((?:sub)?title)\s*(.*)/ ) {
	    $options->{$1} = decode_utf8($2);

lib/ChordPro.pm  view on Meta::CPAN

	    $f =~ s;(?!\.\w+$)[^\w/-];_;g;
	    warn("Writing output to $f\n") if $options->{verbose};
	    $options->{output} = $f;
	}
    }

    # Call backend to produce output.
    $res = $pkg->generate_songbook($s);
    return $res if $options->{output} eq '*';

  WRITE_OUTPUT:
    # Some backends write output themselves, others return an
    # array of lines to be written.
    if ( $res && @$res > 0 ) {
        if ( $of && $of ne "-" ) {
            open( my $fd, '>', $of );
	    binmode( $fd, ":utf8" );
	    push( @$res, '' ) unless $res->[-1] eq '';
	    print { $fd } ( join( "\n", @$res ) );
	    close($fd);
        }

lib/ChordPro/lib/SVGPDF.pm  view on Meta::CPAN


    $pdf->save("demo.pdf");

=head1 DESCRIPTION

This module processes SVG data and produces one or more PDF XObjects
to be placed in a PDF document. This module is intended to be used
with L<PDF::Builder>, L<PDF::API2> and compatible PDF packages.

The main method is process(). It takes the SVG from an input source, see
L</INPUT>.

=head1 COORDINATES & UNITS

SVG coordinates run from top-left to bottom-right.

Dimensions without units are B<pixels>, at 96 pixels / inch. E.g.,
C<width="96"> means 96px (pixels) and is equal to 72pt (points) or 1in (inch).

For font sizes, CSS defines C<em> to be equal to the font size, and
C<ex> is half of the font size.

lib/ChordPro/lib/SVGPDF.pm  view on Meta::CPAN

    $defs         = {};
    $fontmanager  = SVGPDF::FontManager->new( svg => $self );
    $self;
}

=head2 process

    $xof = $svg->process( $data, %options )

This methods gets SVG data from C<$data> and returns an array reference
with rendered images. See L</OUTPUT> for details.

The input is read using File::LoadLines. See L</INPUT> for details.

Recognized attributes in C<%options> are:

=over 4

=item fontsize

The font size to be used for dimensions in 'ex' and 'em' units.

This value overrides the value set in the constructor.

lib/ChordPro/lib/SVGPDF.pm  view on Meta::CPAN

	$xo->stroke;
    }
    for ( my $y = -$d; $y > $bb[1]; $y -= $d ) {
	$xo->move( $bb[0], $y );
	$xo->hline($bb[2]);
	$xo->stroke;
    }
    $xo->restore;
}

=head1 INPUT

The input SVG data B<must> be correct XML data.
The data can be a single C<< <svg> >> element, or a container
element (e.g. C<< <html> >> or C<< <xml> >>) with one or more
C<< <svg> >> elements among its children.

The SVG data can come from several sources:

=over 4

lib/ChordPro/lib/SVGPDF.pm  view on Meta::CPAN


=item *

A string containing SVG data, specified as a reference to a scalar.

=back

The input is read using L<File::LoadLines>. See its documentation for
details.

=head1 OUTPUT

The result from calling process() is a reference to an array
containing hashes that describe the XObjects. Each hash has the
following keys:

=over 8

=item C<vbox>

The viewBox as specified in the SVG element.



( run in 0.347 second using v1.01-cache-2.11-cpan-64827b87656 )