diff options
author | Deri James <deri@chuzzlewit.myzen.co.uk> | 2023-02-09 15:27:56 +0000 |
---|---|---|
committer | Deri James <deri@chuzzlewit.myzen.co.uk> | 2023-02-09 15:27:56 +0000 |
commit | 7fb6e3ffd06c0ad8058e5de2325eef55f178ef67 (patch) | |
tree | 2f4dd262f4bca0a74aa8ddff658598ae85c86120 /src | |
parent | 5d79ab93573cf29127bbf69aa9c70388509dae78 (diff) | |
download | groff-git-7fb6e3ffd06c0ad8058e5de2325eef55f178ef67.tar.gz |
Fixes <https://savannah.gnu.org/bugs/?63757>
* src/devices/gropdf/gropdf.pl: Parse papersize string for
possible multiple (space separated) entries. First valid entry
wins.
[gropdf] Parse multiple entries in 'papersize' as specified in
the groff_font man page. Reported by Ben Wong and fix based on
his patch, thanks.
Diffstat (limited to 'src')
-rw-r--r-- | src/devices/gropdf/gropdf.pl | 75 |
1 files changed, 45 insertions, 30 deletions
diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl index f24889219..c65a1051f 100644 --- a/src/devices/gropdf/gropdf.pl +++ b/src/devices/gropdf/gropdf.pl @@ -286,46 +286,61 @@ LoadDownload(); LoadDesc(); my $unitwidth=$desc{unitwidth}; -my $papersz=$desc{papersize}; -$papersz=lc($fpsz) if $fpsz; $env{FontHT}=0; $env{FontSlant}=0; MakeMatrix(); -if (substr($papersz,0,1) eq '/' and -r $papersz) +my $possiblesizes = $desc{papersize}; +$possiblesizes = $fpsz if $fpsz; +my $papersz; +for $papersz ( split(" ", lc($possiblesizes).' #duff#') ) { - if (open(P,"<$papersz")) + # No valid papersize found? + if ($papersz eq '#duff#') { - while (<P>) - { - chomp; - s/# .*//; - next if $_ eq ''; - $papersz=$_; - last - } + Warn("ignoring unrecognized paper format(s) '$possiblesizes'"); + last; + } - close(P); + # Check for "/etc/papersize" + elsif (substr($papersz,0,1) eq '/' and -r $papersz) + { + if (open(P,"<$papersz")) + { + while (<P>) + { + chomp; + s/# .*//; + next if $_ eq ''; + $papersz=lc($_); + last; + } + close(P); + } } -} -if ($papersz=~m/([\d.]+)([cipP]),([\d.]+)([cipP])/) -{ - @defaultmb=@mediabox=(0,0,ToPoints($3,$4),ToPoints($1,$2)); -} -elsif (exists($ppsz{$papersz})) -{ - @defaultmb=@mediabox=(0,0,$ppsz{$papersz}->[0],$ppsz{$papersz}->[1]); -} -elsif (substr($papersz,-1) eq 'l' and exists($ppsz{substr($papersz,0,-1)})) -{ - # Note 'legal' ends in 'l' but will be caught above - @defaultmb=@mediabox=(0,0,$ppsz{substr($papersz,0,-1)}->[1],$ppsz{substr($papersz,0,-1)}->[0]); -} -else -{ - Warn("ignoring unrecognized paper format '$papersz'"); + # Allow height,width specified directly in centimeters, inches, or points. + if ($papersz=~m/([\d.]+)([cipP]),([\d.]+)([cipP])/) + { + @defaultmb=@mediabox=(0,0,ToPoints($3,$4),ToPoints($1,$2)); + last; + } + # Look $papersz up as a name such as "a4" or "letter". + elsif (exists($ppsz{$papersz})) + { + @defaultmb=@mediabox=(0,0,$ppsz{$papersz}->[0],$ppsz{$papersz}->[1]); + last; + } + # Check for a landscape version + elsif (substr($papersz,-1) eq 'l' and exists($ppsz{substr($papersz,0,-1)})) + { + # Note 'legal' ends in 'l' but will be caught above + @defaultmb=@mediabox=(0,0,$ppsz{substr($papersz,0,-1)}->[1],$ppsz{substr($papersz,0,-1)}->[0]); + last; + } + + # If we get here, $papersz was invalid, so try the next one. } my (@dt)=localtime($ENV{SOURCE_DATE_EPOCH} || time); |