Update the postscript file to be able to support much more stipples

The postscript template had a hardcoded stipple length of 29, any more stipples would cause problems with a postscript parser. This was particularly a problem since the default mos.24bit.dstyle has 36 stipples already.

It also used a base-30 encoding.

I have updated the template to fix both issues, it now uses base-10 encoding, and can support up to 255 stipples (which is the maximum length allowed by the current approach of using fonts)

I was also wondering if it made more sense to encode this file directly into the C program as a literal, as half of it already is in the C program. (some "begin"s have an "end" in strings directly embedded in magic, so this file basically serves as a large string that has to be loaded each time from disk, while other parts of the string are stored normally in memory)
This commit is contained in:
Ahmed Nematallah 2026-05-17 03:41:07 +02:00 committed by GitHub
parent 256955f48e
commit f3c2571b55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 6 deletions

View File

@ -26,17 +26,19 @@ StipplePattern begin
/FontMatrix [1 0 0 1 0 0] def
/FontBBox [0 0 1 1] def
/Encoding 256 array def
/PattName (P0) def
/tmpStr 1 string def
/PattName (P000) def
/tmpStr 3 string def
/NoPatt {<00>} def
0 1 255 { Encoding exch /NoPatt put } for
/BuildChar {
1 0 0 0 1 1 setcachedevice exch begin Encoding exch get load
64 64 true [64 0 0 64 0 0] 5 -1 roll imagemask end } def
end
/dp { StipplePattern begin dup 30 tmpStr cvrs PattName exch 1 exch
putinterval PattName cvn dup Encoding exch 4 -1 roll exch put exch
store end } def
/dp { StipplePattern begin
dup 10 tmpStr cvrs /num exch def
PattName 1 num putinterval
PattName 0 num length 1 add getinterval cvn
dup Encoding exch 4 -1 roll exch put exch store end } def
/sf { findfont exch scalefont setfont } bind def
/sp { patterns setfont 2 setlinewidth } def
/lb { gsave translate 0 0 moveto /just exch def gsave dup true charpath
@ -68,4 +70,3 @@ end
x y moveto w y lineto w h lineto x h lineto closepath clip bx } def
/tb {1 sub 3 1 roll gsave newpath moveto {lineto} repeat closepath clip pathbbox
/h exch def /w exch def /y exch def /x exch def bx } def