### Get Font Underline Metrics Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Retrieves underline position and thickness from the current font's metrics. Handles Type 0 fonts and applies FontMatrix transformations. ```postscript % Get the underline position and thickness from the current font. /vg&underline { currentfont dup /FontType get 0 eq {/FDepVector get 0 get} if dup dup /FontInfo known { /FontInfo get dup dup /UnderlinePosition known { /UnderlinePosition get /vg&uoffset exch def } { pop /vg&uoffset 0 def } ifelse dup /UnderlineThickness known { /UnderlineThickness get /vg&uthick exch def } { pop /vg&uthick 0 def } ifelse } { pop /vg&uoffset 0 def /vg&uthick 0 def } ifelse /FontMatrix get currentfont dup /FontType get 0 eq {/FontMatrix get matrix concatmatrix}{pop} ifelse dup 0 vg&uoffset 3 -1 roll transform /vg&uoffset exch def pop 0 vg&uthick 3 -1 roll transform /vg&uthick exch def pop } def ``` -------------------------------- ### Manage Staging Repository on Sonatype Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/ReleaseToCentral.txt Steps to manage a staging repository on oss.sonatype.org after a release. This involves logging in, searching, closing, and releasing or dropping the repository. ```bash log in as "duns" to website oss.sonatype.org search for orgfreehep-xxxx (xxx=number) under "Staging Repositories" select open repo, click close, add comment check... when everything is ok, select the closed repo, click release (or drop). ``` -------------------------------- ### Build FreeHEP VectorGraphics documentation locally Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/README.txt Commands to build the documentation site from the gh-pages branch using Jekyll. ```bash jekyll build ``` -------------------------------- ### Perform Version Release Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/ReleaseToCentral.txt Execute the release deployment to Central and GitHub after preparation. This command may encounter failures. ```bash mvn release:perform ``` -------------------------------- ### Prepare Version Release Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/ReleaseToCentral.txt Initiate the release process for a versioned release using Maven. This prepares the release by tagging and updating versions. ```bash mvn release:prepare ``` -------------------------------- ### Update API Documentation with Maven Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/UpdateApidocsOnPages.md Execute these commands sequentially to clean the project, generate Javadoc, and publish it to the SCM. ```bash mvn clean mvn javadoc:javadoc mvn scm-publish:publish-scm ``` -------------------------------- ### Deploy Version Release from Checkout Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/ReleaseToCentral.txt Manually deploy a version release from the checked-out release artifact directory. This ensures deployment from the final release state. ```bash cd target/checkout mvn -DperformRelease=true clean deploy ``` -------------------------------- ### Utility and Tokenization Routines Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Helper routines for comparing values and tokenizing strings. ```PostScript /testchar {exch dup 3 -1 roll 0 get eq} def ``` ```PostScript /maxval {2 copy gt {pop} {exch pop} ifelse} def ``` ```PostScript /vg&token {/vg&string exch def /vg&index -1 def /vg&level 0 def 0 2 vg&string length 2 sub { dup dup 1 add exch vg&string exch get 8 bitshift vg&string 3 -1 roll get or dup 16#f0fe eq {pop 1}{16#f0ff eq {-1}{0} ifelse} ifelse /vg&level exch vg&level add def vg&level 0 eq {/vg&index exch def exit} if pop } for vg&index 0 ge { vg&string vg&index 2 add dup vg&string length exch sub getinterval vg&index 2 gt {vg&string 2 vg&index 2 sub getinterval}{()} ifelse true} {false} ifelse } bind def ``` -------------------------------- ### Internal Rendering and Bounding Box Routines Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Internal routines for managing string display and bounding box updates. ```PostScript /internalshow {show} def ``` ```PostScript /internalstroke {S} def ``` ```PostScript /nullinternalshow {/internalshow {false charpath flattenpath pathbbox updatebbox} def} def ``` ```PostScript /nullinternalstroke { /internalstroke {flattenpath pathbbox updatebbox} def} def ``` -------------------------------- ### Release Snapshot to GitHub Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/ReleaseToCentral.txt Use these Git commands to tag and push a snapshot release to GitHub. Ensure you have the correct snapshot version number. ```bash git tag freehep-vectorgraphics-x.y-SNAPSHOT git push --tags ``` -------------------------------- ### Release Snapshot to Central Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/ReleaseToCentral.txt Deploy a snapshot release to the Central repository using Maven. This command cleans the project and deploys the artifacts. ```bash mvn clean deploy ``` -------------------------------- ### Define Font Selection Procedure Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Defines a helper procedure to set the font size and select the SansSerif font. ```PostScript /cfontH { dup /fontsize exch def /SansSerif exch sf ``` -------------------------------- ### String Alignment Utilities Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Provides PostScript procedures for aligning strings based on first and second letters indicating vertical (U, C, B, L) and horizontal (L, C, R) alignment. ```postscript % Utilities to position a string. % First letter (U=upper, C=center, B=baseline, L=lower) % Second letter (L=left, C=center, R=right) /align [ {calcval dx neg widy dy add neg rmoveto} % UL {calcval dx neg widy 2 div dy add neg rmoveto} % CL {calcval dx neg 0 rmoveto} % BL {calcval dx neg dy neg rmoveto} % LL {calcval widx dx add neg widy dy add neg rmoveto} % UR {calcval widx dx add neg widy 2 div dy add neg rmoveto} % CR {calcval widx dx add neg 0 rmoveto} % BR ``` -------------------------------- ### Render Text with Underline Styles Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Handles character display and applies various underline styles (none, dashed, dotted, thick, gray thick) or overbars based on a control byte. Requires font metrics to be set. ```postscript % Render text with underline or overbar. /vg&recshow { vg&cbyte 16#01 eq { vg&token pop currentpoint 3 -1 roll recshow q 0 J vg&underline vg&uthick w currentpoint 4 -2 roll vg&uoffset add moveto vg&uoffset add lineto internalstroke Q recshow} if % Dashed underline. vg&cbyte 16#03 eq { vg&token pop currentpoint 3 -1 roll recshow q 0 J [ vg&uthick 5 mul vg&uthick 2 mul] 0 d vg&underline vg&uthick w currentpoint 4 -2 roll vg&uoffset add moveto vg&uoffset add lineto internalstroke Q recshow} if % Dotted underline. vg&cbyte 16#04 eq { vg&token pop currentpoint 3 -1 roll recshow q 1 J [ 0 vg&uthick 3 mul] 0 d vg&underline vg&uthick w currentpoint 4 -2 roll vg&uoffset add moveto vg&uoffset add lineto internalstroke Q recshow} if % Thick underline. vg&cbyte 16#05 eq { vg&token pop currentpoint 3 -1 roll recshow q 0 J vg&underline vg&uthick 2 mul w currentpoint 4 -2 roll vg&uoffset vg&uthick 2 div sub add moveto vg&uoffset vg&uthick 2 div sub add lineto internalstroke Q recshow} if % Gray thick underline. vg&cbyte 16#06 eq { vg&token pop currentpoint 3 -1 roll recshow q 0 J vg&underline vg&uthick 2 mul w 0.5 setgray currentpoint 4 -2 roll vg&uoffset vg&uthick 2 div sub add moveto vg&uoffset vg&uthick 2 div sub add lineto internalstroke Q recshow} if % Overbar. vg&cbyte 16#07 eq { vg&token pop dup stringsize relative 4 1 roll pop pop exch 3 -1 roll recshow q 0 J vg&underline vg&uthick w vg&uoffset neg add dup currentpoint pop exch m l internalstroke Q recshow} if } { vg&fbyte vg&cbyte unicharshow recshow } ifelse } ifelse } def ``` -------------------------------- ### PostScript Procedure for String Rendering and Framing Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt This PostScript procedure, '/vg&str', handles the rendering of strings within a graphics context. It includes scaling, alignment, and framing operations before displaying the text. ```postscript /vg&str {m q 1 -1 scale dup stringsize 4 copy align 11 -1 roll get exec q inflate relative frame exch exec Q recshow Q} def ``` -------------------------------- ### PostScript Page Layout Configuration Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Procedures for defining page dimensions, margins, orientation, and image scaling logic. ```PostScript % Initialize variables for safety. /delta 0 def /xv 0 def /yv 0 def /width 0 def /height 0 def % Initialize to portrait INTERNATIONAL (Letter-height, A4-width) page. /pw 595 def /ph 791 def /po true def /ftp false def % Initialize margins to 20 points. /ml 20 def /mr 20 def /mt 20 def /mb 20 def % Temporary matrices. /smatrix 0 def /nmatrix 0 def % set page size (usage: setpagesize) /setpagesize {/ph exch def /pw exch def} def % set page orientation (usage: portrait or landscape) /portrait {/po true def} def /landscape {/po false def} def % force natural size for image (usage: naturalsize) /naturalsize {/ftp false def} def % resize image to fill page (usage: fittopage) /fittopage {/ftp true def} def % set margins of the page (usage: setmargins) /setmargins {/mr exch def /mt exch def /mb exch def /ml exch def} def % set the graphic's size (usage: setsize) /setsize {/gh exch def /gw exch def} def % set the graphic's origin (usage: setorigin) /setorigin {/gy exch def /gx exch def} def % calculate image center /imagecenter {pw ml sub mr sub 2 div ml add ph mt sub mb sub 2 div mb add} def % calculate the necessary scaling /imagescale {po {gw}{gh} ifelse pw ml sub mr sub div po {gh}{gw} ifelse ph mt sub mb sub div 2 copy lt {exch} if pop ftp not {1 2 copy lt {exch} if pop} if 1 exch div /sfactor exch def /gw gw sfactor mul def /gh gh sfactor mul def} def % calculate image origin /imageorigin {pw ml sub mr sub 2 div ml add po {gw}{gh} ifelse 2 div sub ph mt sub mb sub 2 div mb add po {gh}{gw} ifelse 2 div po {add}{sub} ifelse} def % calculate the clipping origin ``` -------------------------------- ### PostScript Path and Dash Utilities Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Custom stroke handling to ensure dash patterns persist across path segments. ```PostScript % Special version of stroke which allows the dash pattern to continue % across path segments. (This may be needed for PostScript although % modern printers seem to do this correctly.) /vg&stroke { currentdash pop length 0 eq {stroke} { currentdash /vg&doffset exch def pop flattenpath {m vg&resetdash} {2 copy currentpoint 3 -1 roll sub dup mul 3 1 roll sub dup mul add sqrt 3 1 roll l currentdash 3 -1 roll add setdash} {} {h vg&resetdash} pathforall stroke vg&resetdash } ifelse } def /vg&resetdash {currentdash pop vg&doffset setdash} def ``` -------------------------------- ### Calculate String Positioning Values Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Calculates width, height, and offsets (dx, dy) for string positioning based on provided coordinates. ```postscript % Calculate values for string positioning. /calcval {4 copy 3 -1 roll sub /widy exch def sub neg /widx exch def pop pop /dy exch def /dx exch def} def ``` -------------------------------- ### Recursive String Rendering Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Routine for recursively processing and showing unicode strings with attributes. ```PostScript /recshow { popfirst { % Test to see if this is a string attribute. vg&fbyte 16#f0 and 16#e0 eq { q % Font style. currentfont dup /FontStyleBits known {/FontStyleBits get}{pop 0} ifelse vg&cbyte or vg&fontstyles exch get fontsize exch exec vg&token pop recshow currentpoint Q m recshow } { vg&fbyte 16#F8 and 16#F0 eq { % Superscript and/or subscript. vg&cbyte 16#00 eq { vg&token pop exch vg&token pop 3 -1 roll q raise recshow unraise currentpoint pop Q exch q lower recshow unlower currentpoint pop Q maxval currentpoint exch pop m recshow } if % Strikeout. vg&cbyte 16#01 eq { vg&token pop currentpoint 3 -1 roll recshow q 0 J vg&underline vg&uthick w currentpoint 4 -2 roll fontsize 3 div add moveto fontsize 3 div add lineto internalstroke Q recshow} if % Underline. vg&cbyte 16#02 eq { vg&token pop currentpoint 3 -1 roll recshow ``` -------------------------------- ### Calculate String Size Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Calculates the bounding box of a string for use with 'recshow'. Requires 'internalshow' and 'internalstroke' procedures to be defined. ```postscript % Returns the size of a string appropriate for recshow. % stringsize /stringsize { pushbbox /internalshow load /internalstroke load 7 -1 roll q nulldevice 0 0 m nullinternalshow nullinternalstroke resetbbox recshow /internalstroke exch def /internalshow exch def pushbbox 8 -4 roll restorebbox Q } def ``` -------------------------------- ### PostScript Feature Emulation Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Provides fallback implementations for rectangle and font selection operators for PostScript environments lacking Level 2 features. ```PostScript % Emulation of the rectangle operators for PostScript implementations % which do not implement all Level 2 features. This is an INCOMPLETE % emulation; only the "x y width height rect..." form is emulated. /*rf {gsave newpath re fill grestore} def /*rs {gsave newpath re stroke grestore} def /*rc {newpath re clip} def /rf /rectfill where {pop /rectfill}{/*rf} ifelse load def /rs /rectstroke where {pop /rectstroke}{/*rs} ifelse load def /rc /rectclip where {pop /rectclip}{/*rc} ifelse load def % Emulation of the selectfont operator. This includes a 20% increase in % the fontsize which is necessary to get sizes similar to the Java fonts. /*sf {exch findfont exch dup type /arraytype eq {makefont}{scalefont} ifelse setfont} bind def /sf /selectfont where {pop {1.2 mul selectfont}}{{1.2 mul *sf}} ifelse def ``` -------------------------------- ### Create New Base Font Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Creates a new base font definition. Usage requires a key, an encoding array, a base font name, and the font object. ```PostScript % usage: key encoding basefontname vg&newbasefont font /vg&newbasefont { findfont dup length dict copy begin currentdict /FID undef /Encoding exch def dup /FontName exch def currentdict end definefont } def ``` -------------------------------- ### Initialize ZapfDingbats Encoding Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Copies and re-indexes the ZapfDingbats font encoding for use within the library. ```PostScript /ZapfDingbats findfont /Encoding get dup length array copy /UCDingbatsEncoding exch def 16#20 1 16#7f { dup 16#20 sub exch UCDingbatsEncoding exch get UCDingbatsEncoding 3 1 roll put } for 16#a0 1 16#ff { dup 16#40 sub exch UCDingbatsEncoding exch get UCDingbatsEncoding 3 1 roll put } for UCDingbatsEncoding [ 16#c0 1 16#ff {} for ] vg&undef [ 16#00 16#05 16#0a 16#0b 16#28 16#4c 16#4e 16#53 16#54 16#55 16#57 16#5f 16#60 16#68 16#69 16#6a 16#6b 16#6c 16#6d 16#6e 16#6f 16#70 16#71 16#72 16#73 16#74 16#75 16#95 16#96 16#97 16#b0 16#bf ] vg&undef pop ``` -------------------------------- ### Create a Bounding Box Frame Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Defines a PostScript procedure to create a rectangular frame using coordinates on the stack. ```postscript % Make a frame with the coordinates on the stack. % frame -- /frame {4 copy m 3 1 roll exch l 4 -2 roll l l h} def ``` -------------------------------- ### Color Mapping Dictionaries Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Dictionaries defining color mappings for display, print, grayscale, and black-and-white output. ```PostScript /displayColorMap << /Cr [1.00 0.00 0.00] /Cg [0.00 1.00 0.00] /Cb [0.00 0.00 1.00] /Cc [1.00 0.00 0.00 0.00] /Cm [0.00 1.00 0.00 0.00] /Cy [0.00 0.00 1.00 0.00] /Co [1.00 0.78 0.00] /Cp [1.00 0.67 0.67] /Cw [1 ] /Cgrl [0.75] /Cgr [0.50] /Cgrd [0.25] /Ck [0 ] /CGr [1.00 0.00 0.00] /CGg [0.00 1.00 0.00] /CGb [0.00 0.00 1.00] /CGc [1.00 0.00 0.00 0.00] /CGm [0.00 1.00 0.00 0.00] /CGy [0.00 0.00 1.00 0.00] /CGo [1.00 0.78 0.00] /CGp [1.00 0.67 0.67] /CGw [1 ] /CGgrl [0.75] /CGgr [0.50] /CGgrd [0.25] /CGk [0 ] /CIr [1.00 0.00 0.00] /CIg [0.00 1.00 0.00] /CIb [0.00 0.00 1.00] /CIc [1.00 0.00 0.00 0.00] /CIm [0.00 1.00 0.00 0.00] /CIy [0.00 0.00 1.00 0.00] /CIo [1.00 0.78 0.00] /CIp [1.00 0.67 0.67] /CIw [1 ] /CIgrl [0.75] /CIgr [0.50] /CIgrd [0.25] /CIk [0 ] >> def /printColorMap << /Cr [1.00 0.33 0.33] /Cg [0.33 1.00 0.33] /Cb [0.33 0.33 1.00] /Cc [1.00 0.00 0.00 0.00] /Cm [0.00 1.00 0.00 0.00] /Cy [0.00 0.00 1.00 0.00] /Co [1.00 0.78 0.00] /Cp [1.00 0.67 0.67] /Cw [1 ] /Cgrl [0.75] /Cgr [0.50] /Cgrd [0.25] /Ck [0 ] /CGr [1.00 0.33 0.33] /CGg [0.33 1.00 0.33] /CGb [0.33 0.33 1.00] /CGc [1.00 0.00 0.00 0.00] /CGm [0.00 1.00 0.00 0.00] /CGy [0.00 0.00 1.00 0.00] /CGo [1.00 0.78 0.00] /CGp [1.00 0.67 0.67] /CGw [1 ] /CGgrl [0.75] /CGgr [0.50] /CGgrd [0.25] /CGk [0 ] /CIr [1.00 0.33 0.33] /CIg [0.33 1.00 0.33] /CIb [0.33 0.33 1.00] /CIc [1.00 0.00 0.00 0.00] /CIm [0.00 1.00 0.00 0.00] /CIy [0.00 0.00 1.00 0.00] /CIo [1.00 0.78 0.00] /CIp [1.00 0.67 0.67] /CIw [1 ] /CIgrl [0.75] /CIgr [0.50] /CIgrd [0.25] /CIk [0 ] >> def /grayColorMap << /Cr [0 ] /Cg [0 ] /Cb [0 ] /Cc [0 ] /Cm [0 ] /Cy [0 ] /Co [0 ] /Cp [0 ] /Cw [0 ] /Cgrl [0 ] /Cgr [0 ] /Cgrd [0 ] /Ck [0 ] /CGr [0.75] /CGg [1 ] /CGb [0.50] /CGc [0.75] /CGm [0.50] /CGy [1 ] /CGo [0.75] /CGp [1 ] /CGw [0 ] /CGgrl [0.25] /CGgr [0.50] /CGgrd [0.75] /CGk [1 ] /CIr [1 ] /CIg [1 ] /CIb [1 ] /CIc [1 ] /CIm [1 ] /CIy [1 ] /CIo [1 ] /CIp [1 ] /CIw [1 ] /CIgrl [1 ] /CIgr [1 ] /CIgrd [1 ] /CIk [1 ] >> def /bwColorMap << /Cr [0 ] /Cg [0 ] /Cb [0 ] /Cc [0 ] /Cm [0 ] /Cy [0 ] /Co [0 ] /Cp [0 ] /Cw [0 ] /Cgrl [0 ] /Cgr [0 ] /Cgrd [0 ] ``` -------------------------------- ### Define Font Style Procedures Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Procedures to set font size and style for SansSerif, Serif, and Typewriter families. ```PostScript /vg&fontstyles [{cfontH} {cfontHB} {cfontHI} {cfontHBI}] def } def /cfontHB { dup /fontsize exch def /SansSerif-Bold exch sf /vg&fontstyles [{cfontH} {cfontHB} {cfontHI} {cfontHBI}] def } def /cfontHI { dup /fontsize exch def /SansSerif-Italic exch sf /vg&fontstyles [{cfontH} {cfontHB} {cfontHI} {cfontHBI}] def } def /cfontHBI { dup /fontsize exch def /SansSerif-BoldItalic exch sf /vg&fontstyles [{cfontH} {cfontHB} {cfontHI} {cfontHBI}] def } def /cfontT { dup /fontsize exch def /Serif exch sf /vg&fontstyles [{cfontT} {cfontTB} {cfontTI} {cfontTBI}] def } def /cfontTB { dup /fontsize exch def /Serif-Bold exch sf /vg&fontstyles [{cfontT} {cfontTB} {cfontTI} {cfontTBI}] def } def /cfontTI { dup /fontsize exch def /Serif-Italic exch sf /vg&fontstyles [{cfontT} {cfontTB} {cfontTI} {cfontTBI}] def } def /cfontTBI { dup /fontsize exch def /Serif-BoldItalic exch sf /vg&fontstyles [{cfontT} {cfontTB} {cfontTI} {cfontTBI}] def } def /cfontC { dup /fontsize exch def /Typewriter exch sf /vg&fontstyles [{cfontC} {cfontCB} {cfontCI} {cfontCBI}] def } def /cfontCB { dup /fontsize exch def /Typewriter-Bold exch sf /vg&fontstyles [{cfontC} {cfontCB} {cfontCI} {cfontCBI}] def } def /cfontCI { dup /fontsize exch def /Typewriter-Italic exch sf /vg&fontstyles [{cfontC} {cfontCB} {cfontCI} {cfontCBI}] def } def /cfontCBI { dup /fontsize exch def /Typewriter-BoldItalic exch sf /vg&fontstyles [{cfontC} {cfontCB} {cfontCI} {cfontCBI}] def } def ``` -------------------------------- ### Push Bounding Box Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Pushes the current accumulated bounding box coordinates onto the stack. ```postscript % Push the accumulated bounding box onto the stack. % -- pushbbox /pushbbox {bbllx bblly bburx bbury} def ``` -------------------------------- ### Restore Bounding Box Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Sets the bounding box to specific values provided on the stack. ```postscript % Set the bounding box to the values on the stack. % updatebbox -- /restorebbox { /bbury exch def /bburx exch def /bblly exch def /bbllx exch def } def ``` -------------------------------- ### Create New Skewed Base Font Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Creates a new base font with a skewed transformation matrix. Usage requires a key, encoding, base font name, and font object. ```PostScript % usage: key encoding basefontname vg&newskewedbasefont font /vg&newskewedbasefont { findfont dup length dict copy begin currentdict /FID undef /Encoding exch def dup /FontName exch def exch FontMatrix exch matrix concatmatrix /FontMatrix exch def currentdict end definefont } def ``` -------------------------------- ### Unicode String Processing Routines Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Routines for popping characters from strings and showing unicode characters. ```PostScript /popfirst { dup length 1 gt {dup 0 get /vg&fbyte exch def dup 1 get /vg&cbyte exch def dup length 2 sub 2 exch getinterval true} {pop false} ifelse } def ``` ```PostScript /unicharshow { 2 string dup 0 5 -1 roll put dup 1 4 -1 roll put internalshow } def ``` -------------------------------- ### Inflate Bounding Box Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Makes a relative bounding box relative to the current point, inflating it by a fraction of the font size. ```postscript % Make the relative bounding box relative to the currentpoint. % inflate /inflate { 2 {fontsize 0.2 mul add 4 1 roll} repeat 2 {fontsize 0.2 mul sub 4 1 roll} repeat } def ``` -------------------------------- ### Re-release Snapshot to GitHub Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/ReleaseToCentral.txt To force an update of an existing snapshot tag on GitHub, use the -f flag with git tag and git push. This overwrites the previous snapshot tag. ```bash git tag -f freehep-vectorgraphics-x.y-SNAPSHOT git push --tags -f ``` -------------------------------- ### PostScript Dictionary Definition Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt This PostScript code defines the '/procDict' dictionary, which is likely used to store and manage graphics-related procedures. It is set up to exchange the current dictionary with the new one. ```postscript end /procDict exch def ``` -------------------------------- ### Color Manipulation Procedure Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Procedure to darken or lighten the current color. ```PostScript % Darken or lighten the current color. /darken {0.7 exch exp 3 copy q 4 -1 roll vg&C currentrgbcolor 3 {4 -2 roll mul} repeat 3 array astore Q} def ``` -------------------------------- ### Text Baseline Adjustment Routines Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Routines to modify the text baseline for superscript and subscript formatting. ```PostScript /raise { 0 fontsize 2 div rmoveto /fontsize fontsize 2 mul 3 div def currentfont /FontName get fontsize sf } def ``` ```PostScript /unraise { /fontsize fontsize 1.5 mul def 0 fontsize 2 div neg rmoveto } def ``` ```PostScript /lower { 0 fontsize 3 div neg rmoveto /fontsize fontsize 2 mul 3 div def currentfont /FontName get fontsize sf } def ``` ```PostScript /unlower { /fontsize fontsize 1.5 mul def 0 fontsize 3 div rmoveto } def ``` -------------------------------- ### PostScript Procedures for Graphics Calculations Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt These PostScript procedures are used for calculating coordinate transformations and movements within the vector graphics system. They are typically used in conjunction with other graphics operations. ```postscript {calcval widx dx add neg dy neg rmoveto} % LR ``` ```postscript {calcval widx 2 div dx add neg widy dy add neg rmoveto} % UC ``` ```postscript {calcval widx 2 div dx add neg widy 2 div dy add neg rmoveto} % CC ``` ```postscript {calcval widx 2 div dx add neg 0 rmoveto} % BC ``` ```postscript {calcval widx 2 div dx add neg dy neg rmoveto} % LC ``` -------------------------------- ### Set Base Transformation Matrix Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Establishes the base transformation matrix for subsequent drawing operations. It handles translation, rotation, and scaling based on image origin and orientation. ```PostScript % set the base transformation matrix (usage: setbasematrix) /setbasematrix {imageorigin translate po {0}{90} ifelse rotate sfactor sfactor neg scale /defaultmatrix matrix currentmatrix def} def ``` -------------------------------- ### Define and Redefine Font Encodings Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Procedures for undefining and redefining specific values within a font's encoding array. Used for customizing font mappings. ```PostScript % Define the composite fonts used to print Unicode strings. % Undefine particular values in an encoding array. /vg&undef { {exch dup 3 -1 roll /.notdef put} forall } def /vg&redef { {3 -1 roll dup 4 2 roll put} forall } def ``` -------------------------------- ### Make Bounding Box Relative Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Adjusts bounding box coordinates to be relative to the current point. ```postscript % Make the relative bounding box relative to the currentpoint. % relative /relative { currentpoint 3 -1 roll add 3 1 roll add exch 4 2 roll currentpoint 3 -1 roll add 3 1 roll add exch 4 2 roll } def ``` -------------------------------- ### Define Clipping Region to Bounding Box Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Sets the clipping region to the bounding box of the current graphics state. This is useful for ensuring content stays within defined boundaries. ```PostScript /cliporigin {pw ml sub mr sub 2 div ml add po {gw}{gh} ifelse 2 div sub floor ph mt sub mb sub 2 div mb add po {gh}{gw} ifelse 2 div sub floor} def % Set the clipping region to the bounding box. /cliptobounds {cliporigin po {gw}{gh} ifelse 1 add po {gh}{gw} ifelse 1 add rc} def ``` -------------------------------- ### Create New Composite Font Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Defines a new composite font with specified style bits, font name, and encoding mappings. It integrates various character sets like Latin, Greek, and punctuation. ```PostScript % usage: newfontname basefontname vg&newcompositefont -- /vg&newcompositefont { /vg&fstyle exch def /vg&bfont exch def /vg&fname exch def << /FontStyleBits vg&fstyle /FontType 0 /FontMatrix matrix /FontName vg&fname /FMapType 2 /Encoding [ 0 1 255 {pop 6} for ] dup 16#00 0 put % Latin dup 16#03 1 put % Greek dup 16#20 2 put % Punctuation dup 16#21 3 put % Arrows dup 16#22 4 put % MathOps dup 16#27 5 put % Dingbats /FDepVector [ vg&bfont /-UC-Latin vg&nconcat UCLatinEncoding vg&bfont vg&newbasefont vg&bfont vg&skewmatrix vg&bfont /-UC-Greek vg&nconcat UCGreekEncoding /Symbol vg&newskewedbasefont vg&bfont /-UC-Punctuation vg&nconcat UCPunctuationEncoding vg&bfont vg&newbasefont /Arrows-UC findfont /MathOps-UC findfont /Dingbats-UC findfont /Undefined-UC findfont ] >> vg&fname exch definefont pop } def ``` -------------------------------- ### Register Base Fonts Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Registers the base fonts that do not require encoding changes. ```PostScript /Undefined-UC NullEncoding /Helvetica vg&newbasefont pop /MathOps-UC UCMathOpsEncoding /Symbol vg&newbasefont pop /Arrows-UC UCArrowsEncoding /Symbol vg&newbasefont pop /Dingbats-UC UCDingbatsEncoding /ZapfDingbats vg&newbasefont pop ``` -------------------------------- ### Apply Bias for Line Drawing Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Applies a translation of 0.5, 0.5 to adjust for the lower-right bias in drawing 1-point wide lines. 'unbias' reverts this transformation. ```PostScript % The lower-right bias in drawing 1 pt. wide lines. /bias {q 0.5 0.5 translate} def /unbias {Q} def ``` -------------------------------- ### Reset Bounding Box Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Resets the accumulated bounding box to a degenerate box at the current point. ```postscript % Resets the accumulated bounding box to a degenerate box at the % current point. % -- resetbbox -- /resetbbox { currentpoint 2 copy /bbury exch def /bburx exch def /bblly exch def /bbllx exch def } def ``` -------------------------------- ### Update Bounding Box Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Updates the accumulated bounding box with new coordinates, expanding it if necessary. ```postscript % Update the accumulated bounding box. % updatebbox -- /updatebbox { dup bbury gt {/bbury exch def} {pop} ifelse dup bburx gt {/bburx exch def} {pop} ifelse dup bblly lt {/bblly exch def} {pop} ifelse dup bbllx lt {/bbllx exch def} {pop} ifelse } def ``` -------------------------------- ### Apply Skew Matrix to Font Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Applies an italic angle transformation to a font's matrix if the 'FontInfo' dictionary contains an 'ItalicAngle'. Otherwise, it returns the original matrix. ```PostScript %usage: fontname vg&skewmatrix matrix /vg&skewmatrix { findfont dup /FontInfo known { /FontInfo get dup /ItalicAngle known { [ 1 0 4 -1 roll /ItalicAngle get neg dup sin exch cos div 1 0 0 ] } {pop matrix} ifelse } {pop matrix} ifelse } def ``` -------------------------------- ### Null Encoding Vector Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Defines a null encoding vector where all character codes map to '.notdef'. This serves as a base for other encodings. ```PostScript % Null encoding vector (all elements set to .notdef) /NullEncoding [ 256 {/.notdef} repeat ] def ``` -------------------------------- ### Register Composite Font Families Source: https://github.com/freehep/freehep-vectorgraphics/blob/master/freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt Registers various composite font families including SansSerif, Serif, Monospaced, Dialog, and Typewriter variants. ```PostScript /SansSerif /Helvetica 16#00 vg&newcompositefont /SansSerif-Bold /Helvetica-Bold 16#01 vg&newcompositefont /SansSerif-Italic /Helvetica-Oblique 16#02 vg&newcompositefont /SansSerif-BoldItalic /Helvetica-BoldOblique 16#03 vg&newcompositefont /Serif /Times-Roman 16#00 vg&newcompositefont /Serif-Bold /Times-Bold 16#01 vg&newcompositefont /Serif-Italic /Times-Italic 16#02 vg&newcompositefont /Serif-BoldItalic /Times-BoldItalic 16#03 vg&newcompositefont /Monospaced /Courier 16#00 vg&newcompositefont /Monospaced-Bold /Courier-Bold 16#01 vg&newcompositefont /Monospaced-Italic /Courier-Oblique 16#02 vg&newcompositefont /Monospaced-BoldItalic /Courier-BoldOblique 16#03 vg&newcompositefont /Dialog /Helvetica 16#00 vg&newcompositefont /Dialog-Bold /Helvetica-Bold 16#01 vg&newcompositefont /Dialog-Italic /Helvetica-Oblique 16#02 vg&newcompositefont /Dialog-BoldItalic /Helvetica-BoldOblique 16#03 vg&newcompositefont /DialogInput /Courier 16#00 vg&newcompositefont /DialogInput-Bold /Courier-Bold 16#01 vg&newcompositefont /DialogInput-Italic /Courier-Oblique 16#02 vg&newcompositefont /DialogInput-BoldItalic /Courier-BoldOblique 16#03 vg&newcompositefont /Typewriter /Courier 16#00 vg&newcompositefont /Typewriter-Bold /Courier-Bold 16#01 vg&newcompositefont /Typewriter-Italic /Courier-Oblique 16#02 vg&newcompositefont /Typewriter-BoldItalic /Courier-BoldOblique 16#03 vg&newcompositefont ```