Skip to content

Latest commit

 

History

History
295 lines (228 loc) · 15.7 KB

File metadata and controls

295 lines (228 loc) · 15.7 KB

PostForge Compliance Assessment

Date: 2026-02-24 Reference: PostScript Language Reference Manual, Second Edition (PLRM2) and Third Edition (PLRM3) Methodology: Systematic cross-reference of PLRM Chapter 8 operator summaries and Chapters 3-6 feature specifications against PostForge source code (both Python postforge/operators/*.py and PostScript postforge/resources/*.ps implementations).


Summary

PostForge implements ~99.7% of the PostScript Level 2 specification and declares LanguageLevel 3. All 22 Level 2 operator categories are at 100% except Errors (96% — only interrupt missing; DPS-only errors excluded from scope). Level 3 additions include UseCIEColor, ProcessColorModel, smoothness, trapping operators, additional resource categories, and compatibility parameters.

Note: Display PostScript (DPS) operators are explicitly excluded from this assessment as they are a separate extension not required for compliance.


1. Operator Coverage

Fully Implemented Categories (100%)

Category Operators Status
Operand Stack pop, exch, dup, copy, index, roll, clear, count, mark, cleartomark, counttomark 11/11
Arithmetic & Math add, div, idiv, mod, mul, sub, abs, neg, ceiling, floor, round, truncate, sqrt, atan, cos, sin, exp, ln, log, rand, srand, rrand 22/22
Array array, [, ], length, get, put, getinterval, putinterval, astore, aload, copy, forall 12/12
Packed Array packedarray, currentpacking, setpacking + polymorphic ops 3/3
Dictionary dict, <<, >>, length, maxlength, begin, end, def, load, store, get, put, undef, known, where, copy, forall, currentdict, errordict, $error, systemdict, userdict, globaldict, statusdict, countdictstack, dictstack, cleardictstack 25/25
String string, length, get, put, getinterval, putinterval, copy, forall, anchorsearch, search, token 11/11
Relational/Boolean/Bitwise eq, ne, ge, gt, le, lt, and, not, or, xor, true, false, bitshift 13/13
Control exec, if, ifelse, for, repeat, loop, exit, stop, stopped, countexecstack, execstack, quit, start 13/13
Type/Attribute/Conversion type, cvlit, cvx, xcheck, executeonly, noaccess, readonly, rcheck, wcheck, cvi, cvn, cvr, cvrs, cvs 14/14
Resource defineresource, undefineresource, findresource, resourcestatus, resourceforall 5/5
Coordinate System & Matrix matrix, initmatrix, identmatrix, defaultmatrix, currentmatrix, setmatrix, translate, scale, rotate, concat, concatmatrix, transform, dtransform, itransform, idtransform, invertmatrix 15/15
File/I/O file, filter, closefile, read, write, readhexstring, writehexstring, readstring, writestring, readline, token, bytesavailable, flush, flushfile, resetfile, status, run, currentfile, deletefile, renamefile, filenameforall, setfileposition, fileposition, setobjectformat, currentobjectformat, printobject, writeobject, print, =, ==, stack, pstack 32/32
Virtual Memory save, restore, setglobal, currentglobal, gcheck, startjob, defineuserobject, execuserobject, undefineuserobject, UserObjects 10/10
Miscellaneous bind, null, version, realtime, usertime, languagelevel, product, revision, serialnumber, executive, echo, prompt 12/12
Graphics State (DI) gsave, grestore, grestoreall, initgraphics, gstate, setgstate, currentgstate, setlinewidth, currentlinewidth, setlinecap, currentlinecap, setlinejoin, currentlinejoin, setmiterlimit, currentmiterlimit, setstrokeadjust, currentstrokeadjust, setdash, currentdash, setcolorspace, currentcolorspace, setcolor, currentcolor, setgray, currentgray, sethsbcolor, currenthsbcolor, setrgbcolor, currentrgbcolor, setcmykcolor, currentcmykcolor 31/31
Graphics State (DD) sethalftone, currenthalftone, setscreen, currentscreen, setcolorscreen, currentcolorscreen, settransfer, currenttransfer, setcolortransfer, currentcolortransfer, setcolorrendering, currentcolorrendering, setblackgeneration, currentblackgeneration, setundercolorremoval, currentundercolorremoval, setflat, currentflat, setoverprint, currentoverprint 20/20
Path Construction newpath, currentpoint, moveto, rmoveto, lineto, rlineto, arc, arcn, arct, arcto, curveto, rcurveto, closepath, flattenpath, reversepath, strokepath, charpath, clippath, pathbbox, pathforall, initclip, clip, eoclip, rectclip, ustrokepath, uappend, setbbox, upath, ucache 25/25
Painting erasepage, fill, eofill, stroke, rectfill, rectstroke, image, colorimage, imagemask, ufill, ueofill, ustroke 12/12
Insideness Testing infill, ineofill, instroke, inufill, inueofill, inustroke 6/6
Form and Pattern makepattern, setpattern, execform 3/3
Device Setup and Output showpage, copypage, setpagedevice, currentpagedevice, nulldevice 5/5
Character and Font definefont, undefinefont, findfont, scalefont, makefont, setfont, currentfont, rootfont, selectfont, show, ashow, widthshow, awidthshow, kshow, xshow, xyshow, yshow, glyphshow, stringwidth, cshow, FontDirectory, GlobalFontDirectory, StandardEncoding, ISOLatin1Encoding, findencoding, setcachedevice, setcachedevice2, setcharwidth 28/28
Interpreter Parameters setsystemparams, currentsystemparams, setuserparams, currentuserparams, vmstatus, setcachelimit, setdevparams, currentdevparams, vmreclaim, setvmthreshold, cachestatus, setcacheparams, currentcacheparams, setucacheparams, ucachestatus 15/15

Note: ucache is accepted but is a no-op — actual user path caching is not implemented.

Partially Implemented Categories

Errors (25/26 = 96%)

Implemented in errordict: VMerror, dictfull, dictstackoverflow, dictstackunderflow, execstackoverflow, invalidaccess, invalidexit, invalidfileaccess, invalidfont, invalidrestore, ioerror, limitcheck, nocurrentpoint, rangecheck, stackoverflow, stackunderflow, syntaxerror, timeout, typecheck, undefined, undefinedfilename, undefinedresource, undefinedresult, unmatchedmark, unregistered, configurationerror, handleerror

Missing:

  • interrupt - External interrupt request (Ctrl+C handled at Python level instead)

Excluded (DPS-only, not required for Level 2):

  • invalidcontext - Improper use of context operation
  • invalidid - Invalid identifier for external object

2. Language Features

Feature Status Details
Type System COMPLETE All 15 PS types implemented
ASCII Syntax COMPLETE Full tokenizer with all delimiters
Binary Token Encoding COMPLETE All token types 132-149 fully implemented. Binary object sequences (128-131): full read/parse support with recursive array building, plus write support via printobject/writeobject
Immediate Name Lookup (//name) COMPLETE Tokenizer lines 344-376
Global/Local VM COMPLETE Dual gvm/lvm, vm_alloc_mode tracking
Save/Restore COMPLETE Full VM snapshot/restore
Garbage Collection COMPLETE gcheck implemented, vmreclaim implemented (no-op per spec allowance)

3. Graphics Features

Feature Status Details
Path Construction COMPLETE All standard path operators
Clipping COMPLETE clip, eoclip, rectclip, initclip
Color Spaces COMPLETE DeviceGray, DeviceRGB, DeviceCMYK, CIEBasedABC, CIEBasedA, Indexed, Separation, DeviceN, Pattern, ICCBased
Patterns MOSTLY COMPLETE makepattern, setpattern; PaintType 1 & 2, TilingType 1-3 supported. Minor spec gaps: TilingType-specific pixel-grid matrix adjustment not performed, BBox clipping not applied during PaintProc execution
Forms COMPLETE execform with form-space caching for efficient replay
Images COMPLETE Level 2 image dicts, all data sources, colorimage, imagemask
User Paths COMPLETE upath, ufill, ueofill, ustroke, ustrokepath, uappend, ucache, setbbox
Insideness Testing COMPLETE infill, ineofill, instroke, inufill, inueofill, inustroke
Halftone Dicts PARTIAL sethalftone accepts all halftone dictionaries. HalftoneType 1 fully processed; Types 2-5 accepted without error but fall through to default rendering values
CIE Color Rendering COMPLETE setcolorrendering, currentcolorrendering
Transfer Functions COMPLETE settransfer, setcolortransfer, currenttransfer, currentcolortransfer

4. Filter Support

Filter Encode Decode Status
ASCIIHexDecode/Encode Yes Yes COMPLETE
ASCII85Decode/Encode Yes Yes COMPLETE
LZWDecode/Encode Yes Yes COMPLETE
RunLengthDecode/Encode Yes Yes COMPLETE
FlateDecode/Encode Yes Yes COMPLETE
DCTDecode/Encode Yes Yes COMPLETE
CCITTFaxDecode N/A Yes COMPLETE
CCITTFaxEncode -- -- Not implemented (rarely needed for rendering)
SubFileDecode N/A Yes COMPLETE
NullEncode Yes N/A COMPLETE
ReusableStreamDecode N/A Yes COMPLETE (with setfileposition seek support)

5. Resource Categories

Category Directory Exists Populated Status
Font Yes Yes COMPLETE
CIDFont Yes Empty COMPLETE (CID fonts registered at runtime; directory available for user-supplied resources)
CMap Yes Empty COMPLETE (CMaps registered at runtime; directory available for user-supplied resources)
Encoding Yes 3 files COMPLETE (Standard, ISOLatin1, Symbol — all Level 2 required encodings present)
Form Yes Yes COMPLETE (TestForm.ps)
Pattern Yes Yes COMPLETE (TestPattern.ps)
ProcSet Yes Yes COMPLETE
ColorSpace Yes Yes COMPLETE
Halftone Yes Yes COMPLETE (TestHalftone.ps)
ColorRendering Yes Yes COMPLETE

6. Priority Gap Analysis

High Priority (impacts real-world PS documents)

No remaining high-priority gaps.

Medium Priority (less commonly used but spec-required)

  • CCITTFaxEncode filter: CCITTFaxDecode is implemented but the encode direction is not. Rarely needed for rendering.

Low Priority (rarely used in practice)

  • Pattern TilingType matrix adjustment: makepattern does not perform TilingType-specific pixel-grid alignment of the pattern matrix. May cause subtle seam artifacts at certain DPIs but does not affect pattern correctness.
  • Pattern BBox clipping: PaintProc is not clipped to BBox during pattern cell capture. Only affects patterns where PaintProc intentionally draws outside bounds.
  • interrupt error: Not wired to external interrupt signals (Ctrl+C handled at Python level instead).
  • DPS error names (invalidcontext, invalidid): Display PostScript extensions, not required for Level 2 compliance.

7. Overall Score

Area Implemented Total Percentage
Stack/Math/Logic 110 110 100%
Type/Conversion 14 14 100%
File/I/O 32 32 100%
Resource 5 5 100%
VM 10 10 100%
Miscellaneous 12 12 100%
Graphics State (DI) 31 31 100%
Graphics State (DD) 20 20 100%
Matrix 15 15 100%
Path 25 25 100%
Painting 12 12 100%
Insideness Testing 6 6 100%
Form/Pattern 3 3 100%
Device Output 5 5 100%
Font 28 28 100%
Interpreter Params 15 15 100%
Errors 25 26 96%
TOTAL 368 369 99.7%

Language Features Score

Feature Score
Type System 100%
Tokenizer/Syntax 100%
VM System 100%
Color Spaces 100%
Patterns 95%
Images 100%
Filters 97%
Resources 100%

Overall Level 2 Compliance: ~99.7%


8. Level 3 Features

Level 3 is a strict superset of Level 2. All Level 2 behavior is preserved. The features below are additions specified in the PLRM Third Edition.

Level 3 Operators

Category Operators Status
Graphics State setsmoothness, currentsmoothness COMPLETE
Clipping clipsave, cliprestore COMPLETE
Font composefont COMPLETE
Painting shfill (all 7 shading types) COMPLETE
Color findcolorrendering COMPLETE
Show glyphshow (name + integer forms) COMPLETE
Trapping settrapparams, currenttrapparams, settrapzone COMPLETE (no-ops — physical device feature)

Level 3 Color Spaces

Feature Status Details
CIEBasedDEF COMPLETE 3-component CIE with decode table
CIEBasedDEFG COMPLETE 4-component CIE with 4D lookup table
ICCBased COMPLETE Tier 2 (lcms2 via Pillow) with device space fallback
DeviceN COMPLETE N-component with tint transform
UseCIEColor COMPLETE Device spaces remapped through Default* CIE resources (PLRM 6.2.5)
ProcessColorModel COMPLETE PLRM-standard name wired as fallback for ColorModel

Level 3 Filters

Filter Status Details
FlateDecode/Encode COMPLETE zlib-based compression
SubFileDecode COMPLETE Substring-delimited subfile
ReusableStreamDecode COMPLETE Seekable buffered stream with setfileposition
CCITTFaxDecode COMPLETE Group 3/4 fax decoding
CCITTFaxEncode NOT IMPLEMENTED Encode direction (PLRM makes encode filters optional)

Level 3 Font Support

Feature Status Details
Type 0 composite (CID) COMPLETE CIDFont + CMap resources
Type 42 (TrueType) COMPLETE sfnts-based TrueType
CFF (Type 2) COMPLETE OpenType/CFF charstrings
Type 3 masked images COMPLETE MaskColor color-key masking
Function Types 0, 2, 3 COMPLETE Sampled, Exponential, Stitching

Level 3 Page Device Parameters

Parameter Status Details
UseCIEColor COMPLETE CIE substitution for device color spaces
ProcessColorModel COMPLETE Device native color model
Trapping params COMPLETE settrapparams/currenttrapparams (no-ops)
Physical media keys COMPLETE Accepted without error (implementation-dependent)
Separation keys COMPLETE Accepted without error (implementation-dependent)

Level 3 Resource Categories

Category Status Details
IdiomSet REGISTERED Empty — idiom matching is implementation-dependent
ControlLanguage REGISTERED Empty
Localization REGISTERED Empty
PDL REGISTERED Empty
HWOptions REGISTERED Empty
FontSet REGISTERED CFF font loading

Level 3 User/System Parameters

Parameter Type Status Details
IdiomRecognition User COMPLETE Boolean, default true
AccurateScreens User COMPLETE Boolean, default false
HalftoneMode User COMPLETE Integer, default 0
LicenseID System COMPLETE String, default empty

Level 3 Behavior Changes

Feature Status Details
copypage erases page COMPLETE Gated on language_level >= 3
language_level attribute COMPLETE Derived from version in sysdict.ps

Not Applicable

Feature Reason
Type 4 Calculator Functions PDF-only feature (PDF Reference 3.9.4), not in PLRM
Type 14 (Chameleon) Fonts Proprietary Adobe format, no public spec
Halftone Types 6, 10, 16 Threshold arrays for physical devices — accepted, no rendering needed

LanguageLevel Bump — COMPLETE

sysdict.ps updated: version set to (3000), languagelevel set to 3. Verified with full test suite (ps_tests) and visual regression tests.


9. Overall Compliance

Level Operator Coverage Feature Coverage Status
Level 2 368/369 (99.7%) ~99.7% Production-ready
Level 3 All new operators implemented All features complete LanguageLevel 3 declared