]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add additional options grdp to scripts/auxiliar/make-regtest-pngs.sh
authorDavid Kastrup <dak@gnu.org>
Sat, 20 Apr 2013 10:29:31 +0000 (12:29 +0200)
committerDavid Kastrup <dak@gnu.org>
Sat, 20 Apr 2013 10:29:31 +0000 (12:29 +0200)
This is for checking bitmap production at different resolution, the
output from using poppler and libcairo on LilyPond's PDF, and the
output for typical print bitmaps generated from LilyPond's PDF.

scripts/auxiliar/make-regtest-pngs.sh

index 5942e279da8269f653145d69c946c7ebd7f76950..e770cc2a674b6786ae16b0352d1052cb2fedab9f 100755 (executable)
 #
 #   -n means build a new regtest set - the PNGs go in the new-regtest-results
 #   directory
+#
+#   -p uses PDF and the poppler library via pdftocairo for generating bitmaps,
+#   simulating the output for Evince and other previewers using poppler.
+#   pdftocairo may be contained in the poppler-utils package.
+#
+#   -r can be used for specifying a rendering resolution.  This
+#   defaults to 101 for poppler and 300 for Ghostscript from PDF.
+#
+#   -g uses Ghostscript for rendering a bitmap version from the PDF,
+#   simulating the output from printing PDF files on a GNU system, so
+#   use a resolution appropriate for print.  Antialiasing is not enabled.
+#
+#   -d changes the Ghostscript device used for creating PNG files
+#   (usually png16m, but with -g you might prefer fewer colors for size
+#   reasons, like png16).
+
+cpu_count=${CPU_COUNT:-1}
+backend_opt='--png ${resolution:+=-dresolution=$resolution} ${gsdevice:+=-dpixmap-format=$gsdevice}'
+resolution=
+gsdevice=
+
+png_generate()
+{
+    :
+}
 
-cpu_count=1
+while getopts "j:onpr:g" opts; do
+    case $opts in j)
+            cpu_count=$OPTARG;;
+       
+       o)
+            file_loc="old-regtest-results";;
 
-while getopts "j:on" opts; do
-    if [ "$opts" = "j" ]; then
-        cpu_count=$OPTARG
-    fi
+       p)
+           backend_opt="--pdf"
+           png_generate()
+           {
+               for i
+               do pdftocairo -png -r ${resolution:-101} -q "$i" &&
+                   rm "$i"
+               done
+           };;
 
-    if [ "$opts" = "o" ]; then
-        file_loc="old-regtest-results"
-    fi
+       n)
+            file_loc="new-regtest-results"
+            do_compare="y";;
 
-    if [ "$opts" = "n" ]; then
-        file_loc="new-regtest-results"
-        do_compare="y"
-    fi
+       r)
+           resolution=$OPTARG;;
+       g)
+           backend_opt="--pdf"
+           png_generate()
+           {
+               for i
+               do
+                   gs -sDEVICE=${gsdevice:-png16m} -q -dNOPAUSE \
+                       -r${resolution:-300} -dNOPLATFONTS \
+                       -dTextAlphaBits=1 -dGraphicsAlphaBits=1 \
+                       -sOutputFile="${i%.pdf}-%d.png" "$i" -c quit &&
+                   rm "$i"
+               done
+           };;
+    esac
 done
 
 if [ -z "$file_loc" ]; then
@@ -41,9 +88,10 @@ rm -rf $LILYPOND_BUILD_DIR/out-png-check/$file_loc
 mkdir -p $LILYPOND_BUILD_DIR/out-png-check/$file_loc
 cd $LILYPOND_BUILD_DIR/out-png-check/$file_loc
 ls $LILYPOND_GIT/input/regression/*.ly > dir.txt
-$LILYPOND_BUILD_DIR/out/bin/lilypond --png --relocate \
+$LILYPOND_BUILD_DIR/out/bin/lilypond $(eval echo $backend_opt) --relocate \
     -dinclude-settings=$LILYPOND_GIT/scripts/auxiliar/NoTagline.ly \
     -djob-count=$cpu_count -dread-file-list "dir.txt"
+png_generate *.pdf
 rm -rf dir.txt
 rm -rf *.log