| 1 | /* GraphicsPostscript.cpp |
| 2 | * |
| 3 | * Copyright (C) 1992-2007,2009,2011,2012,2014-2017,2020-2022,2025 Paul Boersma |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "GraphicsP.h"cxx . . $ `<file>/sys/GraphicsP.h`/ |
| 20 | #include <time.h> /* For creation date. */ |
| 21 | #include "Printer.h"cxx . . $ `<file>/sys/Printer.h`/ |
| 22 | |
| 23 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (GraphicsPostscript, Graphics, 0); |
| 24 | |
| 25 | static void downloadPrologAndSetUpcxx . . $ downloadPrologAndSetUp(b3e8c95126eb3d7a). (GraphicsPostscriptcxx . . $ GraphicsPostscript# me) { |
| 26 | /* |
| 27 | * Procedures section of the document prolog: procedure definitions valid for all pages. |
| 28 | */ |
| 29 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%BeginProlog\n"); |
| 30 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%BeginResource: procset (ppgb GraphicsPostscript procs) 1.0 0\n"); |
| 31 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "/N { newpath } bind def /M { newpath moveto } bind def /L { rlineto } bind def\n"); |
| 32 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "/F { 10 { 1 exch rlineto } repeat } bind def\n"); |
| 33 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "/C { 0 360 arc stroke } bind def /FC { 0 360 arc fill } bind def\n"); |
| 34 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., |
| 35 | "/PraatEncoding [\n" |
| 36 | " /dotlessi/Aogonek/aogonek/Cacute/cacute/Ccaron/ccaron/Dcaron/dcaron/Dbar\n" |
| 37 | " /dbar/Ecaron/ecaron/Eogonek/eogonek/Gcaron/gcaron/Lslash/lslash/Nacute\n" |
| 38 | " /nacute/Ncaron/ncaron/Ohungarumlaut/ohungarumlaut/Rcaron/rcaron/Sacute/sacute/Scaron\n" |
| 39 | " /scaron/Tcaron/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quotesinglright\n" |
| 40 | " /parenleft/parenright/asterisk/plus/comma/hyphen/period/slash/zero/one\n" |
| 41 | " /two/three/four/five/six/seven/eight/nine/colon/semicolon\n" |
| 42 | " /less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z\n" |
| 43 | " /bracketleft/backslash/bracketright/asciicircum/underscore/quotesinglleft\n" |
| 44 | " /a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde\n" |
| 45 | " /Zdot/Adieresis/Aring/Ccedilla/Eacute/Ntilde/Odieresis/Udieresis/aacute/agrave/acircumflex\n" |
| 46 | " /adieresis/atilde/aring/ccedilla/eacute/egrave/ecircumflex/edieresis/iacute/igrave/icircumflex\n"); |
| 47 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., |
| 48 | " /idieresis/ntilde/oacute/ograve/ocircumflex/odieresis/otilde/uacute/ugrave/ucircumflex/udieresis\n" |
| 49 | " /dagger/degree/cent/sterling/section/bullet/paragraph/germandbls/registered/copyright/trademark\n" |
| 50 | " /acute/dieresis/notequal/AE/Oslash/infinity/plusminus/lessequal/greaterequal/yen/mu\n" |
| 51 | " /partialdiff/summation/product/pi/integral/ordfeminine/ordmasculine/Omega/ae/oslash\n" |
| 52 | " /questiondown/exclamdown/logicalnot/radical/florin/approxequal/Delta/guillemotleft/guillemotright\n" |
| 53 | " /ellipsis/zdot/Agrave/Atilde/Otilde/OE/oe/endash/emdash/quotedblleft/quotedblright\n" |
| 54 | " /quoteleft/quoteright/divide/lozenge/ydieresis/Ydieresis/fraction/currency\n" |
| 55 | " /guilsinglleft/guilsinglright/fi/fl/daggerdbl/periodcentered/quotesinglbase/quotedblbase\n" |
| 56 | " /perthousand/Acircumflex/Ecircumflex/Aacute/Edieresis/Egrave/Iacute/Icircumflex/Idieresis\n" |
| 57 | " /Igrave/Oacute/Ocircumflex/apple/Ograve/Uacute/Ucircumflex/Ugrave/tcaron\n" |
| 58 | " /Uhungarumlaut/uhungarumlaut/Uring/uring/Yacute/yacute/Zacute/zacute/Zcaron/zcaron ] def\n"); |
| 59 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., |
| 60 | "/PraatEncode { /font exch def /base exch def\n" |
| 61 | " /basedict base findfont def /new basedict maxlength dict def\n" |
| 62 | " basedict { exch dup dup /FID ne exch /Encoding ne and\n" |
| 63 | " { exch new 3 1 roll put } { pop pop } ifelse } forall\n" |
| 64 | " new /FontName font put new /Encoding PraatEncoding put font new definefont pop } def\n"); |
| 65 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%EndResource\n"); |
| 66 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%EndProlog\n"); |
| 67 | |
| 68 | /* |
| 69 | * Document setup: graphics state changes persistent across showpage calls. |
| 70 | */ |
| 71 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%BeginSetup\n"); |
| 72 | //my d_printf (my d_file, "%d %d { dup mul exch dup mul add 1.0 exch sub } setscreen\n", my spotsDensity, my spotsAngle); |
| 73 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "true setstrokeadjust\n"); |
| 74 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%EndSetup\n"); |
| 75 | } |
| 76 | |
| 77 | static void initPagecxx . . $ initPage(b3e8c95126eb3d7a). (GraphicsPostscriptcxx . . $ GraphicsPostscript# me) { |
| 78 | ++ mycxx . . $ `melder/melder.h:44:9`! pageNumbercxx . . $ structGraphicsPostscript#pageNumber.; |
| 79 | if (mycxx . . $ `melder/melder.h:44:9`! printercxx . . $ structGraphics#printer. && mycxx . . $ `melder/melder.h:44:9`! pageNumbercxx . . $ structGraphicsPostscript#pageNumber. > 1) downloadPrologAndSetUpcxx . . $ downloadPrologAndSetUp(b3e8c95126eb3d7a). (me); // has to be repeated for every page |
| 80 | if (mycxx . . $ `melder/melder.h:44:9`! jobcxx . . $ structGraphicsPostscript#job.) { |
| 81 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%Page: %d %d\n", mycxx . . $ `melder/melder.h:44:9`! pageNumbercxx . . $ structGraphicsPostscript#pageNumber., mycxx . . $ `melder/melder.h:44:9`! pageNumbercxx . . $ structGraphicsPostscript#pageNumber.); |
| 82 | /*my d_printf (my d_file, "save\n");*/ |
| 83 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%BeginPageSetup\n"); |
| 84 | } |
| 85 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%g setlinewidth 2 setlinejoin\n", mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution. / 192.0); /* 0.375 point */ |
| 86 | if (mycxx . . $ `melder/melder.h:44:9`! jobcxx . . $ structGraphicsPostscript#job. || mycxx . . $ `melder/melder.h:44:9`! printercxx . . $ structGraphics#printer.) { |
| 87 | if (mycxx . . $ `melder/melder.h:44:9`! landscapecxx . . $ structGraphicsPostscript#landscape.) |
| 88 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%d 0 translate 90 rotate ", (int) (mycxx . . $ `melder/melder.h:44:9`! paperHeightcxx . . $ structGraphics#paperHeight. * 72 * mycxx . . $ `melder/melder.h:44:9`! magnificationcxx . . $ structGraphicsPostscript#magnification.)); |
| 89 | } |
| 90 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%.6g dup scale\n", 72.0 * mycxx . . $ `melder/melder.h:44:9`! magnificationcxx . . $ structGraphicsPostscript#magnification. / mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution.); |
| 91 | if (mycxx . . $ `melder/melder.h:44:9`! jobcxx . . $ structGraphicsPostscript#job.) mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%EndPageSetup\n"); |
| 92 | mycxx . . $ `melder/melder.h:44:9`! lastFidcxx . . $ structGraphicsPostscript#lastFid. = nullptr; |
| 93 | } |
| 94 | |
| 95 | static void exitPagecxx . . $ exitPage(b3e8c95126eb3d7a). (GraphicsPostscriptcxx . . $ GraphicsPostscript# me) { |
| 96 | int font, style; |
| 97 | /* |
| 98 | * A showpage is only needed if we are printing to a file. |
| 99 | * If we are printing directly to a printer, the page will be ejected |
| 100 | * by EndPage (Windows NT/2000/XP/Vista) or PMSessionEndPage (MacOSX). |
| 101 | */ |
| 102 | if (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file.) { |
| 103 | if (mycxx . . $ `melder/melder.h:44:9`! jobcxx . . $ structGraphicsPostscript#job.) { |
| 104 | /*my d_printf (my d_file, "restore\n");*/ |
| 105 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "showpage\n"); |
| 106 | } else if (mycxx . . $ `melder/melder.h:44:9`! epscxx . . $ structGraphicsPostscript#eps.) { |
| 107 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "showpage %% redefined by encapsulating program\n"); |
| 108 | } |
| 109 | } |
| 110 | for (font = 0; font <= kGraphics_font_DINGBATScxx . . $ `sys/GraphicsP.h:41:9`!; font ++) |
| 111 | for (style = 0; style <= Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`!; style ++) |
| 112 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`! (mycxx . . $ `melder/melder.h:44:9`! fontInfos [font] [style]); |
| 113 | mycxx . . $ `melder/melder.h:44:9`! loadedXipacxx . . $ structGraphicsPostscript#loadedXipa. = false; // FIXME: include this because of the unpredictable page order with DSC? |
| 114 | } |
| 115 | |
| 116 | void structGraphicsPostscriptcxx . . $ structGraphicsPostscript# :: v9_destroycxx . . $ structGraphicsPostscript#v9_destroy(ced63f7c635d850d). () noexcept { |
| 117 | exitPagecxx . . $ exitPage(b3e8c95126eb3d7a). (this); |
| 118 | if (ourcxx . . $ `melder/melder.h:42:9`! d_filecxx . . $ structGraphicsPostscript#d_file.) { |
| 119 | if (ourcxx . . $ `melder/melder.h:42:9`! jobcxx . . $ structGraphicsPostscript#job.) { |
| 120 | ourcxx . . $ `melder/melder.h:42:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (ourcxx . . $ `melder/melder.h:42:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%Trailer\n"); |
| 121 | ourcxx . . $ `melder/melder.h:42:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (ourcxx . . $ `melder/melder.h:42:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%Pages: %d\n", ourcxx . . $ `melder/melder.h:42:9`! pageNumbercxx . . $ structGraphicsPostscript#pageNumber.); |
| 122 | } |
| 123 | ourcxx . . $ `melder/melder.h:42:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (ourcxx . . $ `melder/melder.h:42:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%EOF\n"); // BUG. Correct according to DSC. But not good in EPS files? |
| 124 | fclose (ourcxx . . $ `melder/melder.h:42:9`! d_filecxx . . $ structGraphicsPostscript#d_file.); |
| 125 | } |
| 126 | GraphicsPostscript_Parentcxx . . $ GraphicsPostscript_Parent# :: v9_destroycxx . . $ structGraphics#v9_destroy(ced63f7c635d850d). (); |
| 127 | } |
| 128 | |
| 129 | autoGraphicscxx . . $ autoGraphics# Graphics_create_postscriptjobcxx . . $ Graphics_create_postscriptjob(9faa091b4e8e8b45). (MelderFilecxx . . $ MelderFile# file, int resolution, kGraphicsPostscript_spotscxx . . $ kGraphicsPostscript_spots# spots, |
| 130 | kGraphicsPostscript_paperSizecxx . . $ kGraphicsPostscript_paperSize# paperSize, kGraphicsPostscript_orientationcxx . . $ kGraphicsPostscript_orientation# rotation, double magnification) |
| 131 | { |
| 132 | autoGraphicsPostscriptcxx . . $ autoGraphicsPostscript# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (GraphicsPostscript); |
| 133 | time_t today; |
| 134 | mycxx . . $ `melder/melder.h:44:9`! postScriptcxx . . $ structGraphics#postScript. = true, mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. = false, mycxx . . $ `melder/melder.h:44:9`! languageLevelcxx . . $ structGraphicsPostscript#languageLevel. = 2; |
| 135 | mycxx . . $ `melder/melder.h:44:9`! jobcxx . . $ structGraphicsPostscript#job. = true, mycxx . . $ `melder/melder.h:44:9`! epscxx . . $ structGraphicsPostscript#eps. = false, mycxx . . $ `melder/melder.h:44:9`! printercxx . . $ structGraphics#printer. = false; |
| 136 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. = (int (*)(void *, const char*, ...)) fprintf; |
| 137 | Graphics_initcxx . . $ Graphics_init(9abe41586e87648d). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), resolution); // virtual resolution; may differ from that of the printer; OK if always 600 dpi |
| 138 | mycxx . . $ `melder/melder.h:44:9`! photocopyablecxx . . $ structGraphicsPostscript#photocopyable. = spots == kGraphicsPostscript_spotscxx . . $ kGraphicsPostscript_spots#::PHOTOCOPYABLEcxx . . $ kGraphicsPostscript_spots#PHOTOCOPYABLE.; |
| 139 | if (mycxx . . $ `melder/melder.h:44:9`! photocopyablecxx . . $ structGraphicsPostscript#photocopyable.) { mycxx . . $ `melder/melder.h:44:9`! spotsDensitycxx . . $ structGraphicsPostscript#spotsDensity. = 85; mycxx . . $ `melder/melder.h:44:9`! spotsAnglecxx . . $ structGraphicsPostscript#spotsAngle. = 35; } |
| 140 | else { mycxx . . $ `melder/melder.h:44:9`! spotsDensitycxx . . $ structGraphicsPostscript#spotsDensity. = 106; mycxx . . $ `melder/melder.h:44:9`! spotsAnglecxx . . $ structGraphicsPostscript#spotsAngle. = 46; } |
| 141 | if (paperSize == kGraphicsPostscript_paperSizecxx . . $ kGraphicsPostscript_paperSize#::A3cxx . . $ kGraphicsPostscript_paperSize#A3.) mycxx . . $ `melder/melder.h:44:9`! paperWidthcxx . . $ structGraphics#paperWidth. = 842 / 72.0, mycxx . . $ `melder/melder.h:44:9`! paperHeightcxx . . $ structGraphics#paperHeight. = 1191 / 72.0; |
| 142 | else if (paperSize == kGraphicsPostscript_paperSizecxx . . $ kGraphicsPostscript_paperSize#::US_LETTERcxx . . $ kGraphicsPostscript_paperSize#US_LETTER.) mycxx . . $ `melder/melder.h:44:9`! paperWidthcxx . . $ structGraphics#paperWidth. = 612 / 72.0, mycxx . . $ `melder/melder.h:44:9`! paperHeightcxx . . $ structGraphics#paperHeight. = 792 / 72.0; |
| 143 | else mycxx . . $ `melder/melder.h:44:9`! paperWidthcxx . . $ structGraphics#paperWidth. = 595 / 72.0, mycxx . . $ `melder/melder.h:44:9`! paperHeightcxx . . $ structGraphics#paperHeight. = 842 / 72.0; |
| 144 | mycxx . . $ `melder/melder.h:44:9`! landscapecxx . . $ structGraphicsPostscript#landscape. = rotation == kGraphicsPostscript_orientationcxx . . $ kGraphicsPostscript_orientation#::LANDSCAPEcxx . . $ kGraphicsPostscript_orientation#LANDSCAPE.; |
| 145 | mycxx . . $ `melder/melder.h:44:9`! magnificationcxx . . $ structGraphicsPostscript#magnification. = magnification; |
| 146 | mycxx . . $ `melder/melder.h:44:9`! includeFontscxx . . $ structGraphicsPostscript#includeFonts. = true; |
| 147 | mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file. = Melder_fopencxx . . $ Melder_fopen(feb98de266255aea). (file, "w"); |
| 148 | /* |
| 149 | * The Device Coordinates are the PostScript user coordinates. |
| 150 | * They are chosen in such a way that a distance of 1 in device coordinates |
| 151 | * equals one dot if the printer's resolution is 'resolution' dots per inch. |
| 152 | * Take a sensible default margin: half an inch on all sides. |
| 153 | */ |
| 154 | mycxx . . $ `melder/melder.h:44:9`! d_x1DCcxx . . $ structGraphics#d_x1DC. = mycxx . . $ `melder/melder.h:44:9`! d_x1DCmincxx . . $ structGraphics#d_x1DCmin. = resolution / 2; |
| 155 | mycxx . . $ `melder/melder.h:44:9`! d_x2DCcxx . . $ structGraphics#d_x2DC. = mycxx . . $ `melder/melder.h:44:9`! d_x2DCmaxcxx . . $ structGraphics#d_x2DCmax. = (mycxx . . $ `melder/melder.h:44:9`! paperWidthcxx . . $ structGraphics#paperWidth. - 0.5) * resolution; |
| 156 | mycxx . . $ `melder/melder.h:44:9`! d_y1DCcxx . . $ structGraphics#d_y1DC. = mycxx . . $ `melder/melder.h:44:9`! d_y1DCmincxx . . $ structGraphics#d_y1DCmin. = resolution / 2; |
| 157 | mycxx . . $ `melder/melder.h:44:9`! d_y2DCcxx . . $ structGraphics#d_y2DC. = mycxx . . $ `melder/melder.h:44:9`! d_y2DCmaxcxx . . $ structGraphics#d_y2DCmax. = (mycxx . . $ `melder/melder.h:44:9`! paperHeightcxx . . $ structGraphics#paperHeight. - 0.5) * resolution; |
| 158 | /* |
| 159 | * Now don't just set x1wNDC etc, but force computation of the scaling as well. |
| 160 | */ |
| 161 | Graphics_setWsWindowcxx . . $ Graphics_setWsWindow(72bdb7937dbb13da). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0, mycxx . . $ `melder/melder.h:44:9`! paperWidthcxx . . $ structGraphics#paperWidth. - 1.0, 12.000 - (mycxx . . $ `melder/melder.h:44:9`! paperHeightcxx . . $ structGraphics#paperHeight. - 1.0), 12.000); |
| 162 | /* |
| 163 | * We will adhere to version 3.0 of the Document Structuring Conventions for print jobs. |
| 164 | */ |
| 165 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%!PS-Adobe-3.0\n"); |
| 166 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%Creator: Praat Shell 4.2\n"); |
| 167 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%Title: %s\n", Melder_peek32to8_fileSystemcxx . . $ Melder_peek32to8_fileSystem(c6a971952cbb8e31). (MelderFile_namecxx . . $ MelderFile_name(d9f043369fa9b55b). (file))); |
| 168 | today = time (nullptr); |
| 169 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%CreationDate: %s", ctime (& today)); // contains newline symbol |
| 170 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%PageOrder: Special\n"); |
| 171 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%Pages: (atend)\n"); |
| 172 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%EndComments\n"); |
| 173 | downloadPrologAndSetUpcxx . . $ downloadPrologAndSetUp(b3e8c95126eb3d7a). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 174 | initPagecxx . . $ initPage(b3e8c95126eb3d7a). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 175 | return mecxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 176 | } |
| 177 | |
| 178 | #if defined (macintosh) |
| 179 | static int Eps_postScript_printf (void *stream, const char *format, ... ) { |
| 180 | constexpr integer bufferSize = 3002; |
| 181 | static char theLine [bufferSize]; |
| 182 | char *p; |
| 183 | va_list args; |
| 184 | va_start (args, format); |
| 185 | vsnprintf (theLine, bufferSize, format, args); |
| 186 | theLine [bufferSize - 1] = '\0'; |
| 187 | va_end (args); |
| 188 | for (p = theLine; *p != '\0'; p ++) |
| 189 | if (*p == '\n') |
| 190 | *p = '\r'; |
| 191 | return (int) fwrite (theLine, sizeof (char), strlen (theLine), reinterpret_cast <FILE *> (stream)); |
| 192 | } |
| 193 | #endif |
| 194 | |
| 195 | autoGraphicscxx . . $ autoGraphics# Graphics_create_epsfilecxx . . $ Graphics_create_epsfile(acf596eda8b563dd). (MelderFilecxx . . $ MelderFile# file, int resolution, enum kGraphicsPostscript_spotscxx . . $ kGraphicsPostscript_spots# spots, |
| 196 | double x1inches, double x2inches, double y1inches, double y2inches, bool includeFonts, bool useSilipaPS) |
| 197 | { |
| 198 | autoGraphicsPostscriptcxx . . $ autoGraphicsPostscript# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (GraphicsPostscript); |
| 199 | time_t today; |
| 200 | integercxx . . $ integer# left, right, top, bottom; |
| 201 | mycxx . . $ `melder/melder.h:44:9`! postScriptcxx . . $ structGraphics#postScript. = true, mycxx . . $ `melder/melder.h:44:9`! languageLevelcxx . . $ structGraphicsPostscript#languageLevel. = 2; |
| 202 | mycxx . . $ `melder/melder.h:44:9`! jobcxx . . $ structGraphicsPostscript#job. = false, mycxx . . $ `melder/melder.h:44:9`! epscxx . . $ structGraphicsPostscript#eps. = true, mycxx . . $ `melder/melder.h:44:9`! printercxx . . $ structGraphics#printer. = false; |
| 203 | #if defined (macintosh) |
| 204 | /* Replace newlines with carriage returns to be compatible with MS Word 5.1. */ |
| 205 | my d_printf = Eps_postScript_printf; |
| 206 | #else |
| 207 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. = (int (*)(void *, const char*, ...)) fprintf; |
| 208 | #endif |
| 209 | Graphics_initcxx . . $ Graphics_init(9abe41586e87648d). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), resolution); // virtual resolution; may differ from that of the printer; OK if always 600 dpi |
| 210 | mycxx . . $ `melder/melder.h:44:9`! photocopyablecxx . . $ structGraphicsPostscript#photocopyable. = spots == kGraphicsPostscript_spotscxx . . $ kGraphicsPostscript_spots#::PHOTOCOPYABLEcxx . . $ kGraphicsPostscript_spots#PHOTOCOPYABLE.; |
| 211 | if (mycxx . . $ `melder/melder.h:44:9`! photocopyablecxx . . $ structGraphicsPostscript#photocopyable.) { mycxx . . $ `melder/melder.h:44:9`! spotsDensitycxx . . $ structGraphicsPostscript#spotsDensity. = 85; mycxx . . $ `melder/melder.h:44:9`! spotsAnglecxx . . $ structGraphicsPostscript#spotsAngle. = 35; } |
| 212 | else { mycxx . . $ `melder/melder.h:44:9`! spotsDensitycxx . . $ structGraphicsPostscript#spotsDensity. = 106; mycxx . . $ `melder/melder.h:44:9`! spotsAnglecxx . . $ structGraphicsPostscript#spotsAngle. = 46; } |
| 213 | mycxx . . $ `melder/melder.h:44:9`! paperWidthcxx . . $ structGraphics#paperWidth. = 7.5, mycxx . . $ `melder/melder.h:44:9`! paperHeightcxx . . $ structGraphics#paperHeight. = 11.0; |
| 214 | mycxx . . $ `melder/melder.h:44:9`! landscapecxx . . $ structGraphicsPostscript#landscape. = false; |
| 215 | mycxx . . $ `melder/melder.h:44:9`! magnificationcxx . . $ structGraphicsPostscript#magnification. = 1.0; |
| 216 | mycxx . . $ `melder/melder.h:44:9`! includeFontscxx . . $ structGraphicsPostscript#includeFonts. = includeFonts; |
| 217 | mycxx . . $ `melder/melder.h:44:9`! useSilipaPScxx . . $ structGraphicsPostscript#useSilipaPS. = useSilipaPS; |
| 218 | mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file. = Melder_fopencxx . . $ Melder_fopen(feb98de266255aea). (file, "w"); |
| 219 | mycxx . . $ `melder/melder.h:44:9`! d_x1DCcxx . . $ structGraphics#d_x1DC. = mycxx . . $ `melder/melder.h:44:9`! d_x1DCmincxx . . $ structGraphics#d_x1DCmin. = 0; |
| 220 | mycxx . . $ `melder/melder.h:44:9`! d_x2DCcxx . . $ structGraphics#d_x2DC. = mycxx . . $ `melder/melder.h:44:9`! d_x2DCmaxcxx . . $ structGraphics#d_x2DCmax. = mycxx . . $ `melder/melder.h:44:9`! paperWidthcxx . . $ structGraphics#paperWidth. * resolution; // 600 dpi -> 4500 virtual dots |
| 221 | mycxx . . $ `melder/melder.h:44:9`! d_y1DCcxx . . $ structGraphics#d_y1DC. = mycxx . . $ `melder/melder.h:44:9`! d_y1DCmincxx . . $ structGraphics#d_y1DCmin. = 0; |
| 222 | mycxx . . $ `melder/melder.h:44:9`! d_y2DCcxx . . $ structGraphics#d_y2DC. = mycxx . . $ `melder/melder.h:44:9`! d_y2DCmaxcxx . . $ structGraphics#d_y2DCmax. = mycxx . . $ `melder/melder.h:44:9`! paperHeightcxx . . $ structGraphics#paperHeight. * resolution; // 600 dpi -> 6600 virtual dots |
| 223 | Graphics_setWsWindowcxx . . $ Graphics_setWsWindow(72bdb7937dbb13da). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0, mycxx . . $ `melder/melder.h:44:9`! paperWidthcxx . . $ structGraphics#paperWidth., 12.0 - mycxx . . $ `melder/melder.h:44:9`! paperHeightcxx . . $ structGraphics#paperHeight., 12.0); // force scaling |
| 224 | /* |
| 225 | * We will honour version 3.0 of the DSC for Encapsulated PostScript files, |
| 226 | * which includes supplying the bounding box information. |
| 227 | */ |
| 228 | left = Melder_ifloorcxx . . $ `melder/melder_ftoi.h:33:9`! (x1inches * 72); |
| 229 | right = Melder_iceilingcxx . . $ `melder/melder_ftoi.h:45:9`! (x2inches * 72); |
| 230 | top = Melder_iceilingcxx . . $ `melder/melder_ftoi.h:45:9`! ((y2inches - mycxx . . $ `melder/melder.h:44:9`! d_y1wNDCcxx . . $ structGraphics#d_y1wNDC.) * 72); |
| 231 | bottom = Melder_ifloorcxx . . $ `melder/melder_ftoi.h:33:9`! ((y1inches - mycxx . . $ `melder/melder.h:44:9`! d_y1wNDCcxx . . $ structGraphics#d_y1wNDC.) * 72); |
| 232 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%!PS-Adobe-3.0 EPSF-3.0\n"); |
| 233 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%BoundingBox: %d %d %d %d\n", left, bottom, right, top); |
| 234 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%Creator: Praat Shell 5.1\n"); |
| 235 | /* |
| 236 | * In an EPS file without screen preview, the file name will be visible anyway. |
| 237 | * This leaves us room to show a warning that should keep users from thinking anything is wrong. |
| 238 | */ |
| 239 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%Title: NO SCREEN PREVIEW, BUT WILL PRINT CORRECTLY\n"); |
| 240 | today = time (nullptr); |
| 241 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%CreationDate: %s", ctime (& today)); /* Contains newline symbol. */ |
| 242 | mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%%%%EndComments\n"); |
| 243 | downloadPrologAndSetUpcxx . . $ downloadPrologAndSetUp(b3e8c95126eb3d7a). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 244 | initPagecxx . . $ initPage(b3e8c95126eb3d7a). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 245 | return mecxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 246 | } |
| 247 | |
| 248 | #if defined (_WIN32) |
| 249 | autoGraphics Graphics_create_postscriptprinter () { |
| 250 | autoGraphicsPostscript me = Thing_new (GraphicsPostscript); |
| 251 | my postScript = true, my languageLevel = 2; |
| 252 | my job = false, my eps = false, my printer = true; |
| 253 | my d_printf = Printer_postScript_printf; |
| 254 | Graphics_init (me.get(), thePrinter. resolution); // virtual resolution |
| 255 | my photocopyable = thePrinter. spots == kGraphicsPostscript_spots::PHOTOCOPYABLE; |
| 256 | if (my photocopyable) { my spotsDensity = 85; my spotsAngle = 35; } |
| 257 | else { my spotsDensity = 106; my spotsAngle = 46; } |
| 258 | my paperWidth = (double) thePrinter. paperWidth / my resolution; |
| 259 | my paperHeight = (double) thePrinter. paperHeight / my resolution; |
| 260 | my landscape = thePrinter. orientation == kGraphicsPostscript_orientation::LANDSCAPE; |
| 261 | my magnification = thePrinter. magnification; |
| 262 | my includeFonts = true; |
| 263 | my d_x1DC = my d_x1DCmin = my resolution / 2; |
| 264 | my d_x2DC = my d_x2DCmax = (my paperWidth - 0.5) * my resolution; |
| 265 | my d_y1DC = my d_y1DCmin = my resolution / 2; |
| 266 | my d_y2DC = my d_y2DCmax = (my paperHeight - 0.5) * my resolution; |
| 267 | Graphics_setWsWindow (me.get(), 0, my paperWidth - 1.0, 13.0 - my paperHeight, 12.0); |
| 268 | downloadPrologAndSetUp (me.get()); |
| 269 | initPage (me.get()); |
| 270 | return me.move(); |
| 271 | } |
| 272 | #endif |
| 273 | |
| 274 | void Graphics_nextSheetOfPapercxx . . $ Graphics_nextSheetOfPaper(2d838ed765120c5d). (Graphicscxx . . $ Graphics# graphics) { |
| 275 | if (graphics -> postScriptcxx . . $ structGraphics#postScript.) { |
| 276 | GraphicsPostscriptcxx . . $ GraphicsPostscript# me = static_cast <GraphicsPostscriptcxx . . $ GraphicsPostscript#> (graphics); |
| 277 | exitPagecxx . . $ exitPage(b3e8c95126eb3d7a). (me); |
| 278 | if (mycxx . . $ `melder/melder.h:44:9`! printercxx . . $ structGraphics#printer.) Printer_nextPagecxx . . $ Printer_nextPage(49f6e7a06ebc5aa8). (); |
| 279 | initPagecxx . . $ initPage(b3e8c95126eb3d7a). (me); |
| 280 | } else if (graphics -> printercxx . . $ structGraphics#printer.) { |
| 281 | Printer_nextPagecxx . . $ Printer_nextPage(49f6e7a06ebc5aa8). (); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | /* End of file GraphicsPostscript.cpp */ |