Skip to content

Commit

Permalink
Several image fixes related to issue #428.
Browse files Browse the repository at this point in the history
  • Loading branch information
sciurius committed Oct 7, 2024
1 parent 6567450 commit 43c0a95
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions lib/ChordPro/Output/PDF.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1315,9 +1315,9 @@ sub generate_song {

my $gety = sub {
my $h = shift;
$checkspace->($h);
my $have = $checkspace->($h);
$ps->{pr}->show_vpos( $y, 1 ) if $config->{debug}->{spacing};
return $y;
return wantarray ? ($y,$have) : $y;
};

my $vsp = imageline( $elt, $x, $ps, $gety );
Expand Down Expand Up @@ -2127,7 +2127,17 @@ sub imageline {
}
$align //= "left";

my $y = $gety->($anchor eq "float" ? $h : 0); # may have been changed by checkspace
my $xtrascale = ( $ps->{__rightmargin}-$ps->{_leftmargin} ) /
( $ps->{_marginright}-$ps->{_leftmargin} );

my ( $y, $spaceok ) = $gety->($anchor eq "float" ? $h*$xtrascale : 0);
# y may have been changed by checkspace.
# An extra scaled image is flushed to the next page, recalc xtrascale.
if ( !$spaceok && $xtrascale < 1 ) {
$y = $gety->($anchor eq "float" ? $h : 0);
$xtrascale = ( $ps->{__rightmargin}-$ps->{_leftmargin} ) /
( $ps->{_marginright}-$ps->{_leftmargin} );
}
if ( defined ( my $tag = $i_tag // $label ) ) {
$i_tag = $tag;
my $ftext = $ps->{fonts}->{comment};
Expand All @@ -2154,7 +2164,6 @@ sub imageline {
}
};

my $xtrascale = 1;
if ( $anchor eq "column" ) {
# Relative to the column.
$calc->( @{$ps}{qw( __leftmargin __rightmargin
Expand All @@ -2174,8 +2183,6 @@ sub imageline {
# See issue #428.
# $calc->( $x, $ps->{__rightmargin}, $y, $ps->{__bottommargin}, 0 );
$calc->( $x, $ps->{_marginright}, $y, $ps->{__bottommargin}, 0 );
$xtrascale = ( $ps->{__rightmargin}-$ps->{_leftmargin} ) /
( $ps->{_marginright}-$ps->{_leftmargin} );
warn( pv( "_MR = ", $ps->{_marginright} ),
pv( ", _RM = ", $ps->{_rightmargin} ),
pv( ", __RM = ", $ps->{__rightmargin} ),
Expand Down
2 changes: 1 addition & 1 deletion lib/ChordPro/Version.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is generated. Do not edit!
package ChordPro::Version;
our $VERSION = "6.060_057";
our $VERSION = "6.060_058";
print "$VERSION\n" unless caller;

0 comments on commit 43c0a95

Please sign in to comment.