Flyweight in PostScript
Share font spirit dictionaries to save demonic memory space in the stack.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Flyweight
ARCANUM SCHOOL: Conjuration // Spirit Caching
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
% Flyweight in PostScript
/FontCache << >> def
/getFontSpirit {
FontCache exch 2 copy known not {
(Summoning and Caching Font Spirit...\n) print
2 copy << /data (Heavy Vector Glyphs) >> put
} if
get
} bind def
/Helvetica getFontSpirit pop
/Helvetica getFontSpirit pop
Flyweight: Spirit Caching
When conjuring tens of thousands of individual characters on a page, creating a new font spirit for each glyph would rapidly exhaust the interpreter’s memory stack. The Flyweight caches these intrinsic states, ensuring that “Helvetica” is loaded only once. All subsequent invocations simply reference the already summoned spirit.
Runic Tags:
#postscript
#print-daemon
#structural
#flyweight