Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #2954

Re: Caching font metrics without a font cache?

From Carlos <angus@quovadis.com.ar>
Newsgroups comp.lang.postscript
Subject Re: Caching font metrics without a font cache?
Date 2016-12-02 18:59 +0100
Organization A noiseless patient Spider
Message-ID <20161202185925.68a0e79b@samara.DOMA> (permalink)
References <9c7e7857-0eb1-4b4d-a127-6d43ace853ac@googlegroups.com>

Show all headers | View raw


[luser droog <luser.droog@gmail.com>, 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.

-- 

Back to comp.lang.postscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Caching font metrics without a font cache? luser droog <luser.droog@gmail.com> - 2016-12-01 16:34 -0800
  Re: Caching font metrics without a font cache? Carlos <angus@quovadis.com.ar> - 2016-12-02 18:59 +0100
    Re: Caching font metrics without a font cache? luser droog <luser.droog@gmail.com> - 2016-12-02 19:44 -0800

csiph-web