dan@kfw.COM (Dan Mick) (02/26/91)
Should load work on a non-name-type operand? In other words would you expect this to work: (Times-Roman) load setfont , or does it have to be (Times-Roman) cvn load setfont ?
mzellers@starnet.uucp (Mark Zellers) (02/27/91)
In article <1991Feb26.010153.5370@kfw.COM> dan@kfw.com (Dan Mick) writes: > >Should load work on a non-name-type operand? > In a word, yes. Dictionary keys are not limited to being name objects. To quote book, chapter and verse, the Adobe Red Book says: "Keys are normally name objects; the PostScript syntax and the interpreter are optimized for this most common case. However, a key may be any PostScript object except null. If you attempt to use a string as a key, PostScript will first convert the string to a name object; thus, strings and names are interchangable when used as keys in dictionaries." Mark H. Zellers decwrl.dec.com!bwayne!voltaire!mark
cet1@cl.cam.ac.uk (C.E. Thompson) (02/28/91)
In article <436@heaven.woodside.ca.us> glenn@heaven.woodside.ca.us (Glenn Reid) writes: >Dan Mick writes >> >> Should load work on a non-name-type operand? >> >> In other words would you expect this to work: >> >> (Times-Roman) load setfont >> >> , or does it have to be >> >> (Times-Roman) cvn load setfont > >Yes, the "load" operator works with non-name-type operands. So does >the "def" operator, its converse. The following examples are all >perfectly legitimate in PostScript: > >3 (three) def >3 load == returns the string (three) > >(four) 4 def >(four) load == returns the integer 4 > >5 (five) def >3 2 add load == returns the string (five) > Every word you say is true, Glenn, but I think you may be misleading the original poster. Keys in PostScript directories can have any type (although the case of names is usually optimised), but the type is significant when matching the key. Thus the user's two examples may both be valid, but they won't access the same directory entries. If, as one rather suspects, he has added FontDirectory to the directory stack and is hoping to find the canonical Times-Roman font, only the second will have the desired effect. Chris Thompson JANET: cet1@uk.ac.cam.phx Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk
kevina@apple.com (Nobody you know) (03/01/91)
In article <1991Feb26.010153.5370@kfw.COM> dan@kfw.COM (Dan Mick) writes: > Should load work on a non-name-type operand? > > In other words would you expect this to work: > > (Times-Roman) load setfont > > , or does it have to be > > (Times-Roman) cvn load setfont > Load will work on any type of operand... you can associate a value in a dictionary with any type of key (except a null object.) Note that strings are converted to names automatically when used as keys, so (name) (Kevin) def /name load and /name (Kevin) def (name) load will both return (Kevin) on the stack. (See pg. 30 of Red Book 1 or pg. 40 of Red Book 2.) Of course, neither of your examples will work unless you've defined a font dictionary with the name /Times-Roman... otherwise you're missing a findfont! --Kevin Andresen [kevina@apple.com] "You take the wind right out of my sails/It must be luff, it must be luff"
cet1@cl.cam.ac.uk (C.E. Thompson) (03/01/91)
In article <1991Feb28.151933.8786@cl.cam.ac.uk> I wrote: > {Original articles omitted} >Every word you say is true, Glenn, but I think you may be misleading the >original poster. Keys in PostScript directories can have any type (although >the case of names is usually optimised), but the type is significant when >matching the key. Thus the user's two examples may both be valid, but >they won't access the same directory entries. If, as one rather suspects, >he has added FontDirectory to the directory stack and is hoping to find >the canonical Times-Roman font, only the second will have the desired effect. > After seeing Kevin Andresen's posting, I realise I was quite wrong here! In the specific case of strings, they are coerced to names during directory lookup. Thus the two original PostScript fragments will have identical effect. Mea culpa, and that may teach me to try the experiment before posting next time. Chris Thompson JANET: cet1@uk.ac.cam.phx Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk
glenn@heaven.woodside.ca.us (Glenn Reid) (03/03/91)
In article <1991Feb28.151933.8786@cl.cam.ac.uk> cet1@cl.cam.ac.uk (C.E. Thompson) writes: > In article <436@heaven.woodside.ca.us> Glenn Reid writes: > >Dan Mick writes Dan> >> In other words would you expect this to work: Dan> >> (Times-Roman) load setfont Dan> >> , or does it have to be Dan> >> (Times-Roman) cvn load setfont Glenn> >Yes, the "load" operator works with non-name-type operands. So does Glenn> >the "def" operator, its converse. The following examples are all Glenn> >perfectly legitimate in PostScript: Chris> Every word you say is true, Glenn, but I think you may be misleading the > original poster. Keys in PostScript directories can have any type (although > the case of names is usually optimised), but the type is significant when > matching the key. Thus the user's two examples may both be valid, but > they won't access the same directory entries. If, as one rather suspects, > he has added FontDirectory to the directory stack and is hoping to find > the canonical Times-Roman font, only the second will have the desired effect. I'll certainly admit to the likelihood that I was missing the point and misleading the original poster, but I have to point out that strings and names are in fact equivalent from the dictionary-lookup point of view (as a recent posting indicated, quoting directly from the Red Book that strings are in fact converted to names by the "def" operator, and presumably by the "load" operator as well, since it works). This works fine: FontDirectory begin (Times-Roman) load 12 scalefont setfont But it is certainly not the recommended way to set a font. I can't believe, somehow, that the original poster would have happened upon "load" before discovering "findfont", since almost every single example of PostScript I've even seen uses "findfont", and very few of them use "load". I suspect that there was another motivation for the question. If Dan Mick is still out there reading all this drivel, perhaps he could post again and let us know just what he was really after, and if any of our various followups have helped at all :-) -- Glenn Reid RightBrain Software glenn@heaven.woodside.ca.us NeXT/PostScript developers ..{adobe,next}!heaven!glenn 415-851-1785 (fax 851-1470)