auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-devel] Asking help for preview-latex


From: Ikumi Keita
Subject: [AUCTeX-devel] Asking help for preview-latex
Date: Wed, 19 Jun 2019 01:04:07 +0900

Dear Ghostscript developers,

I'd like to ask you for help to restore functionality of preview-latex,
which uses Ghostscript to show math formulae images in Emacs buffer of
LaTeX documents.  I'm one of developers of AUCTeX, which has
preview-latex as its subsystem: https://www.gnu.org/software/auctex/ .

Let me begin with overview of the problem we (AUCTeX developers) want to
address.  It was reported recently that preview-latex does not work
under certain circumstances:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=35571
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=35696
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=36039
In short, Ghostscript stops with error when preview-latex tries to
adjust the foreground color of the generated image to be the same as
that of Emacs face.

We consider the reason of the problem is that preview-latex relies on
GS_PDF_ProcSet, which was removed in Ghostscript 9.27, from the
following three observations:
(1) Preview-latex works well when the user downgrades to gs-9.26:
https://lists.gnu.org/archive/html/bug-auctex/2019-05/msg00034.html
(2) Typical error message (quoted at the last of this message) tells
that "GS_PDF_ProcSet" caused the error and I found that the official
Ghostscript document[1] says "We eliminated GS_PDF_ProcSet".

[1] https://www.ghostscript.com/doc/9.27/History9.htm
(3) The only function which uses GS_PDF_ProcSet in the preview-latex
source is called only when the default face of Emacs has non-trivial
foreground color and preview-latex tries to adjust the foreground color
of the generated image to be the same as that.  In fact, I encounter no
errors even with gs-9.27 when I use preview-latex with standard
foreground color (black) in Emacs.

Assuming the above consideration is correct, we would appreciate if you,
the Ghostscript developers, could kindly provide alternate Postscript
code to achieve the original purpose of preview-latex.  The relevant
elisp code is:
----------------------------------------------------------------------
(defun preview-pdf-color-string (colors)
  "Return a string that patches PDF foreground color to work properly."
  ;; Actually, this is rather brutal.  It will only be invoked in
  ;; cases, however, where previously it was not expected that
  ;; anything readable turned up, anyway.
  (let ((fg (aref colors 1)))
    (if fg
        (concat
         "/GS_PDF_ProcSet GS_PDF_ProcSet dup maxlength dict copy dup begin\
/graphicsbeginpage{//graphicsbeginpage exec "
         (mapconcat #'preview-gs-color-value fg " ")
         " 3 copy rg RG}bind store end readonly store "))))
----------------------------------------------------------------------
.  What we would like to know is the code (string) to replace the
"/GS_PDF_ProcSet GS_PDF_ProcSet dup..." part.  Unfortunately, I don't
understand any Postscript language, but I hope that the above piece of
code together with the error message quoted at the last of this message
is enough to determine what to do, even without knowledge of elisp.
Please note that these codes go through pdf2dsc.

If the given information is not enough, feel free to ask us any
additional materials.

Please keep address@hidden in CC: when replying.

Best regards,
Ikumi Keita

/usr/local/texlive/2019/bin/amd64-freebsd/rungs 
-dOutputFile\=\(tst-prv.prv/tmpgIMQ85/pr1-1.png\) -q -dDELAYSAFER -dNOPAUSE 
-DNOPLATFONTS -dPrinted -dTextAlphaBits\=4 -dGraphicsAlphaBits\=4 
-sDEVICE\=png16m -r108.606x108.587
GS>{<</PermitFileReading[(tst-prv.pdf)(tst-prv.prv/tmpgIMQ85/preview.dsc)]>> 
setuserparams .locksafe} stopped pop {DELAYSAFER{.setsafe}if}stopped 
pop/.preview-BP currentpagedevice/BeginPage get dup null eq{pop{pop}bind}if 
def<</BeginPage{currentpagedevice/PageSize get dup 0 get 1 ne exch 1 get 1 ne 
or{.preview-BP 0.925795 0.925795 0.925795 setrgbcolor clippath fill 0.17969 
0.203128 0.210941 setrgbcolor}{pop}ifelse}bind/PageSize[1 
1]>>setpagedevice/preview-do{/.preview-ST[count 4 roll save]def dup length 0 
eq{pop}{setpagedevice}{ifelse exec}stopped{handleerror quit}if .preview-ST 
aload pop restore}bind def /GS_PDF_ProcSet GS_PDF_ProcSet dup maxlength dict 
copy dup begin/graphicsbeginpage{//graphicsbeginpage exec 0.17969 0.203128 
0.210941 3 copy rg RG}bind store end readonly store  
(tst-prv.prv/tmpgIMQ85/preview.dsc)(r)file /.preview-ST 1 index def dup 0 
setfileposition 415()/SubFileDecode filter cvx exec .preview-ST dup dup 415 
setfileposition 53()/SubFileDecode filter cvx<<>>preview-
 do
Error: /undefined in GS_PDF_ProcSet
Operand stack:
   GS_PDF_ProcSet
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   
--nostringval--   2   %stopped_push   --nostringval--   --nostringval--   
%loop_continue   --nostringval--   --nostringval--   false   1   %stopped_push  
 .runexec2   --nostringval--   --nostringval--   --nostringval--   2   
%stopped_push   --nostringval--
Dictionary stack:
   --dict:739/1123(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 641
GS<1>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]