From 84675bc536af363543bdae1fa422903a977e1ec8 Mon Sep 17 00:00:00 2001 From: Masamichi Hosoda Date: Thu, 27 Apr 2017 21:18:41 +0900 Subject: [PATCH] Issue 5126: Prevent Ghostscript's unwanted automatic page rotation Ghostscript is "too clever" to rotate pages automatically with "majority decision". This behavior can cause unwanted page rotation. This commit prevents such behavior by adding option `-dAutoRotatePages=/None` to Ghostscript. --- Documentation/pictures/GNUmakefile | 2 +- make/lilypond-book-rules.make | 4 ++-- scm/backend-library.scm | 1 + scm/ps-to-png.scm | 1 + scripts/auxiliar/make-regtest-pngs.sh | 1 + scripts/build/output-distance.py | 1 + stepmake/stepmake/tex-rules.make | 1 + stepmake/stepmake/texinfo-rules.make | 2 +- 8 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Documentation/pictures/GNUmakefile b/Documentation/pictures/GNUmakefile index ef72775059..8ae3e463bb 100644 --- a/Documentation/pictures/GNUmakefile +++ b/Documentation/pictures/GNUmakefile @@ -38,7 +38,7 @@ $(outdir)/%.jpg: %.jpg ln -f $< $@ $(outdir)/%.png: %.eps - gs -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=$@ -sDEVICE=png16m -dEPSCrop -dNOPAUSE -f $< -c quit + gs -dAutoRotatePages=/None -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q -sOutputFile=$@ -sDEVICE=png16m -dEPSCrop -dNOPAUSE -f $< -c quit $(outdir)/%.pdf: %.eps gs -dAutoRotatePages=/None -q -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=$@ -dEPSCrop -c .setpdfwrite -f $< diff --git a/make/lilypond-book-rules.make b/make/lilypond-book-rules.make index e0c0756bc4..243a9f18c7 100644 --- a/make/lilypond-book-rules.make +++ b/make/lilypond-book-rules.make @@ -29,7 +29,7 @@ $(outdir)/%.pdf: $(outdir)/%.tex cd $(outdir) && $(buildscript-dir)/run-and-check "$(PDFLATEX) -halt-on-error $(notdir $<)" "$*.pdflatex.log" ifeq ($(USE_EXTRACTPDFMARK),yes) $(EXTRACTPDFMARK) -o $(outdir)/$*.pdfmark $@ - $(GS920) -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$(outdir)/$*.final.pdf -c "30000000 setvmthreshold" -f $(top-build-dir)/out-fonts/*.font.ps $(outdir)/$*.pdfmark $@ + $(GS920) -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dAutoRotatePages=/None -sOutputFile=$(outdir)/$*.final.pdf -c "30000000 setvmthreshold" -f $(top-build-dir)/out-fonts/*.font.ps $(outdir)/$*.pdfmark $@ rm $@ mv $(outdir)/$*.final.pdf $@ endif @@ -61,7 +61,7 @@ $(outdir)/%.pdf: $(outdir)/%.xml cd $(outdir) && $(buildscript-dir)/run-and-check "$(DBLATEX) $(DBLATEX_BACKEND) $(notdir $<)" "$*.dblatex.log" ifeq ($(USE_EXTRACTPDFMARK),yes) $(EXTRACTPDFMARK) -o $(outdir)/$*.pdfmark $@ - $(GS920) -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$(outdir)/$*.final.pdf -c "30000000 setvmthreshold" -f $(top-build-dir)/out-fonts/*.font.ps $(outdir)/$*.pdfmark $@ + $(GS920) -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dAutoRotatePages=/None -sOutputFile=$(outdir)/$*.final.pdf -c "30000000 setvmthreshold" -f $(top-build-dir)/out-fonts/*.font.ps $(outdir)/$*.pdfmark $@ rm $@ mv $(outdir)/$*.final.pdf $@ endif diff --git a/scm/backend-library.scm b/scm/backend-library.scm index 240096cad2..8eec320288 100644 --- a/scm/backend-library.scm +++ b/scm/backend-library.scm @@ -98,6 +98,7 @@ "-r1200" (if (ly:bigpdfs) "-dSubsetFonts=false") "-sDEVICE=pdfwrite" + "-dAutoRotatePages=/None" (string-append "-sOutputFile=" (string-join (string-split pdf-name #\%) diff --git a/scm/ps-to-png.scm b/scm/ps-to-png.scm index f20ca61b41..d0f810fafb 100644 --- a/scm/ps-to-png.scm +++ b/scm/ps-to-png.scm @@ -145,6 +145,7 @@ "-dNOPAUSE" "-dBATCH" (ly:format "-sDEVICE=~a" pixmap-format) + "-dAutoRotatePages=/None" (string-append "-sOutputFile=" output-file) (ly:format "-r~a" (* anti-alias-factor resolution)) (string-append "-f" tmp-name)))) diff --git a/scripts/auxiliar/make-regtest-pngs.sh b/scripts/auxiliar/make-regtest-pngs.sh index 01610e8ac3..d5ee847bc6 100755 --- a/scripts/auxiliar/make-regtest-pngs.sh +++ b/scripts/auxiliar/make-regtest-pngs.sh @@ -70,6 +70,7 @@ while getopts "j:oncr:gpd:" opts; do { $1 gs -sDEVICE=${gsdevice:-pngmono} -q -dNOPAUSE \ -r${resolution:-300} -dNOPLATFONTS \ + -dAutoRotatePages=/None \ -dTextAlphaBits=1 -dGraphicsAlphaBits=1 \ -sOutputFile="${2%.pdf}-%d.png" "$2" -c quit };; diff --git a/scripts/build/output-distance.py b/scripts/build/output-distance.py index 49a659b73f..625ce12a1e 100755 --- a/scripts/build/output-distance.py +++ b/scripts/build/output-distance.py @@ -642,6 +642,7 @@ class SignatureFileLink (FileLink): cmd = ('gs -sDEVICE=png16m -dGraphicsAlphaBits=4 -dTextAlphaBits=4 ' ' %(data_option)s ' ' -r101 ' + ' -dAutoRotatePages=/None ' ' -sOutputFile=%(outfile)s -dNOSAFER -dEPSCrop -q -dNOPAUSE ' ' %(infile)s -c quit ') % locals () diff --git a/stepmake/stepmake/tex-rules.make b/stepmake/stepmake/tex-rules.make index 6751e5da9a..5b6e6c04d0 100644 --- a/stepmake/stepmake/tex-rules.make +++ b/stepmake/stepmake/tex-rules.make @@ -23,6 +23,7 @@ $(outdir)/%.pdf: $(outdir)/%.dvi -dNOPAUSE\ -dBATCH\ -sDEVICE=pdfwrite\ + -dAutoRotatePages=/None\ -sOutputFile=$(@F)\ -dCompatibilityLevel=1.2\ -sPAPERSIZE=a4\ diff --git a/stepmake/stepmake/texinfo-rules.make b/stepmake/stepmake/texinfo-rules.make index 007f88fdad..df04e1ebe3 100644 --- a/stepmake/stepmake/texinfo-rules.make +++ b/stepmake/stepmake/texinfo-rules.make @@ -74,7 +74,7 @@ else endif ifeq ($(USE_EXTRACTPDFMARK),yes) $(EXTRACTPDFMARK) -o $(outdir)/$*.pdfmark $@ - $(GS920) -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$(outdir)/$*.final.pdf -c "30000000 setvmthreshold" -f $(top-build-dir)/out-fonts/*.font.ps $(outdir)/$*.pdfmark $@ + $(GS920) -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dAutoRotatePages=/None -sOutputFile=$(outdir)/$*.final.pdf -c "30000000 setvmthreshold" -f $(top-build-dir)/out-fonts/*.font.ps $(outdir)/$*.pdfmark $@ rm $@ mv $(outdir)/$*.final.pdf $@ endif -- 2.39.2