ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Arthur Reutenauer <arthur.reutenauer@normalesup.org>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Bug in pstoedit 3.44 (was: makempy (pstoedit <-> gs) hangs)
Date: Mon, 30 Jul 2007 23:52:02 +0200	[thread overview]
Message-ID: <20070730215202.GD4593@phare.normalesup.org> (raw)
In-Reply-To: <22af238a0707300854k6af19acv71d0c8028b49c798@mail.gmail.com>

> I'm interested, but it is good to post the explanation so it becomes
> part of the public record google can find.

  Well, that wouldn't be the first time I report a bug indirectly; so here goes:

  When font dictionaries are altered (by changing FontMatrix, etc ...)
in PostScript, it is customary to keep a copy of the original
dictionary, which appears in the modified dictionary as a object
associated with the key OrigFont.  Now, if a programmer wants to access
the original dictionary, he / she must of course expect to search the
dictionary recursively; hence the original definition of getorigfont
(which wasn't that bad actually):

        % Here the stack must contain a font dictionary
        /getorigfont
        {
          dup /OrigFont known
          {
            /OrigFont get getorigfont
          }
          if
        }
        def

  This definition could have worked in other languages ... but not in
PostScript, because of the nature of dictionaries: they're so-called
“composite objects”, meaning that if you copy this object on the stack you get
eaxctly the same physical object (this is a bit like pointers in C); for
further details see the PostScript Language Reference Manual, section 3.3.1
(http://www.adobe.com/products/postscript/pdfs/PLRM.pdf).  Anyway, this means
that a dictionary can contain itself, and this was the case with the font at
stake (LMSans by the Latin Modern team, converted from cminch by Knuth).  So
retrieving OrigFont yielded the exact same dictionary at each iteration, and
this created the endless loop.

  This (somewhat weird) definition of the font only started with
Ghostscript 8.56; this is why the bug didn't happen with older versions
of Ghostscript.

  The real bugfix Wolfgang Glunz (author of pstoedit) did was to check
at each iteration if the retrieved OrigFont dictionary was actually
different, thus avoiding the loop, but still looking for the “most
original” font dictionary.  As I said, the new code will be incorporated in
pstoedit 3.45 and looks like:

	% font getorigfont font
	/getorigfont
	{ 210 pscover
	  %
	  % retrieves the father font of the input font if possible
	  % returns a font.
	  %
	  dup /OrigFont known
	  % OrigFont is provided at least if Font was generated with makefont
	  { 211 pscover
	    dup % for comparison
	    dup /OrigFont get ne  % ne is a weak check against recursion
	                          % but is was needed from gs8.56
	    {
	      /OrigFont get getorigfont
	    } if
	  } if
	}
	def

  For people wanting to experiment with pstoedit, you will certainly find the
-pscover switch most useful: it writes to the file “pscover.txt” a unique
number corresponding to a particular chunk of code in the PostScript prologue
(the psinXXXXXX file); look for “xyz pscover”, where xyz is a integral number;
this is how I found the bug in the first place.

   That's about all. Hope you had fun reading this,

	Arthur
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2007-07-30 21:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1.1185789602.14300.ntg-context@ntg.nl>
2007-07-30 12:30 ` makempy (pstoedit <-> gs) hangs Wolfgang Werners-Lucchini
2007-07-30 13:03   ` Arthur Reutenauer
2007-07-30 13:46     ` luigi scarso
2007-07-30 15:54     ` George N. White III
2007-07-30 21:52       ` Arthur Reutenauer [this message]
2007-07-31  8:07         ` Bug in pstoedit 3.44 (was: makempy (pstoedit <-> gs) hangs) luigi scarso
2007-07-30 22:42   ` makempy (pstoedit <-> gs) hangs luigi scarso
2007-07-31 20:02 ` itemize with zero start Wolfgang Werners-Lucchini
2007-07-31 20:36   ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070730215202.GD4593@phare.normalesup.org \
    --to=arthur.reutenauer@normalesup.org \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).