5454 /integertype { dup cvr dup cvi ne {dup not} if cvi } bind % Force type error when precision is lost or boolean is given
5555>> readonly def
5656
57+ % Alias maps: old option names => canonical names
58+ /processoptions.aliases <<
59+ (alttext) /text1
60+ (alttextsubspace) /text1subspace
61+ (alttextsplit) /text1split
62+ (textlinegaps) /text1linegaps
63+ (textcolor) /text1color
64+ (textxalign) /text1xalign
65+ (textyalign) /text1yalign
66+ (textdirection) /text1direction
67+ (textfont) /text1font
68+ (textsize) /text1size
69+ (textxoffset) /text1xoffset
70+ (textyoffset) /text1yoffset
71+ (textgaps) /text1gaps
72+ (extratext) /text2
73+ (extratextsubspace) /text2subspace
74+ (extratextsplit) /text2split
75+ (extratextlinegaps) /text2linegaps
76+ (extratextcolor) /text2color
77+ (extratextxalign) /text2xalign
78+ (extratextyalign) /text2yalign
79+ (extratextdirection) /text2direction
80+ (extratextfont) /text2font
81+ (extratextsize) /text2size
82+ (extratextxoffset) /text2xoffset
83+ (extratextyoffset) /text2yoffset
84+ (extratextgaps) /text2gaps
85+ >> readonly def
86+
5787/processoptions.apply {
5888
5989 %
@@ -71,11 +101,20 @@ begin
71101 } if
72102
73103 %
74- % Apply options that exist in currentdict, converting values to existing types
104+ % Apply options that exist in currentdict, converting values to existing types.
105+ % Unknown options are checked against the alias map and applied to the canonical name.
75106 %
76107 mark exch dup
77108 {
78- exch dup currentdict exch known {
109+ exch dup currentdict exch known not { % Not known, but we might have been given an alias
110+ //processoptions.aliases 1 index 2 copy known {
111+ get dup 4 index exch known not { exch } if % Replace alias key with canonical, if no clash
112+ pop
113+ } {
114+ pop pop
115+ } ifelse
116+ } if
117+ dup currentdict exch known {
79118 dup load type 3 -1 roll exch
80119 //processoptions.typemap exch get stopped {
81120 pop pop
@@ -198,34 +237,13 @@ begin
198237
199238} bind def
200239
201- %
202- % Resolve alias options: for each alias in the table, if the user set
203- % the alias in their options dict, copy the value to the primary name.
204- % User-set primary always wins.
205- %
206- /processoptions.resolve { % optionsdict aliastable --
207- { % optdict alias-key primary-name
208- 2 index 1 index known { % user set primary? => primary wins
209- pop pop
210- } {
211- 2 index 2 index known { % user set alias in options?
212- exch load def % copy alias value to primary
213- } {
214- pop pop
215- } ifelse
216- } ifelse
217- } forall
218- pop % optdict
219- } bind def
220-
221240%
222241% Dispatcher table
223242%
224243/processoptions.dispatch <<
225244 /apply //processoptions.apply
226245 /generategroup //processoptions.generate
227246 /collectgroup //processoptions.collect
228- /resolve //processoptions.resolve
229247>> readonly def
230248
231249/processoptions {
0 commit comments