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


Groups > comp.lang.postscript > #2953 > unrolled thread

Caching font metrics without a font cache?

Started byluser droog <luser.droog@gmail.com>
First post2016-12-01 16:34 -0800
Last post2016-12-02 19:44 -0800
Articles 3 — 2 participants

Back to article view | Back to comp.lang.postscript


Contents

  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

#2953 — Caching font metrics without a font cache?

Fromluser droog <luser.droog@gmail.com>
Date2016-12-01 16:34 -0800
SubjectCaching font metrics without a font cache?
Message-ID<9c7e7857-0eb1-4b4d-a127-6d43ace853ac@googlegroups.com>
We're fixing one problem at a time until xpost can run
the output from dvips. And the latest one has me wondering
what's the best way to solve it.

The problem manifests as an /undefined error in /xadvance.
Here is the error output with extra INFO messages.

josh@LAPTOP-ILO10OOF ~/xpost
$ xpost /cygdrive/c/Users/josh/Downloads/test_unix.ps 
INF: src/lib/xpost_log.c:292 xpost_log_init() dump interpreter errors in file xdump3klDMy
INF: src/lib/xpost_memory.c:133 xpost_memory_file_init() init memory file for lmem39VjNQ
INF: src/lib/xpost_memory.c:321 xpost_memory_file_grow() grow memory file for lmem39VjNQ (old: 65536  new: 131072)
INF: src/lib/xpost_memory.c:133 xpost_memory_file_init() init memory file for gmemdQVcBJ
INF: src/lib/xpost_memory.c:321 xpost_memory_file_grow() grow memory file for gmemdQVcBJ (old: 65536  new: 131072)
INF: src/lib/xpost_memory.c:321 xpost_memory_file_grow() grow memory file for lmem39VjNQ (old: 131072  new: 196608)
INF: src/lib/xpost_memory.c:321 xpost_memory_file_grow() grow memory file for gmemdQVcBJ (old: 131072  new: 196608)
INF: src/bin/xpost_main.c:432 main() defs=0x0
INF: src/lib/xpost_memory.c:321 xpost_memory_file_grow() grow memory file for lmem39VjNQ (old: 196608  new: 262144)
INF: src/lib/xpost_memory.c:321 xpost_memory_file_grow() grow memory file for lmem39VjNQ (old: 262144  new: 327680)
INF: src/lib/xpost_memory.c:321 xpost_memory_file_grow() grow memory file for lmem39VjNQ (old: 327680  new: 393216)
INF: src/lib/xpost_op_matrix.c:207 _default_matrix() loaded graphicsdict
INF: src/lib/xpost_op_matrix.c:212 _default_matrix() loaded gstate
INF: src/lib/xpost_op_matrix.c:217 _default_matrix() loaded device
INF: src/lib/xpost_op_matrix.c:222 _default_matrix() loaded defaultmatrix
INF: src/lib/xpost_memory.c:321 xpost_memory_file_grow() grow memory file for lmem39VjNQ (old: 393216  new: 458752)
save
INF: src/lib/xpost_memory.c:321 xpost_memory_file_grow() grow memory file for lmem39VjNQ (old: 458752  new: 524288)
save
INF: src/lib/xpost_save.c:187 _copy_ent() ent 1589 copied to ent 2073 in lmem39VjNQ
INF: src/lib/xpost_save.c:187 _copy_ent() ent 2034 copied to ent 2074 in lmem39VjNQ
INF: src/lib/xpost_save.c:263 xpost_save_restore_snapshot() restoring 2 save records
INF: src/lib/xpost_save.c:274 xpost_save_restore_snapshot() replacing ent 2034 with copy ent 2074
INF: src/lib/xpost_save.c:274 xpost_save_restore_snapshot() replacing ent 1589 with copy ent 2073
restore
INF: src/lib/xpost_save.c:187 _copy_ent() ent 23 copied to ent 2077 in lmem39VjNQ
%%[ Error: undefined; OffendingCommand: get]%%
Stack:
33 
-dict- 
-dict- 
/xadvance 
ExecStack:
--quit--
{ { handleerror } if quit } 
false 
{ executive } 
-file- 
{ tail } 
{ pop 0 0 transform grestore itransform moveto } 
--forall--
--cvx--
[ gsave 1 index /BuildChar get exec grestore graphicsdict /currgstate 
get /currfont get dup /xadvance get 1 index /yadvance get translate ] 
()
{ 1 index /yadvance get translate } 
INF: src/lib/xpost_interpreter.c:1358 xpost_run() destroying device
INF: src/lib/xpost_interpreter.c:1362 xpost_run() device type=arraytype
INF: src/lib/xpost_interpreter.c:1365 xpost_run() running proc
INF: src/lib/xpost_interpreter.c:1377 xpost_run() destroying device dict
INF: src/lib/xpost_interpreter.c:1387 xpost_run() destroyed device
INF: src/lib/xpost_save.c:263 xpost_save_restore_snapshot() restoring 0 save records
INF: src/lib/xpost_save.c:263 xpost_save_restore_snapshot() restoring 1 save records
INF: src/lib/xpost_save.c:274 xpost_save_restore_snapshot() replacing ent 23 with copy ent 2077
INF: src/lib/xpost_save.c:263 xpost_save_restore_snapshot() restoring 0 save records


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.

[toc] | [next] | [standalone]


#2954

FromCarlos <angus@quovadis.com.ar>
Date2016-12-02 18:59 +0100
Message-ID<20161202185925.68a0e79b@samara.DOMA>
In reply to#2953
[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.

-- 

[toc] | [prev] | [next] | [standalone]


#2956

Fromluser droog <luser.droog@gmail.com>
Date2016-12-02 19:44 -0800
Message-ID<fdad36af-12c2-4015-8bb6-7e78137e31db@googlegroups.com>
In reply to#2954
On Friday, December 2, 2016 at 11:59:26 AM UTC-6, Carlos wrote:
> [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!
[snip]
> > 
> > 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
> > 
> > 
[snip]
> > 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.
> 

That would work, too. Stacks are of course also immune
to save and restore. I think the easiest thing is 
globaldict with dotted names. I can force validity 
without checking anything by just clearing them each time.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.postscript


csiph-web