URL: <https://savannah.gnu.org/bugs/?63757>
Summary: [gropdf] doesn't handle "papersize" directive as other drivers do Project: GNU troff Submitter: gbranden Submitted: Sat 04 Feb 2023 11:36:20 AM UTC Category: Driver gropdf Severity: 3 - Normal Item Group: Incorrect behaviour Status: Confirmed Privacy: Public Assigned to: deri Open/Closed: Open Discussion Lock: Any Planned Release: None _______________________________________________________ Follow-up Comments: ------------------------------------------------------- Date: Sat 04 Feb 2023 11:36:20 AM UTC By: G. Branden Robinson <gbranden> Over at the Debian Bug Tracking System, Ben Wong filed the following report <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030097>. Package: groff Version: 1.22.4-9 Severity: normal Tags: patch X-Debbugs-Cc: bugs.debian....@wongs.net Dear Maintainer, The gropdf Perl script has a few bugs. 1. It does not include /etc/papersize as the first place to check for the default paper size. The problem is that the "papersize" directive in fonts/devpdf/DESC only lists "a4" (or "letter"). papersize a4 Instead it should look like this: papersize /etc/papersize a4 2. It does not search each possible papersize listed in DESC, which is the documented behaviour in the groff_font manual. The fix for that requires editing the Perl script and splitting the papersizes on the space character. To reproduce the problem, try this: man -Tpdf groff > groff.pdf && pdfinfo groff.pdf | grep size I have attached two patches, one for each bug. The first changes the devpdf.am file so that it prepends "/etc/papersize" to the search. The code was copied from devps.am. The second patch adds a loop around the check of the $papersz variable in gropdf.pl. Because another level of indentation was added, the diff makes it look like more of the code changed than actually did. Thank you. Here are the suggested patches. --- font/devpdf/devpdf.am.orig 2023-01-30 19:12:42.600754792 -0800 +++ font/devpdf/devpdf.am 2023-01-30 19:15:00.829075259 -0800 @@ -1,9 +1,9 @@ -# Copyright (C) 2011-2018 Free Software Foundation, Inc. +# Copyright (C) 2011-2022 Free Software Foundation, Inc. # Original Makefile.sub written # by Deri James <d...@chuzzlewit.demon.co.uk> # Automake migration by Bertrand Garrigues # -# Last update: 2017-11-02 +# Last update: 2022-01-30 # # This file is part of groff. # @@ -95,9 +95,9 @@ && $(RM) $(top_builddir)/font/devpdf/DESC \ && cat $(devpdf_srcdir)/DESC.in >$(top_builddir)/font/devpdf/DESC \ && if test "$(PAGE)" = A4; then \ - echo "papersize a4" >>$(top_builddir)/font/devpdf/DESC; \ + echo "papersize /etc/papersize a4" >>$(top_builddir)/font/devpdf/DESC; \ else \ - echo "papersize letter" >>$(top_builddir)/font/devpdf/DESC; \ + echo "papersize /etc/papersize letter" >>$(top_builddir)/font/devpdf/DESC; \ fi font/devpdf/Foundry: --- src/devices/gropdf/gropdf.pl.orig 2023-01-30 17:23:40.938310920 -0800 +++ src/devices/gropdf/gropdf.pl 2023-01-30 18:55:24.859580795 -0800 @@ -248,39 +248,49 @@ 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 . " " . $possiblesizes if $fpsz; +my $papersz; +for $papersz ( split(" ", lc($possiblesizes)) ) { - if (open(P,"<$papersz")) + # Check for "/etc/papersize" + if (substr($papersz,0,1) eq '/' and -r $papersz) { - while (<P>) + if (open(P,"<$papersz")) { - chomp; - s/# .*//; - next if $_ eq ''; - $papersz=$_; - last + while (<P>) + { + chomp; + s/# .*//; + next if $_ eq ''; + $papersz=$_; + last; + } + close(P); } + } - close(P); + # 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; } -} -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]); + # If we get here, $papersz was invalid, so try the next one. } + my (@dt)=gmtime($ENV{SOURCE_DATE_EPOCH} || time); my $dt=PDFDate(\@dt); _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?63757> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/