App-Music-ChordPro

 view release on metacpan or  search on metacpan

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


    $self->_dbg("XObject #", scalar(@$xoforms) );
    my $svg = SVGPDF::Element->new
	( name    => $e->{name},
	  atts    => { map { lc($_) => $e->{attrib}->{$_} } keys %{$e->{attrib}} },
	  content => $e->{content},
	  root    => $self,
	);

    # If there are <style> elements, these must be processed first.
    my $cdata = "";
    for ( $svg->get_children ) {
	next unless ref($_) eq "SVGPDF::Style";
	# DDumper($_->get_children) unless scalar($_->get_children) == 1;
	croak("ASSERT: 1 child") unless scalar($_->get_children) == 1;
	for my $t ( $_->get_children ) {
	    croak("# ASSERT: non-text child in style")
	      unless ref($t) eq "SVGPDF::TextElement";
	    $cdata .= $t->content;
	}
    }
    if ( $cdata =~ /\S/ ) {
	$css->read_string($cdata);
    }

    my $atts   = $svg->atts;

    # The viewport, llx lly width height.
    my $vbox   = delete $atts->{viewbox};

    # Width and height are the display size of the viewport.
    # Resolve em, ex and percentages.
    my $vwidth  = delete $atts->{width} // 0;

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

	    }
	}

	push( @res, $p );
    }

    # Return param values.
    return @res;
}

method get_cdata () {
    my $res = "";
    for ( $self->get_children ) {
	$res .= "\n" . $_->content if ref($_) eq "SVGPDF::TextElement";
    }
    $res;
}

method nfi ( $tag ) {
    state $aw = {};
    warn("SVG: $tag - not fully implemented, expect strange results.\n")

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


class SVGPDF::Style :isa(SVGPDF::Element);

method process () {
    my $atts = $self->atts;
    my $xo   = $self->xo;
    return if $atts->{omit};	# for testing/debugging.

    $self->_dbg( "+", $self->name, " ====" );

    my $cdata = "";
    for my $t ( $self->get_children ) {
	croak("# ASSERT: non-text child in style")
	  unless ref($t) eq "SVGPDF::TextElement";
	$cdata .= $t->content;
    }
    if ( $cdata =~ /\S/ ) {
	$self->root->css->read_string($cdata);
    }

    # Ok?

    $self->_dbg( "-" );
}


1;

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


    my @c = $self->get_children;

    if ( $x =~ /,/ ) {
	if ( @c > 1 || ref($c[0]) ne "SVGPDF::TextElement" ) {
	    die("text: Cannot combine coordinate list with multiple elements\n");
	}
	$x = [ $self->getargs($x) ];
	$y = [ $self->getargs($y) ];
	$text = [ split( //, $c[0]->content ) ];
	die( "\"", $self->get_cdata, "\" ", 0+@$x, " ", 0+@$y, " ", 0+@$text )
	  unless @$x == @$y && @$y == @$text;
    }
    else {
	$x = [ $self->u($x||0) ];
	$y = [ $self->u($y||0) ];
    }

    $self->_dbg( "+ xo save" );
    $xo->save;
    my $ix = $x->[0];



( run in 0.531 second using v1.01-cache-2.11-cpan-454fe037f31 )