Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Carlos Newsgroups: comp.lang.postscript Subject: Re: Caching font metrics without a font cache? Date: Fri, 2 Dec 2016 18:59:25 +0100 Organization: A noiseless patient Spider Lines: 86 Message-ID: <20161202185925.68a0e79b@samara.DOMA> References: <9c7e7857-0eb1-4b4d-a127-6d43ace853ac@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Info: mx02.eternal-september.org; posting-host="4986dbdf0537636bb08eff15e6fc2ba5"; logging-data="11724"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19BOTN42iecIy+Iv8v+wbgUSeRJSVYOdsM=" X-Newsreader: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Cancel-Lock: sha1:kOM1MVpiUD0Wraci51bJhpBw0Co= Xref: csiph.com comp.lang.postscript:2954 [luser droog , 2016-12-01 16:34] [...] > Now /xadvance is part of the /show code used for type3 > fonts! It's my own code that's hitting this error! > Here is the implementation for type 3 fonts. > > from xpost/data/font.ps: > > /setcharwidth { > graphicsdict /currgstate get /currfont get > dup /xadvance 5 4 roll put > /yadvance 3 2 roll put > } def > > /setcachedevice { > pop pop pop pop > setcharwidth > } def > > /show { > graphicsdict /currgstate get /currfont get > dup /FontType get 3 ne { pop //show }{ > gsave > currentpoint translate > newpath > dup /FontMatrix get concat > exch > %pstack()= > { > gsave > 1 index /BuildChar get exec > grestore > graphicsdict /currgstate get /currfont get > dup /xadvance get 1 index /yadvance get > % ^^^ > % this get produces the error > % > translate > %hook > } forall > pop > 0 0 transform % use device-space coordinates to save > location past grestore grestore > itransform moveto > > } ifelse > } def > > > The dvips produced code /is/ calling setcachedevice, as it > ought to do, to declare the metrics, but then it does a > `restore` which is screwing the pooch. > > https://www.tug.org/svn/texlive/trunk/Build/source/texk/dvipsk/tex.lpro?revision=18107&view=markup#l147 > > > /CharBuilder % fontdict ch Charbuilder - -- image one character > {save 3 1 roll S A /base get 2 index get S /BitMaps get S get > /Cd X pop > /ctr 0 N > Cdx 0 Cx Cy Ch sub > Cx Cw add Cy > setcachedevice > Cw Ch true > [1 0 0 -1 -.1 Cx sub Cy .1 sub] > {Ci} imagemask > restore > } B > > > This `restore` is discarding the /xadvance and /yadvance from the > font dictionary which is in local memory. I suppose one obvious > solution is to store the values in global memory, or even in strings. > But these options seem less tidy. Strings would be inefficient to > decompose and reconstitute. But if the values are not /in/ the font, > still they need to be closely associated with the font. > > Hmm. Just not sure. Here is a (hackish) idea: put two unique marks in the stack (not necessarily --mark--s) before calling Build{Char,Glyph}; make setcachedevice and friends insert their arguments between those marks. Fish them out when Build{Char,Glyph} returns and process them then. --