diff --git a/.gitignore b/.gitignore index 91b292e..79ff41e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ label/ build/ -dist/ logs/ pdf_backup/ conf/ghostscript/ diff --git a/dist/LabelPrinter.exe b/dist/LabelPrinter.exe new file mode 100644 index 0000000..1c211b9 Binary files /dev/null and b/dist/LabelPrinter.exe differ diff --git a/dist/conf/SumatraPDF-settings.txt b/dist/conf/SumatraPDF-settings.txt new file mode 100644 index 0000000..a8f6f8e --- /dev/null +++ b/dist/conf/SumatraPDF-settings.txt @@ -0,0 +1,94 @@ +# For documentation, see https://www.sumatrapdfreader.org/settings/settings3-5-1.html +Theme = Light +FixedPageUI [ + TextColor = #000000 + BackgroundColor = #ffffff + SelectionColor = #f5fc0c + WindowMargin = 2 4 2 4 + PageSpacing = 4 4 + InvertColors = false + HideScrollbars = false +] +ComicBookUI [ + WindowMargin = 0 0 0 0 + PageSpacing = 4 4 + CbxMangaMode = false +] +ChmUI [ + UseFixedPageUI = false +] + +SelectionHandlers [ +] +ExternalViewers [ +] + +ZoomLevels = 8.33 12.5 18 25 33.33 50 66.67 75 100 125 150 200 300 400 600 800 1000 1200 1600 2000 2400 3200 4800 6400 +ZoomIncrement = 0 + +PrinterDefaults [ + PrintScale = noscale +] +ForwardSearch [ + HighlightOffset = 0 + HighlightWidth = 15 + HighlightColor = #6581ff + HighlightPermanent = false +] +Annotations [ + HighlightColor = #ffff00 + UnderlineColor = #00ff00 + SquigglyColor = #ff00ff + StrikeOutColor = #ff0000 + FreeTextColor = + FreeTextSize = 12 + FreeTextBorderWidth = 1 + TextIconColor = + TextIconType = + DefaultAuthor = +] + +RememberOpenedFiles = true +RememberStatePerDocument = true +RestoreSession = true +UiLanguage = en +EnableTeXEnhancements = false +DefaultDisplayMode = automatic +DefaultZoom = fit page +Shortcuts [ +] +EscToExit = false +ReuseInstance = false +ReloadModifiedDocuments = true + +MainWindowBackground = #80fff200 +FullPathInTitle = false +ShowMenubar = true +ShowToolbar = true +ShowFavorites = false +ShowToc = true +NoHomeTab = false +TocDy = 0 +SidebarDx = 0 +ToolbarSize = 18 +TabWidth = 300 +TreeFontSize = 0 +TreeFontWeightOffset = 0 +TreeFontName = automatic +SmoothScroll = false +ShowStartPage = false +CheckForUpdates = true +WindowState = 1 +WindowPos = 566 0 788 1020 +UseTabs = true +UseSysColors = false +CustomScreenDPI = 0 + +FileStates [ +] +SessionData [ +] +TimeOfLastUpdateCheck = 0 0 +OpenCountWeek = 790 + +# Settings below are not recognized by the current version diff --git a/dist/conf/SumatraPDF.exe b/dist/conf/SumatraPDF.exe new file mode 100644 index 0000000..f034e5e Binary files /dev/null and b/dist/conf/SumatraPDF.exe differ diff --git a/dist/conf/accepted.png b/dist/conf/accepted.png new file mode 100644 index 0000000..d0d769d Binary files /dev/null and b/dist/conf/accepted.png differ diff --git a/dist/conf/app.conf b/dist/conf/app.conf new file mode 100644 index 0000000..a68db1d --- /dev/null +++ b/dist/conf/app.conf @@ -0,0 +1,4 @@ +[Settings] +file_path = C:\temp\check.txt +printer = PDF + diff --git a/dist/conf/ghostscript/bin/gsdll64.dll b/dist/conf/ghostscript/bin/gsdll64.dll new file mode 100644 index 0000000..6990712 Binary files /dev/null and b/dist/conf/ghostscript/bin/gsdll64.dll differ diff --git a/dist/conf/ghostscript/bin/gswin64c.exe b/dist/conf/ghostscript/bin/gswin64c.exe new file mode 100644 index 0000000..d9a546d Binary files /dev/null and b/dist/conf/ghostscript/bin/gswin64c.exe differ diff --git a/dist/conf/ghostscript/lib/PDFA_def.ps b/dist/conf/ghostscript/lib/PDFA_def.ps new file mode 100644 index 0000000..96cb677 --- /dev/null +++ b/dist/conf/ghostscript/lib/PDFA_def.ps @@ -0,0 +1,91 @@ +%! +% This is a sample prefix file for creating a PDF/A document. +% Users should modify entries marked with "Customize". +% This assumes an ICC profile resides in the file (srgb.icc), +% in the current directory unless the user modifies the corresponding line below. + +% Define entries in the document Info dictionary : +[ /Title (Title) % Customise + /DOCINFO pdfmark + +% Define an ICC profile : +/ICCProfile (srgb.icc) % Customise +def + +[/_objdef {icc_PDFA} /type /stream /OBJ pdfmark + +%% This code attempts to set the /N (number of components) key for the ICC colour space. +%% To do this it checks the ColorConversionStrategy or the device ProcessColorModel if +%% ColorConversionStrategy is not set. +%% This is not 100% reliable. A better solution is for the user to edit this and replace +%% the code between the ---8<--- lines with a simple declaration like: +%% /N 3 +%% where the value of N is the number of components from the profile defined in /ICCProfile above. +%% +[{icc_PDFA} +<< +%% ----------8<--------------8<-------------8<--------------8<---------- + systemdict /ColorConversionStrategy known { + systemdict /ColorConversionStrategy get cvn dup /Gray eq { + pop /N 1 false + }{ + dup /RGB eq { + pop /N 3 false + }{ + /CMYK eq { + /N 4 false + }{ + (\tColorConversionStrategy not a device space, falling back to ProcessColorModel, output may not be valid PDF/A.\n)= + true + } ifelse + } ifelse + } ifelse + } { + (\tColorConversionStrategy not set, falling back to ProcessColorModel, output may not be valid PDF/A.\n)= + true + } ifelse + + { + currentpagedevice /ProcessColorModel get + dup /DeviceGray eq { + pop /N 1 + }{ + dup /DeviceRGB eq { + pop /N 3 + }{ + dup /DeviceCMYK eq { + pop /N 4 + } { + (\tProcessColorModel not a device space.)= + /ProcessColorModel cvx /rangecheck signalerror + } ifelse + } ifelse + } ifelse + } if +%% ----------8<--------------8<-------------8<--------------8<---------- + +>> /PUT pdfmark +[ +{icc_PDFA} +{ICCProfile (r) file} stopped +{ + (\n\tFailed to open the supplied ICCProfile for reading. This may be due to\n) print + (\t an incorrect filename or a failure to add --permit-file-read=\n) print + (\t to the command line. This PostScript program needs to open the file\n) print + (\t and you must explicitly grant it permission to do so.\n\n) print + (\tPDF/A processing aborted, output may not be a PDF/A file.\n\n) print + cleartomark +} +{ + /PUT pdfmark + % Define the output intent dictionary : + + [/_objdef {OutputIntent_PDFA} /type /dict /OBJ pdfmark + [{OutputIntent_PDFA} << + /Type /OutputIntent % Must be so (the standard requires). + /S /GTS_PDFA1 % Must be so (the standard requires). + /DestOutputProfile {icc_PDFA} % Must be so (see above). + /OutputConditionIdentifier (sRGB) % Customize + >> /PUT pdfmark + [{Catalog} <> /PUT pdfmark +} ifelse diff --git a/dist/conf/ghostscript/lib/PDFX_def.ps b/dist/conf/ghostscript/lib/PDFX_def.ps new file mode 100644 index 0000000..77010b1 --- /dev/null +++ b/dist/conf/ghostscript/lib/PDFX_def.ps @@ -0,0 +1,126 @@ +%! +% This is a sample prefix file for creating a PDF/X-3 document. +% Users should modify entries marked with "Customize". +% This assumes an ICC profile resides in the file (ISO Coated sb.icc) +% in the current directory unless the user modifies the corresponding line below. + +% First up, attempt to ensure the user has set ColorConversionStrategy correctly. +% PDF/X-3 only permits Gray or CMYK in the output. +% +systemdict /ColorConversionStrategy known { + systemdict /ColorConversionStrategy get cvn dup /Gray ne exch /CMYK ne and +} { + (\nERROR: ColorConversionStrategy not set.)= + true +} ifelse +{ (ERROR: ColorConversionStrategy must be /DeviceGray or /DeviceCMYK.)= + /ColorConversionStrategy cvx /rangecheck signalerror +} if + + +% Define entries in the document Info dictionary : +% +systemdict /PDFX known {systemdict /PDFX get}{3} ifelse + +dup 1 eq { + [ /GTS_PDFXVersion (PDF/X-1a:2001) % Must be so (the standard requires). + /Title (Title) % Customize. + /Trapped /False % Must be so (Ghostscript doesn't provide other). + /DOCINFO pdfmark +} if +dup 3 eq { + [ /GTS_PDFXVersion (PDF/X-3:2002) % Must be so (the standard requires). + /Title (Title) % Customize. + /Trapped /False % Must be so (Ghostscript doesn't provide other). + /DOCINFO pdfmark +} if +4 eq { + [ /GTS_PDFXVersion (PDF/X-4) % Must be so (the standard requires). + /Title (Title) % Customize. + /Trapped /False % Must be so (Ghostscript doesn't provide other). + /DOCINFO pdfmark +} if + + +/ICCProfile (ISO Coated sb.icc) def % Customize or remove. + +% Define an ICC profile in the output, if the user specified one. +% +currentdict /ICCProfile known { + [/_objdef {icc_PDFX} /type /stream /OBJ pdfmark + +% This code attempts to set the /N (number of components) key for the ICC colour space. +% To do this it checks the ColorConversionStrategy or the device ProcessColorModel if +% ColorConversionStrategy is not set. +% This is not 100% reliable. A better solution is for the user to edit this and replace +% the code between the ---8<--- lines with a simple declaration like: +% /N 3 +% where the value of N is the number of components from the profile defined in /ICCProfile above. +% Note, if you don't set ColorConversionStrategy, the output will likely be invalid anyway. + [{icc_PDFX} << +% ----------8<--------------8<-------------8<--------------8<---------- + systemdict /ColorConversionStrategy known { + systemdict /ColorConversionStrategy get cvn dup /Gray eq { + pop /N 1 false + }{ + dup /RGB eq { + systemdict /PDFX known {systemdict /PDFX get}{3} ifelse + 4 lt { + (RGB is not a valid ColorConversionStrategy for PDF/X output)= + /ColorConversionStrategycvx /rangecheck signalerror + } if + }{ + /CMYK eq { + /N 4 false + }{ + (ColorConversionStrategy not a device space, falling back to ProcessColorModel, output may not be valid PDF/X.)= + true + } ifelse + } ifelse + } ifelse + } { + (ColorConversionStrategy not set, falling back to ProcessColorModel, output may not be valid PDF/X.)= + true + } ifelse + + { + currentpagedevice /ProcessColorModel get + dup /DeviceGray eq { + pop /N 1 + }{ + dup /DeviceRGB eq { + systemdict /PDFX known {systemdict /PDFX get}{3} ifelse + 4 lt { + (RGB is not a valid ProcessColorModel for PDF/X output)= + /ColorConversionStrategycvx /rangecheck signalerror + } if + }{ + dup /DeviceCMYK eq { + pop /N 4 + } { + (ProcessColorModel not a device space.)= + /ProcessColorModel cvx /rangecheck signalerror + } ifelse + } ifelse + } ifelse + } if +% ----------8<--------------8<-------------8<--------------8<---------- + >> /PUT pdfmark + [{icc_PDFX} ICCProfile (r) file /PUT pdfmark +} if + +% Define the output intent dictionary : + +[/_objdef {OutputIntent_PDFX} /type /dict /OBJ pdfmark +[{OutputIntent_PDFX} << + /Type /OutputIntent % Must be so (the standard requires). + /S /GTS_PDFX % Must be so (the standard requires). + /OutputCondition (Commercial and specialty printing) % Customize + /Info (none) % Customize + /OutputConditionIdentifier (CGATS TR001) % Customize + /RegistryName (http://www.color.org) % Must be so (the standard requires). + currentdict /ICCProfile known { + /DestOutputProfile {icc_PDFX} % Must be so (see above). + } if +>> /PUT pdfmark +[{Catalog} <> /PUT pdfmark diff --git a/dist/conf/ghostscript/lib/acctest.ps b/dist/conf/ghostscript/lib/acctest.ps new file mode 100644 index 0000000..2af46be --- /dev/null +++ b/dist/conf/ghostscript/lib/acctest.ps @@ -0,0 +1,99 @@ +%! +% Check that operators do their access tests correctly. + +% proc dotest => . +/dotest + { + dup + mark + exch + stopped not % False if error, true if no error. + { (Allowed access: ) print cleartomark == } + if + clear + } +def + +0 0 moveto % So the show commands don't bomb because of nocurrentpoint. + +{ [1 2] executeonly aload } dotest +{ (string) executeonly (seek) anchorsearch } dotest +{ (string) (seek) executeonly anchorsearch } dotest +{ 100 101 (string) noaccess ashow} dotest +{ 100 1 array readonly astore } dotest +{ 100 101 102 103 104 (string) noaccess awidthshow } dotest +{ 1 dict noacess begin } dotest +{ 1 array executeonly 1 array copy } dotest +{ 1 array 1 array readonly copy } dotest +{ 1 dict noaccess 1 dict copy } dotest +{ 1 dict 1 dict readonly copy } dotest +{ 1 string executeonly 1 string copy } dotest +{ 1 string 1 string readonly copy } dotest +{ (100) executeonly cvi } dotest +{ (string) executeonly cvn } dotest +{ (100.001) executeonly cvr } dotest +{ 1 10 1 string readonly cvrs } dotest +{ true 5 string readonly cvs } dotest +{ 1 dict readonly begin /foo true def } dotest +{ 10 array readonly dictstack } dotest +{ 1 string executeonly 1 string eq } dotest +{ 1 string 1 string executeonly eq } dotest +{ 10 array readonly execstack } dotest +{ 1 string noaccess executeonly } dotest +{ 1 array noaccess executeonly } dotest +{ 1 array executeonly { pop } forall } dotest +{ 1 dict noaccess { pop pop } forall } dotest +{ 1 string executeonly { pop } forall } dotest +{ (string1) executeonly (string2) ge } dotest +{ (string1) (string2) executeonly ge } dotest +{ 1 array executeonly 0 get } dotest +{ 1 dict noaccess /key get } dotest +{ 1 string executeonly 0 get } dotest +{ 1 array executeonly 0 1 getinterval } dotest +{ 1 string executeonly 0 1 getinterval } dotest +{ (string1) executeonly (string2) gt } dotest +{ (string1) (string2) executeonly gt } dotest +{ 1 dict noaccess /key known } dotest +{ {} (string) executeonly kshow } dotest +{ (string1) executeonly (string2) le } dotest +{ (string1) (string2) executeonly le } dotest +{ 1 array executeonly length } dotest +{ 1 dict noaccess length } dotest +{ 1 string executeonly length } dotest +%%{ /foo 1 dict def foo begin /bar foo def bar noaccess pop /key load } dotest +{ (string1) executeonly (string2) lt } dotest +{ (string1) (string2) executeonly lt } dotest +{ 1 dict noaccess maxlength } dotest +{ 1 string executeonly 1 string ne } dotest +{ 1 string 1 string executeonly ne } dotest +%{ newpath 0 0 moveto (a) false charpath +% {} {} {} {} pathforall closepath } dotest +{ 1 array executeonly 0 put } dotest +{ 1 dict noaccess /key put } dotest +{ 1 string executeonly 0 put } dotest +{ 1 array executeonly 0 1 putinterval } dotest +{ 1 string executeonly 0 1 putinterval } dotest +{ (access.ps) (r) file executeonly read } dotest +{ (access.ps) (r) file executeonly 10 string readhexstring } dotest +{ (access.ps) (r) file 10 string readonly readhexstring } dotest +{ (access.ps) (r) file executeonly 100 string readline } dotest +{ (access.ps) (r) file 100 string readonly readline } dotest +{ (access.ps) (r) file executeonly 10 string readstring } dotest +{ (access.ps) (r) file 10 string readonly readstring } dotest +% run does not check for no read access? +{ (string) executeonly (seek) search } dotest +{ (string) (seek) executeonly search } dotest +{ (string) executeonly show } +%% some test for store. +{ (string) executeonly stringwidth } dotest +{ (access.ps) (r) file executeonly token } dotest +{ (10) executeonly token } dotest +{ /foo 1 dict def foo begin /bar foo def bar noaccess pop /key where } dotest +{ 100 101 102 (string) noaccess widthshow } dotest +{ (/tmp/_.ps) noaccess (w) file closefile } dotest +{ (/tmp/_.ps) (w) noaccess file closefile } dotest +{ (/tmp/_.ps) (w) file executeonly 100 write } dotest +{ (/tmp/_.ps) (w) file executeonly 10 string writehexstring } dotest +{ (/tmp/_.ps) (w) file 10 string executeonly writehexstring } dotest +{ (/tmp/_.ps) (w) file executeonly 10 string writestring } dotest +{ (/tmp/_.ps) (w) file 10 string executeonly writestring } dotest diff --git a/dist/conf/ghostscript/lib/align.ps b/dist/conf/ghostscript/lib/align.ps new file mode 100644 index 0000000..ae5b21e --- /dev/null +++ b/dist/conf/ghostscript/lib/align.ps @@ -0,0 +1,72 @@ +% Copyright (C) 2001-2023 Artifex Software, Inc. +% All Rights Reserved. +% +% This software is provided AS-IS with no warranty, either express or +% implied. +% +% This software is distributed under license and may not be copied, +% modified or distributed except as expressly authorized under the terms +% of the license contained in the file LICENSE in this distribution. +% +% Refer to licensing information at http://www.artifex.com or contact +% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, +% CA 94129, USA, for further information. +% + +% Print a page that indicates the proper settings of Margins and HWMargins +% for a given device. Requires a Level 2 system. + +% Reset the offset and margins. + +<< + /PageOffset [0 0] + /Margins [0 0] + /.HWMargins [0 0 0 0] +>> +setpagedevice +<< + /ImagingBBox null +>> +setpagedevice + +% Determine the actual page size. + +clippath pathbbox newpath +/y1 exch def /x1 exch def pop pop + +% Draw lines that should be exactly 1" in from each edge, +% and should extend precisely to the edge of the paper. + +1 setlinewidth +0 setgray +72 0 moveto 0 y1 rlineto stroke +0 72 moveto x1 0 rlineto stroke + +% Print the text in the middle of the page. + +/S 80 string def +108 480 moveto +/Helvetica 12 selectfont + { currentfile S readline pop dup (%END) eq { pop exit } if + gsave show grestore 0 -15 rmoveto + } loop +Let the distance in inches from the left edge of the page to +the vertical line be H, and from the bottom edge to the +horizontal line be V; let the lengths of the gaps at the top +and bottom of the vertical line be T and B respectively, and +the gaps at the left and right of the horizontal line be L +and R. For correct alignment of pages, put the following line +in a file named (for example) margins.ps, and then mention +margins.ps on the gs command line when printing any of your +own files: + + << /.HWMargins [ml mb mr mt] /Margins [x y] >> setpagedevice + +where + ml = L * 72, mb = B * 72, mr = R * 72, mt = T * 72, +%END +/res currentpagedevice /HWResolution get def +( x = (1 - H) * ) show res 0 get =string cvs show +(, y = (V - 1) * ) show res 1 get =string cvs show + +showpage diff --git a/dist/conf/ghostscript/lib/caption.ps b/dist/conf/ghostscript/lib/caption.ps new file mode 100644 index 0000000..72b117b --- /dev/null +++ b/dist/conf/ghostscript/lib/caption.ps @@ -0,0 +1,58 @@ +%! +% Copyright (C) 2001-2023 Artifex Software, Inc. +% All Rights Reserved. +% +% This software is provided AS-IS with no warranty, either express or +% implied. +% +% This software is distributed under license and may not be copied, +% modified or distributed except as expressly authorized under the terms +% of the license contained in the file LICENSE in this distribution. +% +% Refer to licensing information at http://www.artifex.com or contact +% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, +% CA 94129, USA, for further information. +% + +% Add a "caption" to the bottom of each page. +/captionsize 20 def +/caption + { /Helvetica //captionsize selectfont + (Printed by Artifex's XXYYZZ) show + /Symbol //captionsize selectfont + (\324) show % trademarkserif + /Helvetica //captionsize selectfont + ( product) show + } bind def + +10 dict begin +gsave + initgraphics + clippath pathbbox + pop exch 36 add /by exch def + % We can't use stringwidth, so we have to show and measure. + gsave + 0 0 0 0 rectclip + 0 0 moveto caption currentpoint pop /bw exch def + grestore + add bw sub 2 div /bx exch def + % We don't have the font bbox available, so we guess. + /bh captionsize 1.05 mul def +grestore +/showcaption + { gsave + initgraphics + //bx 9 sub //by 9 sub //bw 18 add //bh 18 add + 1 setgray 4 copy rectfill 0 setgray 1.5 setlinewidth rectstroke + //bx //by moveto //caption exec + grestore + } bind def +<< /EndPage [ + %% + %% Only print the caption if 'reason' is not 2 (device deactivation) + %% + /dup load /exec load 2 /ne load /exec load [ /showcaption load /exec load ] cvx /if load /exec load + currentpagedevice /EndPage get /exec load + ] cvx +>> setpagedevice +end diff --git a/dist/conf/ghostscript/lib/cat.ps b/dist/conf/ghostscript/lib/cat.ps new file mode 100644 index 0000000..fd3698d --- /dev/null +++ b/dist/conf/ghostscript/lib/cat.ps @@ -0,0 +1,74 @@ +% Copyright (C) 2001-2023 Artifex Software, Inc. +% All Rights Reserved. +% +% This software is provided AS-IS with no warranty, either express or +% implied. +% +% This software is distributed under license and may not be copied, +% modified or distributed except as expressly authorized under the terms +% of the license contained in the file LICENSE in this distribution. +% +% Refer to licensing information at http://www.artifex.com or contact +% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, +% CA 94129, USA, for further information. +% +% +% $Id: cat.ps 8331 2008-02-05 11:07:00Z kens $ +% +% Appends one file to another. Primarily used to overcome the +% 'copy' limitation of Windows command shell for ps2epsi +% +% the files to be appended are given by the environament +% variables %infile% and %outfile%. %infile% is appended to +% %outfile% +% + +/datastring 1024 string def + +{ + (outfile) getenv + { + /outfilename exch def + (infile) getenv + { + /infilename exch def + + infilename status + { + pop pop pop pop outfilename status + { + pop pop pop pop + infilename (r) file /infile exch def + outfilename (a+) file /outfile exch def + { + infile datastring readstring + { + outfile exch writestring + } + { + dup length 0 gt + {outfile exch writestring} {pop} ifelse + exit + } ifelse + } loop + infile closefile + outfile closefile + } + { + (Failed to find file ) print outfilename == + } ifelse + } + { + (Failed to find file ) print infilename == + } ifelse + } + { + (Couldn't find %infile% environment variable) == + } ifelse + } + { + (Couldn't find %outfile% environment variable) == + } + ifelse +} bind +exec diff --git a/dist/conf/ghostscript/lib/cid2code.ps b/dist/conf/ghostscript/lib/cid2code.ps new file mode 100644 index 0000000..cafc92d --- /dev/null +++ b/dist/conf/ghostscript/lib/cid2code.ps @@ -0,0 +1,159 @@ +% Copyright (C) 2001-2023 Artifex Software, Inc. +% All Rights Reserved. +% +% This software is provided AS-IS with no warranty, either express or +% implied. +% +% This software is distributed under license and may not be copied, +% modified or distributed except as expressly authorized under the terms +% of the license contained in the file LICENSE in this distribution. +% +% Refer to licensing information at http://www.artifex.com or contact +% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, +% CA 94129, USA, for further information. +% + +% Construct an inverse map from CIDs to codes. + +% Create an inverse map from CIDs to code values. +% We only use this for 16-bit Unicode, so it has some limitations. +% After invoking .cmap2code, loading a CMap file prints out the map +% instead of doing what it usually does. For example: +% +% gs -dNODISPLAY -dBATCH lib/cid2code.ps -c .cmap2code\ +% -f Resource/CMap/UniJIS-UCS2-H > mapfile + +/.cmap2codedict 10 dict begin + +/begincmap { + mark +} def +/endcmap { + % Stack: mark code_lo1 code_hi1 cid1 ... + 20 dict begin + /depth counttomark 3 sub def + % Do a first pass to determine the maximum CID. + 0 0 3 depth { + 1 add /d exch def + d index d 2 add index 1 get add d 3 add index 1 get sub .max + } for + 1 add /ncid exch def + /map ncid 2 mul string def + % Now fill in the map. + 0 3 depth { + /d exch def + d index 2 mul /cid2 exch def + d 1 add index /hi exch def + d 2 add index 2 string copy /lo exch def + lo 1 get 1 hi 1 get { + map cid2 lo 0 get put + map cid2 1 add 3 -1 roll put + /cid2 cid2 2 add def + } for + } for + % Print the map. + (%stdout) (w) file + dup (<) print + dup /ASCIIHexEncode filter + dup map writestring + closefile + () = flush + closefile + end +} def +%/begincodespacerange +/endcodespacerange {cleartomark} def +%/usecmap + +%/beginbfchar +/endbfchar {cleartomark} def +%/beginbfrange +/endbfrange {cleartomark} def + +%/begincidchar +/endcidchar { + counttomark 2 idiv { dup counttomark 1 add 3 roll } repeat pop +} def +%/begincidrange +/endcidrange { + counttomark 1 add -1 roll pop +} def + +%/beginnotdefchar +/endnotdefchar {cleartomark} def +%/beginnotdefrange +/endnotdefrange {cleartomark} def + +currentdict end readonly def + +/.cmap2code { % - .cmap2code - + /CIDInit /ProcSet findresource dup length dict copy + .cmap2codedict { 3 copy put pop pop } forall + /CIDInit exch /ProcSet defineresource pop +} def + +% Extract and print reverse mapping information from a cid2code.txt file. +/.printhex2 { % .printhex2 - + (<) print + 16#10000 add 16 =string cvrs 1 4 getinterval print + (>) print +} def +/.cid2code { % .cid2code - + 30 dict begin + /column exch def + (r) file /f exch def + (%!) = + (/CIDInit /ProcSet findresource begin 12 dict begin begincmap) = + % Print the information from the template. + { + exch ==only ( ) print + dup type /dicttype eq { + dup length =only ( dict dup begin) = { + ( ) print exch ===only ( ) print ===only ( def) = + } forall (end def) = + } { + ===only + } ifelse ( def) = + } forall + % Read the data from the cid2code.txt file. + { + f =string readline pop (CID\t) anchorsearch { pop pop exit } if pop + } loop + /map [ { + f =string readline not { pop exit } if + column { (\t) search pop pop pop } repeat + (\t) search { exch pop exch pop } if + (,) search { exch pop exch pop } if + dup length 4 ne { pop (*) } if + dup (*) eq { pop (0000) } if + (16#) exch concatstrings cvi + } loop ] def + % Print the code space range(s). + /maxcid map length 1 sub def + mark maxcid + dup 255 and 255 eq { + 0 exch + } { + dup 16#ff00 and exch 0 2 index 1 sub + } ifelse + counttomark 2 idiv dup =only ( begincodespacerange) = { + exch .printhex2 .printhex2 () = + } repeat (endcodespacerange) = + % Print the map data. + 0 1 100 maxcid { + /lo exch def + /hi lo 99 add maxcid .min def + 0 lo 1 hi { map exch get 0 ne { 1 add } if } for + dup 0 eq { + pop + } { + =only ( begincidchar) = lo 1 hi { + map 1 index get dup 0 eq { pop pop } { exch .printhex2 = } ifelse + } for (endcidchar) = + } ifelse + } for + % Wrap up. + (endcmap CMapName currentdict /CMap defineresource pop end end) = + f closefile + end +} bind def diff --git a/dist/conf/ghostscript/lib/docie.ps b/dist/conf/ghostscript/lib/docie.ps new file mode 100644 index 0000000..7f7f4d4 --- /dev/null +++ b/dist/conf/ghostscript/lib/docie.ps @@ -0,0 +1,219 @@ +% Copyright (C) 2001-2023 Artifex Software, Inc. +% All Rights Reserved. +% +% This software is provided AS-IS with no warranty, either express or +% implied. +% +% This software is distributed under license and may not be copied, +% modified or distributed except as expressly authorized under the terms +% of the license contained in the file LICENSE in this distribution. +% +% Refer to licensing information at http://www.artifex.com or contact +% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, +% CA 94129, USA, for further information. +% + +% docie.ps +% Emulate CIE algorithms in PostScript. + +% ---------------- Auxiliary procedures ---------------- % + +/r1default [0 1] def +/r3default [0 1 0 1 0 1] def + +/apply3 % [ ] apply3 + { { 4 -1 roll exch exec } forall + } bind def + +/restrict % restrict + { 3 1 roll .max .min + } bind def + +/restrict3 % [ ... ] restrict3 + { aload pop + 7 -1 roll 3 1 roll restrict 7 1 roll + 5 -1 roll 3 1 roll restrict 5 1 roll + restrict 3 1 roll + } bind def + +/rescale % rescale + { 1 index sub 3 1 roll sub exch div 0 .max 1 .min + } bind def + +/rescale3 % [ ... ] rescale3 + { aload pop + 7 -1 roll 3 1 roll rescale 7 1 roll + 5 -1 roll 3 1 roll rescale 5 1 roll + rescale 3 1 roll + } bind def + +/mmult3 % [ ... ] mmult3 + % + { 4 -1 roll dup dup 6 -1 roll dup dup 8 -1 roll dup dup + 10 -1 roll { 10 -1 roll mul } forall + % Stack: u1 v1 w1 u2 v2 w2 u3 v3 w3 + 4 -1 roll add 6 -1 roll add + % Stack: u1 v1 u2 v2 u3 v3 w' + 7 1 roll 3 -1 roll add 4 -1 roll add + % Stack: w' u1 u2 u3 v' + 5 1 roll add add 3 1 roll + } bind def + +/minvert3 % [ ... ] minvert3 + % [ ... ] + { 16 dict begin + aload pop { I H G F E D C B A } { exch def } forall + /coa E I mul F H mul sub def + /cob F G mul D I mul sub def + /coc D H mul E G mul sub def + /det A coa mul B cob mul add C coc mul add def + [ coa det div + C H mul B I mul sub det div + B F mul C E mul sub det div + cob det div + A I mul C G mul sub det div + C D mul A F mul sub det div + coc det div + B G mul A H mul sub det div + A E mul B D mul sub det div + ] + end + } bind def + +/print1 + { print dup == + } bind def + +/print3 + { print 3 array astore dup == aload pop + } bind def + +% ---------------- Mapping to XYZ ---------------- % + +/csmap % csmap + { 3 index /RangeLMN .knownget not { r3default } if restrict3 +DOCIEDEBUG { (After RangeLMN Decode: ) print3 } if + 3 index /DecodeLMN .knownget { apply3 } if +DOCIEDEBUG { (After DecodeLMN Decode: ) print3 } if + 3 index /MatrixLMN .knownget { mmult3 } if +DOCIEDEBUG { (After MatrixLMN Decode: ) print3 } if + } bind def + +/csciea % csciea + { 1 index /RangeA .knownget not { r1default aload pop } if restrict +DOCIEDEBUG { (After RangeA Decode: ) print1 } if + 1 index /DecodeA .knownget { exec } if +DOCIEDEBUG { (After DecodeA Decode: ) print1 } if + 1 index /MatrixA .knownget + { { 1 index mul exch } forall pop } + { dup dup } + ifelse +DOCIEDEBUG { (After MatrixA Decode: ) print3 } if + csmap + } bind def + +/cscieabc % cscieabc + { 3 index /RangeABC .knownget not { r3default } if restrict3 +DOCIEDEBUG { (After RangeABC Decode: ) print3 } if + 3 index /DecodeABC .knownget { apply3 } if +DOCIEDEBUG { (After DecodeABC Decode: ) print3 } if + 3 index /MatrixABC .knownget { mmult3 } if +DOCIEDEBUG { (After MatrixABC Decode: ) print3 } if + csmap + } bind def + +% ---------------- Rendering from XYZ ---------------- % + +/lookup3 % lookup3 + % + { 3 -1 roll 3 index 0 get 1 sub mul + 3 -1 roll 3 index 1 get 1 sub mul + 3 -1 roll 3 index 2 get 1 sub mul + % Stack: rtable ia ib ic +DOCIEDEBUG { (RenderTable indices: ) print3 mark 5 1 roll } if + 3 -1 roll round cvi 3 index 3 get exch get + % Stack: rtable ib ic string + 3 -1 roll round cvi 3 index 2 get mul + % Stack: rtable ic string ib*nc + 3 -1 roll round cvi add 2 index 4 get mul + % Stack: rtable string index + 2 index 4 get getinterval + % Stack: rtable bytes +DOCIEDEBUG { (RenderTable values: ) print (<) print (%stdout) (w) file 1 index writehexstring (>) = } if + } bind def + +/bpdefault [0 0 0] def + +/crmap % crmap ... + { +DOCIEDEBUG { (CIE XYZ = ) print3 } if + 3 index /MatrixPQR .knownget { mmult3 } if +DOCIEDEBUG { (After MatrixPQR: ) print3 } if + 4 index /WhitePoint get + 5 index /BlackPoint .knownget not { bpdefault } if + 5 index /WhitePoint get + 6 index /BlackPoint .knownget not { bpdefault } if + 4 + { 4 -1 roll aload pop + % Stack: csdict crdict x y z pt pt pt px py pz + 3 copy 12 index /MatrixPQR .knownget { mmult3 } if 6 array astore + } + repeat + % Stack: csdict crdict x y z wps+ bps+ wpd+ bpd+ + 9 -1 roll pop % get rid of csdict + 7 4 roll + 7 index /TransformPQR get + { % Stack: crdict wps+ bps+ wpd+ bpd+ u v w proc + 8 copy exch pop exch pop + exec exch pop 4 -1 roll pop + } + forall + 7 3 roll pop pop pop pop % get rid of White/BlackPoints +DOCIEDEBUG { (After TransformPQR: ) print3 } if + 3 index /MatrixPQR .knownget { minvert3 mmult3 } if +DOCIEDEBUG { (After MatrixPQR': ) print3 } if + 3 index /MatrixLMN .knownget { mmult3 } if +DOCIEDEBUG { (After MatrixLMN Encode: ) print3 } if + 3 index /EncodeLMN .knownget { apply3 } if +DOCIEDEBUG { (After EncodeLMN Encode: ) print3 } if + 3 index /RangeLMN .knownget not { r3default } if restrict3 +DOCIEDEBUG { (After RangeLMN Encode: ) print3 } if + 3 index /MatrixABC .knownget { mmult3 } if +DOCIEDEBUG { (After MatrixABC Encode: ) print3 } if + 3 index /EncodeABC .knownget { apply3 } if +DOCIEDEBUG { (After EncodeABC Encode: ) print3 } if + 3 index /RangeABC .knownget not { r3default } if + 5 -1 roll /RenderTable .knownget + { % Stack: u v w ranges rtable + 5 1 roll rescale3 +DOCIEDEBUG { (Rescaled ABC: ) print3 } if + % Stack: rtable a b c + lookup3 + % Stack: rtable bytes + 0 1 3 index 4 get 1 sub + { % Stack: values rtable bytes c + 2 copy get 255 div + % Stack: values rtable bytes c v + 3 index 3 -1 roll 5 add get exec 3 1 roll + } + for pop pop +DOCIEDEBUG { (After RenderTableT: ) print ] dup == aload pop } if + } + { restrict3 +DOCIEDEBUG { (After RangeABC Encode: ) print3 } if + } + ifelse + } bind def + +% ---------------- Top level control ---------------- % + +/mapdict mark + /CIEBasedA { 1 get exch csciea currentcolorrendering 4 1 roll crmap } bind + /DeviceGray { pop /DefaultGray /ColorSpace findresource 1 get exch csciea currentcolorrendering 4 1 roll crmap } bind + /CIEBasedABC { 1 get 4 1 roll cscieabc currentcolorrendering 4 1 roll crmap } bind + /DeviceRGB { pop /DefaultRGB /ColorSpace findresource 1 get 4 1 roll cscieabc currentcolorrendering 4 1 roll crmap } bind +.dicttomark def +/mapcie % mapcie ... + % mapcie ... + { currentcolorspace dup 0 get //mapdict exch get exec + } bind def diff --git a/dist/conf/ghostscript/lib/font2pcl.ps b/dist/conf/ghostscript/lib/font2pcl.ps new file mode 100644 index 0000000..1d15453 --- /dev/null +++ b/dist/conf/ghostscript/lib/font2pcl.ps @@ -0,0 +1,606 @@ +% Copyright (C) 2001-2023 Artifex Software, Inc. +% All Rights Reserved. +% +% This software is provided AS-IS with no warranty, either express or +% implied. +% +% This software is distributed under license and may not be copied, +% modified or distributed except as expressly authorized under the terms +% of the license contained in the file LICENSE in this distribution. +% +% Refer to licensing information at http://www.artifex.com or contact +% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, +% CA 94129, USA, for further information. +% + +% font2pcl.ps +% Write out a font as a PCL bitmap font. +% This program must be run with -dNOSAFER, as it uses the in-memory image device +% which is unavailable with SAFER. + +/pcldict 60 dict def + +% Write out the current font as a PCL bitmap font. +% The current transformation matrix defines the font size and orientation. + +/WriteResolution? false def % true=use "resolution bound font" format, + % false=use older format + +/LJ4 false def % true=use LJ4 Typeface code + % false=use LJIIP/IID/IIIx Typeface code + +pcldict begin % internal procedures + +/findstring % findstring + { search { pop pop pop true } { pop false } ifelse + } def + + % Determine which set of keywords is present in a string. + % The last keyword set must be empty. + +/keysearch % keysearch + { 0 1 2 index length 1 sub + { 2 copy get true exch + { % Stack: + 4 index exch findstring and + } + forall + { 0 exch getinterval exit + } + if pop + } + for + exch pop length % invalid index if missing + } def + + % Determine the device height of a string in quarter-dots. + +/charheight % charheight + { gsave newpath 0 0 moveto false charpath + pathbbox exch pop exch sub exch pop 0 exch grestore + dtransform add abs 4 mul cvi + } def + + % Compute an integer version of the transformed FontBBox. + +/inflate % inflate + { dup 0 gt { ceiling } { floor } ifelse + } def +/ixbbox % - ixbbox + { /FontBBox load aload pop % might be executable or literal + 4 2 roll transform exch truncate cvi exch truncate cvi + 4 2 roll transform exch inflate cvi exch inflate cvi + } def + + % Determine the original font of a possibly transformed font. + % Since some badly behaved PostScript files construct transformed + % fonts "by hand", we can't just rely on the OrigFont pointers. + % Instead, if a font with the given name exists, and if its + % entries for FontType and UniqueID match those of the font we + % obtain by following the OrigFont chain, we use that font. + +/origfont + { { dup /OrigFont known not { exit } if /OrigFont get } loop + FontDirectory 1 index /FontName get .knownget + { % Stack: origfont namedfont + 1 index /FontType get 1 index /FontType get eq + { 1 index /UniqueID .knownget + { 1 index /UniqueID .knownget + { eq { exch } if } + { pop } + ifelse + } + if + } + if pop + } + if + } def + + % Determine the bounding box of the current device's image. + % Free variables: row, zerow. + +/devbbox % devbbox + { % Find top and bottom whitespace. + dup + { dup 0 eq { exit } if 1 sub + dup currentdevice exch row copyscanlines + zerow ne { 1 add exit } if + } + loop % ymax1 + 0 + { 2 copy eq { exit } if + dup currentdevice exch row copyscanlines + zerow ne { exit } if + 1 add + } + loop % ymin + exch + % Find left and right whitespace. + 3 index 0 + % Stack: rw rh ymin ymax1 xmin xmax1 + 3 index 1 4 index 1 sub + { currentdevice exch row copyscanlines .findzeros + exch 4 1 roll .max 3 1 roll .min exch + } + for % xmin xmax1 + % Special check: xmin > xmax1 if height = 0 + 2 copy gt { exch pop dup } if + 6 -2 roll pop pop + + } def + + % Write values on outfile. + + /w1 { 255 and outfile exch write } def + /w2 { dup -8 bitshift w1 w1 } def + /wbyte %