Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

epstopdf embeds standard fonts within "only for me" installations, but it should not #393

Closed
1 task done
ivankokan opened this issue Oct 16, 2019 · 44 comments · Fixed by #404
Closed
1 task done
Assignees
Milestone

Comments

@ivankokan
Copy link
Contributor

ivankokan commented Oct 16, 2019

Hi @edocevoli, @u-fischer.

I found the root cause of #296, #339 and #386, and hereby I explain how to resolve them.

Firstly, here is how I managed to get embedded fonts within 32-bit and 64-bit MiKTeX installations for "all users":

C:\Users\win10-32-all>mgs.exe -dDEBUG -dNOPAUSE -sDEVICE=pdfwrite -dSAFER -dAutoRotatePages=/None -I"C:\Program Files\MiKTeX 2.9\ghostscript\base\Fontmap" -sOutputFile=dummy.pdf -f dummy.eps -c quit

The crucial part is the -I switch (https://www.ghostscript.com/doc/current/Use.htm#I_switch), and I got the idea from https://stackoverflow.com/a/52887749/9402145:

In older versions of Ghostscript we did not even ship the support files for Windows, 9.25 is the first (Windows) version where these files are actually installed without extra effort from the user.

The Windows version (and in fact all versions now) defaults to using a ROM file system. That is, the support files are compiled into the executable. What that means is that Ghostscript doesn't look at the disk files, unless you tell it to.

You need to add a -I (Include) directive to tell Ghostscript to look at the modified files on disk. In your case that would be :

-IC:/Program Files/gs/gs9.25/Resource/Init

Considering that MiKTeX's epstopdf uses mgs of version 9.25 (and things within Ghostscript changed in this context in version 9.25), it is mandatory to use -I switch pointing to Fontmap (placed under C:\Program Files\MiKTeX 2.9\ghostscript\base or C:\Users\<user>\AppData\Local\Programs\MiKTeX 2.9\ghostscript\base) that utilizes MiKTeX's font packages (defines fonts from MiKTeX's font packages by (Fontmap.MiKTeX) .runlibfile and then defines aliases by (Fontmap.aliases) .runlibfile).

The issue can be resolved adding -I switch with appropriate arguments somewhere around here:

vector<string>gsOptions{ gsExe.GetFileName().ToString() };
gsOptions.insert(gsOptions.end(), gsExtra.begin(), gsExtra.end());
gsOptions.push_back("-q");
gsOptions.push_back("-sDEVICE="s + "pdfwrite");
gsOptions.push_back("-dSAFER");
#if 1 // 642845
gsOptions.push_back("-dAutoRotatePages="s + "/None");
#endif

(Explicitly using -I switch within "only for me" MiKTeX installations, with proper path to Fontmap, preserves the wanted behavior.)

I hope it is at least clear how to resolve the issue (if you still have trouble understanding it :)).

Kind regards, Ivan

@ivankokan ivankokan changed the title Fix for #296, #339, and #386 Fix for #296, #339 and #386 Oct 16, 2019
@edocevoli
Copy link
Member

MiKTeX sets the environment variable MIKTEX_GS_LIB (equiv of Ghostscripts GS_LIB). On my system, this environment variable has the value:

C:\MiKTeX 2.9\ghostscript\base;C:\MiKTeX 2.9\fonts

(C:\MiKTeX 2.9 is the installation directory.)

You can check it on your system by opening a Terminal window via MiKTeX console and running echo %MIKTEX_GS_LIB%.

That said: your fix is already implemented...

@ivankokan
Copy link
Contributor Author

ivankokan commented Oct 16, 2019

It (MIKTEX_GS_LIB) definitely is, and it should have effect, but it apparently does not have effect within "all users" installations (installed with latest installers) on my fresh Win10 VMs (only MiKTeX is installed).

Not sure what else I can provide to convince that issue exists. 😕 Please suggest.

@edocevoli
Copy link
Member

edocevoli commented Oct 16, 2019

MIKTEX_GS_LIB should be honoured by mgs in an all user environment. I will check this.

@edocevoli edocevoli reopened this Oct 16, 2019
@edocevoli edocevoli self-assigned this Oct 16, 2019
@edocevoli
Copy link
Member

edocevoli commented Oct 16, 2019

On my system, running mgs --help produces:

Search path:
   C:\MiKTeX 2.9\ghostscript\base ; C:\MiKTeX 2.9\fonts ;
   %rom%Resource/Init/ ; %rom%lib/ ; c:/gs/gs9.25/Resource/Init ;
   c:/gs/gs9.25/lib ; c:/gs/gs9.25/Resource/Font ; c:/gs/fonts

Please:

  1. start MiKTeX console
  2. click the Terminal icon
  3. run mgs --help

@edocevoli edocevoli added this to the 2.9.7200 milestone Oct 16, 2019
@edocevoli edocevoli removed the bug label Oct 16, 2019
@edocevoli edocevoli removed this from the 2.9.7200 milestone Oct 16, 2019
@ivankokan
Copy link
Contributor Author

Here is everything recorded, step by step.
step_by_step_recorded.zip
files_and_logs.zip

It seems that Steps Recorder did not capture the output of pdffonts dummy.pdf, but they were as given here #386 (comment).

@ivankokan
Copy link
Contributor Author

On my system, running mgs --help produces:

Search path:
   C:\MiKTeX 2.9\ghostscript\base ; C:\MiKTeX 2.9\fonts ;
   %rom%Resource/Init/ ; %rom%lib/ ; c:/gs/gs9.25/Resource/Init ;
   c:/gs/gs9.25/lib ; c:/gs/gs9.25/Resource/Font ; c:/gs/fonts

Please:

  1. start MiKTeX console
  2. click the Terminal icon
  3. run mgs --help

Do you have true Ghostscript installed on your system in c:/gs/gs9.25? My VMs do not have anything except Windows, Chrome and MiKTeX.

@edocevoli
Copy link
Member

No, I do not have another Ghostscript installed.

By the way, since Fontmap is a file, the proposed fix makes no sense. From the gs(1) man page:

-Idirectories
Adds the designated list of directories at the head of the search path for library files.

@ivankokan
Copy link
Contributor Author

ivankokan commented Oct 16, 2019

No, I do not have another Ghostscript installed.

By the way, since Fontmap is a file, the proposed fix makes no sense. From the gs(1) man page:

-Idirectories
Adds the designated list of directories at the head of the search path for library files.

I would agree on that if mgs had its own /Resource/Init, but it does not. The only thing it has is its Fontmap (entry point, so to say), and using it for -I works (regardless of user/system installation).

These are the facts:

  • the issue exists on system-wide installations (I hope you checked what I recorded) - that is why I have troubles with Closed status in general
  • epstopdf does not behave consistently nor in line with its manual
  • -I + Fontmap is the only way to resolve the issue we know so far.

Please, do not get me wrong. You are the maintainer and owner, and you will decide what to do. I am just afraid that some other peers will experience the same issue and start digging from scratch not knowing that issue has been discussed already. The use case (IEEE article) I mentioned here #386 (comment) was not mine but friends'. I started to investigate it (April 2019) because I could not believed "it works on my system but not on theirs". It ended with having 9 VMs in total combining various Win10 and MiKTeX installations.

Hopefully someone else will see this issue (Open), and eventually help on it one day, with some proper? explanation and the fix proposal.

Kind regards, Ivan

@ivankokan
Copy link
Contributor Author

On the other hand,

-sFONTMAP=filename1;filename2;...
Specifies alternate name or names for the Fontmap file. Note that the names are separated by ":" on Unix systems, by ";" on MS Windows systems, and by "," on VMS systems, just as for search paths.

could make sense.

@ivankokan
Copy link
Contributor Author

epstopdf dummy.eps
REM It does not embed Courier-Bold font
pdffonts dummy.pdf

REM Print what would be done
epstopdf -n dummy.eps

REM Only -dNOPAUSE and -f dummy.eps are added
mgs.exe -dNOPAUSE -q -sDEVICE=pdfwrite -dSAFER -dAutoRotatePages=/None -sOutputFile=.\dummy_mgs.pdf -f dummy.eps -c quit
REM It **does** embed Courier-Bold font
pdffonts dummy_mgs.pdf

REM Why???

logs.zip

@edocevoli
Copy link
Member

Can you try it without the -f switch and -dNOPAUSE?

mgs.exe -q -sDEVICE=pdfwrite -dSAFER -dAutoRotatePages=/None -sOutputFile=.\dummy_mgs.pdf - -c quit < dummy.eps

@edocevoli
Copy link
Member

You should note: by default Ghostscript does not embed standard fonts like Courier-Bold. That said, its totally fine that Courier-Bold is not embedded.

@ivankokan
Copy link
Contributor Author

ivankokan commented Oct 17, 2019

Can you try it without the -f switch and -dNOPAUSE?

mgs.exe -q -sDEVICE=pdfwrite -dSAFER -dAutoRotatePages=/None -sOutputFile=.\dummy_mgs.pdf - -c quit < dummy.eps
C:\Users\user\Documents>mgs.exe -q -sDEVICE=pdfwrite -dSAFER -dAutoRotatePages=/None -sOutputFile=.\dummy_mgs.pdf - -c quit < dummy.eps

C:\Users\user\Documents>pdffonts dummy_mgs.pdf
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
BCXUOL+Courier-Bold                  Type 1C           WinAnsi          yes yes no       8  0

You should note: by default Ghostscript does not embed standard fonts like Courier-Bold. That said, its totally fine that Courier-Bold is not embedded.

I totally agree with that (I guess that used dPDFSETTINGS are default): https://www.ghostscript.com/doc/9.25/VectorDevices.htm#note_11.

Check https://stackoverflow.com/a/41243959/9402145. (My comment there dates back in May when only #296 was being discussed; just neglect the part about 32-bit vs 64-bit.)

Here we notice inconsistent behavior - can we resolve that?

  • embedding in "only for me" installations
  • no embedding in for "all users" installations.

I am in favor of embedding (and probably not the only one?) but I would be happy with any behavior if it is consistent. Nevertheless, one can (apparently) always force embedding this way -c "<</NeverEmbed []>> setdistillerparams" -f.

I mean, the font packages are installed by default (except symbol, MiKTeX/miktex-packaging#112), Fontmap.MiKTeX exposes them, and aliases are defined in Fontmap.aliases. As example, for Courier-Bold we have two fonts defined in Fontmap.MiKTeX:

/Courier-Bold (type1/adobe/courier/pcrb8a.pfb) ;
/NimbusMonL-Bold (type1/urw/courier/ucrb8a.pfb) ;

but then the alias is set /Courier-Bold /NimbusMonL-Bold ;, effectively yielding /Courier-Bold (type1/urw/courier/ucrb8a.pfb) ;.

@edocevoli
Copy link
Member

I agree that the behaviour should be consistent. We can force font embedding by specifying EmbedAllFonts-true. I will create a version epstopdf version which does so.

@edocevoli edocevoli reopened this Oct 17, 2019
@edocevoli edocevoli added this to the 2.9.7200 milestone Oct 17, 2019
@edocevoli
Copy link
Member

In a shared installation you could have multiple Fontmap files. You can check this as follows:

kpsewhich --all -progname=ghostscript -format=othertext Fontmap

@ivankokan
Copy link
Contributor Author

ivankokan commented Oct 18, 2019

In a shared installation you could have multiple Fontmap files. You can check this as follows:

kpsewhich --all -progname=ghostscript -format=othertext Fontmap

Here they are:

  • output from "only for me"
C:/Users/user/AppData/Local/Programs/MiKTeX 2.9/ghostscript/base/Fontmap
  • output from for "all users"
C:/Program Files/MiKTeX 2.9/ghostscript/base/Fontmap

...both having d00a51b7aa9271f8eb4843ef94aa49f5 MD5 hash.

Round 1

I suspected that Windows' Courier fonts are the root cause. After deleting them on VMs having MiKTeX installed in two different ways (https://www.wikihow.com/Delete-Protected-System-Fonts-in-Windows-7), and running

epstopdf --gsopt="-dPDFSETTINGS=/prepress" dummy.eps

again, I got the same subset prefixes as before (HSTUIH and UVAYIG) and the same different outputs (pixel-wise). From now on, my Win10 VMs do not have any system Courier fonts.

Round 2

I tried adding -dNOPLATFONTS and -dNONATIVEFONTMAP as well. I got some other subset prefixes but the same different outputs (pixel-wise).

Round 3

Motivated by "ucrb8a.pfb or pcrb8a.pfb" (#386 (comment)), now I tried deleting ucrb8a.pfb, ucrb8a.ttf and ucrb8a.afm, one by one, on both installations (making backup for possible later actions :)):

  1. without ucrb8a.pfb
  • output from "only for me": still HSTUIH, still the same
  • output from for "all users": MNTHDF+Courier-Bold, but opening the file I see the font is not Courier at all (probably Arial or something else)
    image

Conclusion: installation for "all users" definitely uses ucrb8a.pfb (as it should, and it does not fall back to .ttf or .afm), while the "only for me" does not use ucrb8a.pfb.

  1. without ucrb8a.pfb and ucrb8a.ttf
  • output from "only for me": still HSTUIH, still the same
  1. without ucrb8a.pfb, ucrb8a.ttf and ucrb8a.afm
  • output from "only for me": still HSTUIH, still the same
  1. Could it be that "only for me" installation uses some pcrb8a.*?
    Tests say "no".

I cannot find any other Courier resource. Could it be that it is available in mgs's DLL file? 😕

@ivankokan
Copy link
Contributor Author

Renaming all files (mostly *Fontmap*.*) that contain /Courier in C:/Users/user/AppData/Local/Programs/MiKTeX 2.9/ghostscript/base did not change/break anything.

Renaming some additional files that contain /Courier in C:/Users/user/AppData did not change/break anything.

@ivankokan
Copy link
Contributor Author

ivankokan commented Oct 19, 2019

I just set up two new Win10 32-bit VMs with MiKTeX installed in two different ways:

  1. "only for me"
  2. for "all users".

Upon installations, some updates were available - including miktex-epstopdf-bin-2.9 (Oct 17). I installed them, refreshed file name database and font map files (on both systems).

Testing epstopdf dummy.eps

  1. fonts are embedded, subset prefix BNFBCS
  2. fonts are embedded, subset prefix OIIVSG

=> 5e71e72, d43e6a7 ✔️

However, one can find that two different font resources were used:

  1. ?
  2. ucrb8a.pfb.

Renaming ucrb8a.pfb on both systems proved it. ✔️

I left them renamed.

More logs from 1.:

C:\Users\me\Documents>epstopdf --gsopt="-dNOFONTMAP" dummy.eps
Error: /invalidfont in /findfont
Operand stack:
   Courier-Oblique
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   2015   1   3   %oparray_pop   2014   1   3   %oparray_pop   --nostringval--   1998   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1967   1   3   %oparray_pop
Dictionary stack:
   --dict:973/1684(ro)(G)--   --dict:0/20(G)--   --dict:123/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
MiKTeX GPL Ghostscript 9.25: Unrecoverable error, exit code 1

Sorry, but "MiKTeX EPS-to-PDF Converter" did not succeed.

The log file hopefully contains the information to get MiKTeX going again:

  C:\Users\me\AppData\Local\MiKTeX\2.9\miktex\log\epstopdf.log

C:\Users\me\Documents>kpsewhich --all -progname=ghostscript -format=othertext Fontmap
C:/Users/me/AppData/Local/Programs/MiKTeX 2.9/ghostscript/base/Fontmap

C:\Users\me\Documents>mgs --help
MiKTeX GPL Ghostscript 9.25 (2018-09-13)
Copyright (C) 2018 Artifex Software, Inc.  All rights reserved.
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
 -dNOPAUSE           no pause after page   | -q       `quiet', fewer messages
 -g<width>x<height>  page size in pixels   | -r<res>  pixels/inch resolution
 -sDEVICE=<devname>  select device         | -dBATCH  exit after last file
 -sOutputFile=<file> select output file: - for stdout, |command for pipe,
                                         embed %d or %ld for page #
Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PostScriptLevel3 PDF
Default output device: display
Available devices:
   bbox bit bitcmyk bitrgb bitrgbtags bj10e bj200 bjc600 bjc800 bmp16 bmp16m
   bmp256 bmp32b bmpgray bmpmono bmpsep1 bmpsep8 cdeskjet cdj550 cdjcolor
   cdjmono declj250 deskjet devicen display djet500 djet500c eps2write
   eps9high eps9mid epson epsonc fpng gprf ibmpro ijs ink_cov inkcov
   jetp3852 jpeg jpegcmyk jpeggray laserjet lbp8 lj250 ljet2p ljet3 ljet3d
   ljet4 ljet4d ljetplus m8510 mswinpr2 necp6 nullpage pam pamcmyk32
   pamcmyk4 pbm pbmraw pclm pcx16 pcx24b pcx256 pcxcmyk pcxgray pcxmono
   pdfimage24 pdfimage32 pdfimage8 pdfwrite pgm pgmraw pgnm pgnmraw pj pjxl
   pjxl300 pkmraw plan planc plang plank planm planr plib plibc plibg plibk
   plibm png16 png16m png256 pngalpha pnggray pngmono pngmonod pnm pnmcmyk
   pnmraw ppm ppmraw ps2write psdcmyk psdcmykog psdrgb pxlcolor pxlmono
   r4081 spotcmyk st800 stcolor t4693d2 t4693d4 t4693d8 tek4696 tiff12nc
   tiff24nc tiff32nc tiff48nc tiff64nc tiffcrle tiffg3 tiffg32d tiffg4
   tiffgray tifflzw tiffpack tiffscaled tiffscaled24 tiffscaled32
   tiffscaled4 tiffscaled8 tiffsep tiffsep1 txtwrite uniprint xpswrite
Search path:
   %rom%Resource/Init/ ; %rom%lib/ ; c:/gs/gs9.25/Resource/Init ;
   c:/gs/gs9.25/lib ; c:/gs/gs9.25/Resource/Font ; c:/gs/fonts
Initialization files are compiled into the executable.
For more information, see c:/gs/gs9.25/doc/Use.htm.
Please report bugs to bugs.ghostscript.com.

@edocevoli
Copy link
Member

edocevoli commented Oct 19, 2019

Please note: mgs.exe must be called (directly/indirectly) by a MiKTeX executable so that MIKTEX_GS_LIB is set. You can use the Terminal icon in MiKTeX Console to start a command window and the run mgs.exe --help.

@ivankokan
Copy link
Contributor Author

Please note: mgs.exe must be called (directly/indirectly) by a MiKTeX executable so that MIKTEX_GS_LIB is set. You can use the Terminal icon in MiKTeX Console to start a command window and the run mgs.exe --help.

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\Windows\system32>echo MiKTeX Console \ Terminal
MiKTeX Console \ Terminal

C:\Windows\system32>cd C:\Users\me\Documents

C:\Users\me\Documents>echo %MIKTEX_GS_LIB%
C:\Program Files\MiKTeX 2.9\ghostscript\base;C:\Users\me\AppData\Local\Programs\MiKTeX 2.9\ghostscript\base;C:\Program Files\MiKTeX 2.9\fonts;C:\Users\me\AppData\Local\Programs\MiKTeX 2.9\fonts

C:\Users\me\Documents>cd "C:\Program Files\MiKTeX 2.9\ghostscript\base"
The system cannot find the path specified.

C:\Users\me\Documents>cd "C:\Users\me\AppData\Local\Programs\MiKTeX 2.9\ghostscript\base"

C:\Users\me\AppData\Local\Programs\MiKTeX 2.9\ghostscript\base>cd "C:\Program Files\MiKTeX 2.9\fonts"
The system cannot find the path specified.

C:\Users\me\AppData\Local\Programs\MiKTeX 2.9\ghostscript\base>cd "C:\Users\me\AppData\Local\Programs\MiKTeX 2.9\fonts"

C:\Users\me\AppData\Local\Programs\MiKTeX 2.9\fonts>mgs --help
MiKTeX GPL Ghostscript 9.25 (2018-09-13)
Copyright (C) 2018 Artifex Software, Inc.  All rights reserved.
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
 -dNOPAUSE           no pause after page   | -q       `quiet', fewer messages
 -g<width>x<height>  page size in pixels   | -r<res>  pixels/inch resolution
 -sDEVICE=<devname>  select device         | -dBATCH  exit after last file
 -sOutputFile=<file> select output file: - for stdout, |command for pipe,
                                         embed %d or %ld for page #
Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PostScriptLevel3 PDF
Default output device: display
Available devices:
   bbox bit bitcmyk bitrgb bitrgbtags bj10e bj200 bjc600 bjc800 bmp16 bmp16m
   bmp256 bmp32b bmpgray bmpmono bmpsep1 bmpsep8 cdeskjet cdj550 cdjcolor
   cdjmono declj250 deskjet devicen display djet500 djet500c eps2write
   eps9high eps9mid epson epsonc fpng gprf ibmpro ijs ink_cov inkcov
   jetp3852 jpeg jpegcmyk jpeggray laserjet lbp8 lj250 ljet2p ljet3 ljet3d
   ljet4 ljet4d ljetplus m8510 mswinpr2 necp6 nullpage pam pamcmyk32
   pamcmyk4 pbm pbmraw pclm pcx16 pcx24b pcx256 pcxcmyk pcxgray pcxmono
   pdfimage24 pdfimage32 pdfimage8 pdfwrite pgm pgmraw pgnm pgnmraw pj pjxl
   pjxl300 pkmraw plan planc plang plank planm planr plib plibc plibg plibk
   plibm png16 png16m png256 pngalpha pnggray pngmono pngmonod pnm pnmcmyk
   pnmraw ppm ppmraw ps2write psdcmyk psdcmykog psdrgb pxlcolor pxlmono
   r4081 spotcmyk st800 stcolor t4693d2 t4693d4 t4693d8 tek4696 tiff12nc
   tiff24nc tiff32nc tiff48nc tiff64nc tiffcrle tiffg3 tiffg32d tiffg4
   tiffgray tifflzw tiffpack tiffscaled tiffscaled24 tiffscaled32
   tiffscaled4 tiffscaled8 tiffsep tiffsep1 txtwrite uniprint xpswrite
Search path:
   C:\Program Files\MiKTeX 2.9\ghostscript\base ;
   C:\Users\me\AppData\Local\Programs\MiKTeX 2.9\ghostscript\base ;
   C:\Program Files\MiKTeX 2.9\fonts ;
   C:\Users\me\AppData\Local\Programs\MiKTeX 2.9\fonts ;
   %rom%Resource/Init/ ; %rom%lib/ ; c:/gs/gs9.25/Resource/Init ;
   c:/gs/gs9.25/lib ; c:/gs/gs9.25/Resource/Font ; c:/gs/fonts
Initialization files are compiled into the executable.
For more information, see c:/gs/gs9.25/doc/Use.htm.
Please report bugs to bugs.ghostscript.com.

C:\Users\me\AppData\Local\Programs\MiKTeX 2.9\fonts>cd C:\Users\me\Documents

C:\Users\me\Documents>epstopdf dummy.eps

C:\Users\me\Documents>pdffonts dummy.pdf
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
BNFBCS+Courier-Bold                  Type 1C           WinAnsi          yes yes no       8  0

Still the same within PDF, clearly different font than with ucrb8a.pfb.

@edocevoli
Copy link
Member

I think the issue has been fixed with the latest updates.

@ivankokan
Copy link
Contributor Author

I think the issue has been fixed with the latest updates.

Looking forward to testing. :)
So, you suspect that non-existing paths make a mess? Where does the Courier font resource come from in the private environment (note that I removed/renamed almost everything)?

@edocevoli
Copy link
Member

Yes, I assume so. The per-user installation has non-existing directories in the search path. Maybe Ghostscript 9.25 has a problem with it.

@ivankokan
Copy link
Contributor Author

ivankokan commented Oct 22, 2019

Hi. I am glad to verify that the recent commits resolved all issues!

Tests on all four combinations (32-bit / 64-bit x "only for me" / for "all users") yields:

C:\Users\user\Documents>epstopdf dummy.eps

C:\Users\user\Documents>pdffonts dummy.pdf
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
OIIVSG+Courier-Bold                  Type 1C           WinAnsi          yes yes no       8  0

C:\Users\user\Documents>dir
 Volume in drive C has no label.
 Volume Serial Number is C08F-0016

 Directory of C:\Users\user\Documents

10/21/2019  09:10 AM    <DIR>          .
10/21/2019  09:10 AM    <DIR>          ..
10/21/2019  08:59 AM            86,875 dummy.eps
10/21/2019  09:10 AM            34,550 dummy.pdf
               2 File(s)        121,425 bytes
               2 Dir(s)  43,602,800,640 bytes free
  • Binary comparisons of all four dummy.pdf's show only the difference in PDF metadata. ✔️
  • Outputs are visually equal. ✔️
  • Conversion without ucrb8a.pfb proves it has been used as a resource. ✔️

Summary

This was the original behavior of epstopdf:

  • "only for me": standard fonts were embedded without explicit instruction (not sure about the non-standard ones), we did not find out which font resource has been used - it was definitely not the one from courier package but probably Windows system font or some precompiled resource available in DLL.
  • for "all users": standard fonts were not embedded and this was actually expected.

What has changed?

  • Now all fonts are explicitly embedded (including standard ones contributed by URW++, for which we have proved they are really used as a resource).

Remaining

Thank you for all the effort! It was a long journey...

@ivankokan
Copy link
Contributor Author

ivankokan commented Oct 23, 2019

Hi. I tested the behavior in Ubuntu on both installation types with the latest updates. PDF outputs are equal and both have embedded Courier-Bold (subset prefix TXVUDF), but the font seems to be the same as before in "only for me" installation in Win10.

  • Package courier is installed (~/.miktex/texmfs/install/fonts/type1/urw/courier/ucrb8a.pfb).
  • PDF Producer is GPL Ghostscript 9.26 (I guess there is no mgs for Linux systems but regular Ghostscript is used; MiKTeX Console Terminal does not see mgs).
  • epstopdf -n dummy.eps: gs -q -sDEVICE=pdfwrite -dSAFER -dAutoRotatePages=/None -sOutputFile=./dummy.pdf - -c quit
  • Running epstopdf with all arguments added in recent commits produce PDF with embedded font visually equal to the one without explicit arguments.

I guess the root cause is that regular Ghostscript does not see/use paths in MIKTEX_GS_LIB (MIKTEX_GS_LIB does not exist on non-Windows systems https://github.com/MiKTeX/miktex/blob/master/Libraries/MiKTeX/Core/Session/init.cpp#L922).

Would it be possible to make epstopdf behave consistently regardless of the underlying OS:

  1. explicitly embed fonts (including standard ones)
  2. use URW++ fonts available in MiKTeX?

@edocevoli
Copy link
Member

  • MIKTEX_GS_LIB is only set on a Windows system
  • MiKTeX for Linux uses system Ghostscript
  1. explicitly embed fonts (including standard ones)

This will be available with the next .deb release

@ivankokan
Copy link
Contributor Author

ivankokan commented Oct 23, 2019

Ah, sorry. I should have recognized that fix is not available yet since there are no new arguments here:

  • epstopdf -n dummy.eps: gs -q -sDEVICE=pdfwrite -dSAFER -dAutoRotatePages=/None -sOutputFile=./dummy.pdf - -c quit

How about

  1. use URW++ fonts available in MiKTeX?
  • MIKTEX_GS_LIB is only set on a Windows system

Can GS_LIB be modified within epstopdf invocation (locally) in order to use URW++ fonts (in order to be consistent, i.e. platform-independent)?

@ivankokan
Copy link
Contributor Author

ivankokan commented Oct 28, 2019

Hi. I tried this:

GS_LIB=/home/me/.miktex/texmfs/install/ghostscript/base/:/home/me/.miktex/texmfs/install/fonts/:$GS_LIB epstopdf --gsopt="-dPDFSETTINGS=/prepress" dummy.eps

and got the wanted font from courier package.

It seems that setting GS_LIB variable locally for epstopdf invocation would do.

@ivankokan
Copy link
Contributor Author

@edocevoli Looks like the updates arrived to Linux systems?
image

Everything works as expected and GS_LIB contains two paths as expected.

However, I noticed that epstopdf embeds the font even if I uninstall courier package. I could not find obvious differences between two outputs (as before while we had embedding issues), except the subset prefixes - suggesting that different font resources were used.

Standalone Ghostscript 9.26 is available on the testing Ubuntu system, I got no error message like in #429. It probably used its own resources after I uninstalled courier - I will try to confirm that.

@ivankokan
Copy link
Contributor Author

ivankokan commented Dec 25, 2019

Standalone Ghostscript 9.26 is available on the testing Ubuntu system, I got no error message like in #429. It probably used its own resources after I uninstalled courier - I will try to confirm that.

I tried to trace which font resources were used - no success. It could be that URW++ fonts are pre-compiled and included in the Ghostscript executable (https://www.ghostscript.com/doc/9.26/Fonts.htm#Free_fonts). On the other hand, courier package (and others listed in MiKTeX/miktex-packaging#112) contains URW++ fonts as well, so (obvious) visual difference cannot be found.

I leave this information here for someone else keen to investigate, or for the future occasions if some other issues happen.

@uwezi
Copy link

uwezi commented Mar 20, 2020

I am in an urgent need to get some document compiled on a brand new installation of MikTeX on a new computer - and sure with Murphy behind my back, exactly this problem kicked me in the behind and I do not get wiser from the long discussion above...

@u-fischer
Copy link

@uwezi well you are not giving any details and it is not clear if you really have "exactly" this problem. If you installed a basic miktex: install more font packages, in the basic miktex something seems to be missing.

@ivankokan
Copy link
Contributor Author

ivankokan commented Mar 20, 2020

@uwezi If it is about missing fonts, install all font resources. Instructions at the bottom of: MiKTeX/miktex-packaging#112.

Also make sure you have MiKTeX updated.

@uwezi
Copy link

uwezi commented Mar 20, 2020

Thank you very much for the quick replies - I helped myself today by converting the problematic eps-files to png-files.

Of course I know that my "bug report" was not very helpful, but I was in an extreme hurry and it's of course always annoying if something breaks which has always worked flawless before. Tracing back the problem to a possible issue with fonts inside eps-files was tough enough, especially since I already have now 3 different GS-installations on this computer, just to learn that MikTeX uses its own installation number 4...

Well, I chose the 512 GByte SSD on this new computer for a reason. Downloading 1 GByte of fonts doesn't really hurt, let's see
Clip0001

Times have changed since my first TeX-installation from something like 30 floppy disks...

Ok, from tomorrow I can include my eps-files directly again!
Clip0002

Once again, thanks for the quick reply and help!

@ivankokan
Copy link
Contributor Author

@uwezi So, installing missing/all fonts resolved the issues with epstopdf?

@uwezi
Copy link

uwezi commented Mar 21, 2020

@uwezi So, installing missing/all fonts resolved the issues with epstopdf?

Yes, the culprit were eps-figures which I had created with Xcircuit like the one included in the following zip-file.

20200321_eps_fig.zip

More details:

  • Windows 10 64bit
  • latest MilkTeX as of 2020-03-20, admin-installation
  • includegraphics from graphicx
  • XeLaTeX
  • document in UTF-8

Absolute MWE:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=.45\textwidth]{filter_rc_lp_u.eps}
\end{document}

If I look into the eps-file I can only see that it uses times-italic and helvetica. After re-removing these two packages now from MikTeX the document still compiles without problem. But I am too lazy to go back and try to find out which of the 246 additional packages helped...

@ivankokan
Copy link
Contributor Author

@uwezi So, installing missing/all fonts resolved the issues with epstopdf?

Yes, the culprit were eps-figures which I had created with Xcircuit like the one included in the following zip-file.

20200321_eps_fig.zip

More details:

  • Windows 10 64bit
  • latest MilkTeX as of 2020-03-20, admin-installation
  • includegraphics from graphicx
  • XeLaTeX
  • document in UTF-8

Absolute MWE:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=.45\textwidth]{filter_rc_lp_u.eps}
\end{document}

If I look into the eps-file I can only see that it uses times-italic and helvetica. After re-removing these two packages now from MikTeX the document still compiles without problem. But I am too lazy to go back and try to find out which of the 246 additional packages helped...

Looking inside, I found that /Helvetica and /Times-Italic fonts are needed.

Associations in Fontmap.aliases:

/Helvetica			/NimbusSanL-Regu	;
/Times-Italic			/NimbusRomNo9L-ReguItal	;

Associations in Fontmap.MiKTeX:

/NimbusSanL-Regu (type1/urw/helvetic/uhvr8a-105.pfb) ;
/NimbusSanL-Regu (type1/urw/helvetic/uhvr8a.pfb) ;
/NimbusRomNo9L-ReguItal (type1/urw/times/utmri8a.pfb) ;

So, needed packages are helvetic and times.

@uwezi
Copy link

uwezi commented Mar 21, 2020

So, needed packages are helvetic and times.

...then I wonder why it still works now if I uninstall these packages again - or well I actually don't care right now. Let me know if I can contribute with some more tests on my system.

@ivankokan
Copy link
Contributor Author

ivankokan commented Mar 21, 2020

So, needed packages are helvetic and times.

...then I wonder why it still works now if I uninstall these packages again - or well I actually don't care right now. Let me know if I can contribute with some more tests on my system.

  • It could be that previously generated PDF files are still present. Delete them before each test.
  • It could be that you have system-wide MiKTeX installation, uninstalled packages in one mode while the other one is being used for compiling.

@uwezi
Copy link

uwezi commented Mar 22, 2020

* It could be that previously generated PDF files are still present. Delete them before each test.
* It could be that you have system-wide MiKTeX installation, uninstalled packages in one mode while the other one is being used for compiling.

neither nor... I now retested the whole thing and found out that I must have missed something yesterday...

When I have either times or helvetica or both installed, everything works fine.
Only if I remove both times and helvetica from the system I do get the error message and no output from XeLaTeX.

(I was sure I had tested the complete uninstall yesterday, but somehow I must have messed up my experiment.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants