#!/bin/bash ## make covers - companion to mk-calendar-8up-wallet-sized; 2009-Oct Eugene Reimer; ## is "source"d from it, so it receives the Margin settings: W Wpx H Hpx; ## note: defscover.txt has the functions required by the postscript this script generates; ## ## PREREQ: bc -- from http://ereimer.net/programs/general-purpose-scripts.htm USERereimer=; if [[ $USER == ereimer ]];then USERereimer=Y; fi ##for my own use having different defaults... FONTR=Times; FONTB=Times-Bold; if [[ $USERereimer ]];then FONTR=CMSS8; FONTB=CMSSBX10; fi ##use Times in general; ComputerModernSans for my use ##--calculate rescaling needed, for those parts laid out as 4.25x2.75-inch smallpages: Wpsr=$(bc <<<"$W/4.25") Hpsr=$(bc <<<"$H/2.75") if [[ $USERereimer ]];then ##front-cover for my own use ##--Front-Cover: full-bleed WxH (was 4.25x2.75) image with headings on it; B=ER06006-Showy_20040707_erC1C scalepix -t0 -s${Wpx}x$Hpx -DI -a0 -PR tmp -NOSZ -oppm $B.png ##scale to PPM; was 1275x825 annotatepix -fverdana-bold -a50 -cwhite -x-1 -y-$((Hpx-64)) -t"2010 Calendar" tmp$B.ppm ##annotate on top (positive y IS BROKEN); was 765 annotatepix -fverdana -a40 -cwhite -x-1 -y-30 -t"Native Orchid Conservation Inc" tmp$B.ppm ##annotate on bottom; was x:40 for left vs centered pnmtojpeg -quality=85 -density=300x300dpi tmp$B.ppm >tmp$B.jpg ##convert to JPEG ##g2ps -d 300 -pw $W -ph $H -wt 0 tmp$B.jpg tmp$B.eps ##convert to EPS with img2ps; was 4.25 2.75 sam2p -j:quiet -m:dpi:17.28 tmp$B.jpg tmp$B.eps ##convert to EPS with sam2p ##gsed -n -q '1,/^\/origstate/d; /^origstate restore/,$d' tmp$B.eps ##simplify img2ps-produced postscipt chgsed -n -q '1,/^%%Page:/d; /^end restore/,$cend restore' tmp$B.eps ##simplify sam2p-produced postscipt cat tmp$B.eps >smallpage01-C1C.ps echo "have made smallpage01-C1C.ps" rm -f tmp$B* else ##simpler text+logo front-cover for published example echo " $Wpsr $Hpsr scale %%scale from 4.25x2.75 layout... gsave 1.625 inch 0.770 inch translate 72 650 div dup scale DrawLogo grestore %%logo horizontally centred, below text; /$FONTB 18.0 stfont 2.125 inch 2.20 inch moveto (2010 Calendar)cmCTR %%line of text " >smallpage01.ps echo "have made smallpage01.ps" fi ##--Back-Cover: text+logo: echo " $Wpsr $Hpsr scale %%scale from 4.25x2.75 layout... gsave 1.625 inch 0.522 inch translate 72 650 div dup scale DrawLogo grestore %%logo horizontally centred, below text; was y:0.500 /$FONTB 12.0 stfont 2.125 inch 2.30 inch moveto (Native Orchid Conservation Inc)cmCTR %%1st line of text /$FONTR 12.0 stfont 2.125 inch 2.07 inch moveto (204-947-9707)cmCTR %%2nd line of text /$FONTR 12.0 stfont 2.125 inch 1.87 inch moveto (www.nativeorchid.org)cmCTR %%3rd line of text /$FONTR 8.0 stfont 2.125 inch 0.104 inch moveto (Calendar design: Eugene Reimer www.ereimer.net)cmCTR %%line of text at bottom of page; was y:0.060 " >smallpage32.ps echo "have made smallpage32.ps" return ##now "source"d => exit-->return ====== NOTE: the postscript routines cmCTR cmshow cmstringwidth etc are in defscover.txt; BEWARE: the -c (center) option of img2ps is broken; it always positions image to top-left corner of page, so page-size bigger than image does nothing useful; ##--OBSOLETE, an alternate Front-Cover with text+image: B=ER06006-Showy_20040707_erC2C echo " $Wpsr $Hpsr scale %%scale from 4.25x2.75 layout... /$FONTB 15.0 stfont 2.125 inch 2.45 inch moveto (2010 Calendar)cmCTR %%1st line of text /$FONTB 12.0 stfont 2.125 inch 2.20 inch moveto (Native Orchid Conservation Inc)cmCTR %%2nd line of text /pagewidth 1275 def /image_wd 600 def %%==COPIED from below pagewidth image_wd sub 2 div 72 300 div mul 0 translate %%horizontal centering " >smallpage01-C2C.ps scalepix -t0 -s1275x600 -CA -a25 -b25 -PR tmp $B.png ##scale and annotate to JPEG ##g2ps -d 300 -pw 4.25 -ph 2.00 -wt 0 tmp$B*jpg tmp$B.eps ##convert to EPS with img2ps sam2p -j:quiet -m:dpi:17.28 tmp$B.jpg tmp$B.eps ##convert to EPS with sam2p ##gsed -n -q '1,/^\/origstate/d; /^origstate restore/,$d' tmp$B.eps ##simplify img2ps-produced postscript chgsed -n -q '1,/^%%Page:/d; /^end restore/,$cend restore' tmp$B.eps ##simplify sam2p-produced postscript cat tmp$B.eps >>smallpage01-C2C.ps echo "have made smallpage01-C2C.ps" rm -f tmp$B* CHANGES: 2009-11-07: revised interface between the 2 parts of mk-calendar: instead of writing coverFront.ps and coverBack.ps am now writing smallpage01.ps (front-cover), and smallpage32.ps (back-cover) -- for a 15-month calendar; this works better when wanting to make things like a 14-month calendar with smallpage{30,31}.ps as prose pages, or 12-monther with smallpage{26,27,28}.ps as prose and smallpage{29,30,31}.ps as notepad-like pages; ie: this script supplies all smallpages other than the IMG+CAL pairs; 2009-11-12: published version: text+logo-only, no photo; use only fonts from the PS-standard-35; ComputerModern fonts are an awful choice for a lot of reasons... note: at least with ghostscript, a missing font gets replaced with Courier, rather than being fatal, but that still isn't great; switched to Times, except for my own use;