% !TEX TS-program = xelatex 
% !TEX encoding = UTF-8 Unicode 


\documentclass[12pt, oneside]{article}
\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                   % ... or a4paper or a5paper or ... 
%\geometry{landscape}                % Activate for for rotated page geometry
\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}
\usepackage{url}
\urlstyle{same}
\usepackage{amssymb}
\usepackage{epstopdf}
\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}
\usepackage[colorlinks=true, pdfstartview=FitV, linkcolor=blue, 
            citecolor=blue, urlcolor=blue]{hyperref}
            
%\usepackage{fontspec,xltxtra,xunicode} 
%\defaultfontfeatures{Mapping=tex-text} 
%\setromanfont{Hoefler Text} 
%\setromanfont{Optima}
%\setromanfont{Baskerville}
%\setsansfont[Scale=MatchLowercase] {Gill Sans} 
%\setmonofont[Scale=MatchLowercase] {Andale Mono} 

            
\title{Ghostscript 9.55}
%\author{Richard Koch \\ with extensive help from Bruno Voisin}
\date{\today}                                           % Activate to display a given date or no date

\begin{document}
\maketitle

\section{Introduction}

The Ghostscript package in MacTeX-2022 was extensively revised  to add support for Chinese, Japanese, and Korean fonts. We were initially contacted by Munehiro Yamamoto, who offered solutions to Ghostscript problems with Japanese typesetting. Extensive work was done by Kuroki Yusuke, Bruno Voisin, and Norbert Preining to perfect these solutions for the release of the MacTeX installation of Ghostscript 9.16 through 9.55.

Ghostscript is an open source interpreter for Adobe's Postscript and PDF page description languages. This software is optional for many TeX users, since modern engines
like PdfTeX, XeTeX, and LuaTeX can directly output pdf files.

Before these engines were developed, it was common to typeset by calling TeX or LaTeX to convert a source document into a dvi file,
and then calling dvips to convert this dvi file into a postscript file,
and then calling Ghostscript to convert this postscript file into a pdf file. This procedure is still recommended when a project contains many eps illustrations, or when the pstricks package is used to directly insert postscript into the source file.

Ghostscript is also used for graphic conversion to and from eps format,
by the tex4ht engine to convert TeX documents into html, and by the X11 windowing system to rasterize eps illustrations.

\section{Fonts in Ghostscript}

Ghostscript comes with the ``base 35'' fonts required for Postscript and the ``base 14'' fonts required for PDF. These include Times, Helvetica, Courier, etc. In recent years, these fonts were compiled directly into the source and invisible to the outside world.

This year Ghostscript was compiled using the sequence
\begin{verbatim}
     ./configure --disable-compile-inits
     make
     sudo make install
\end{verbatim}

The extra flag for the configure stage makes the Ghostscript fonts visible in
\path{/usr/local/share/ghostscript/9.55/Resource/Fonts}.

It is possible to reconfigure Ghostscript without recompiling it by adding extra files
to the Resource directory just mentioned. In particular, more fonts and links to fonts can be added to make them known to the interpreter. For the straightforward TeX applications mentioned earlier when Ghostscript converts postscript to pdf,  additional fonts are not required because they are embedded in the postscript file being converted.

There are a small number of cases, mostly involving text in illustrations, where Ghostscript needs access to the text fonts. In 2012, Bruno Voisin reconfigured our Ghostscript distribution to provide links to the most common pfb font files in TeX Live.   

\section{CJK Fonts}

The situation changes dramatically in China, Japan, and Korea due to the large number of characters in these languages. It is possible to typeset  these languages with XeTeX or
LuaTeX. But a different approach evolved in these countries historically, with typesetting done using
one of the sequences
\begin{verbatim}
     TeX + dvips + ps2pdf
     TeX + dvipdfmx
\end{verbatim}

In these sequences, the standard TeX engine is often replaced by special versions of the program.

(The program dvipdfmx is related to the program xdvipdfmx used in the final step of XeTeX typesetting, but the  considerations below only apply to dvipdfmx.)

As used in the Far East, the first of these approaches requires Ghostscript. Moreover, the
fonts are not embedded in the file processed by Ghostscript, so
Ghostscript needs direct access to the fonts being used, which can be fonts installed in the user's operating system as well as  TeX Live fonts.

In 2015, Munehiro Yamamoto contacted us to suggest this support, and then very extensive work was done by Bruno Voisin, Kuroki Yusuke, and Norbert Preining to provide the support. 

Afterward, Norbert Preining wrote a script to search a user's computer and configure Ghostscript to support available CJK fonts. That script supports Chinese, Japanese, and Korean and is now part of TeX Live. Users in these countries are encouraged to run it.  To see the current state of the script, go to https://github.com/texjporg/cjk-gs-support. To run the script in TeX Live, open Terminal in /Applications/Utilities, type the following lines, pushing RETURN after each one, and type your password when it is requested. The first two lines below should be written on one line.
\begin{verbatim}
  sudo tlmgr --repository https://contrib.texlive.info/current 
         install cjk-gs-integrate-macos
  sudo cjk-gs-integrate-macos
\end{verbatim}

To get documentation about this script, type
\begin{verbatim}
  texdoc cjk-gs-integrate
\end{verbatim}

 

%\section{More Information for Users in Japan}
%
%The additions give access to the following font sets of the jfontmaps package (as documented in
%\path{ /Library/TeX/Documentation/texmf-doc/fonts/jfontmaps/README}, opened in the Terminal window via ``texdoc jfontmaps'') :
%\begin{verbatim}
%	nofonts
%	hiragino
%	hiragino-pron
%	morisawa (substituted by hiragino-pron)
%	ipa
%	ipaex
%	yu-osx
%\end{verbatim}
%
%The yu-osx set has been reported to exhibit problems depending on the Ghostscript and macOS versions.
%
%Users can switch between sets for both dvips and dvipdfmx by using the kanji-config-updmap tool, for example via
%\begin{verbatim}
%	sudo kanji-config-updmap-sys hiragino-pron
%\end{verbatim}
%for a system-wide setup, and
%\begin{verbatim}
%	kanji-config-updmap hiragino-pron
%\end{verbatim}
%for a user-specific setup.
%
%For the setup to be functional for dvipdfmx, the user needs to create symlinks as explained in the README file. These symlinks are to the Japanese macOS fonts and are placed inside \path{/Library/TeX/Local/fonts/opentype} for a system-wide setup and \path{~/Library/texmf/fonts/opentype} for a user-specific setup.

%\section{Some Words from Bruno Voisin}
%
%After finishing this project, Bruno wrote a fascinating review of the design
%decisions he made. I don't want Bruno's report to be lost, so I'm adding it to this document
%despite the technical nature of his material. Several times, Bruno writes ``Dick and I'' but
%that means he gave me instructions and I followed them.
%
%\section{Bruno's Document}
%
%Hi All,
%
%Now that Ghostscript for MacTeX-2017 is almost out of the door, there's one last point that I'd like to bring out before release.
%
%In order to get Japanese font support to work, Dick and I added the --disable-compile-inits configure option. That's pretty standard (MacPorts, Fink and Homebrew use it, I think), and the Ghostscript documentation seems to imply there is no other way (ie, when saying ``build Ghostscript to use disk based resources'' in section 8.4 of Use.htm, see \url{http://www.ghostscript.com/doc/9.16/Use.htm} --CIDFontSubstitution.
%
%The rest is modification of some config files in \path{Resource/Init}, and addition of a number of font "snippets" and symlinks in \path{Resource/CIDFont} and \path{Resource/Font}, in the same way (though much more involved) as done since 2012 to ensure support of TeX Live's CMR fonts.
%
%Not all TeX-related Ghostscript distributions do the same: on Windows a wrapper script is used, modifying the Ghostscript environment variables at run time; other distributions modify the Ghostscript default search path at compile time, to include the TeX Live font directories and the OS font directories.
%
%The latter option could have been adopted on the Mac, using this time the --with-fontpath configure option to include in the font search path
%\begin{verbatim}
%     /System/Library/Fonts
%     /Library/Fonts
%
%     /Library/TeX/Root/texmf-dist/fonts/opentype
%     /Library/TeX/Root/texmf-dist/fonts/truetype
%     /Library/TeX/Root/texmf-dist/fonts/type1
%\end{verbatim}
%
%Dick and I did not go this route, and preferred leaving the search path alone while adding symlinks to each individual font.
%
%Here are the pros and cons of the path-modifying approach as I see them.
%
%Regarding the pros, the changes would be:
%
%- For \path{Resource/CIDFont}: none. Symlinks would still need to be created. The font search path is not used when looking for CID fonts, Ghostscript only looks into \path{Resource/CIDFont} whatever the search path. This is said explicitly at the end of section 8.3 of Use.htm, see \url{http://www.ghostscript.com/doc/9.16/Use.htm} --CIDFonts.
%
%- For \path{Resource/Font}: the font snippets like FutoGoB101-Bold-78-EUC-H would still need to be created, but the symlinks to the font files (like cmr10.pfb and ipam.ttf from TeX Live) would no longer be necessary. However,
%
%- For \path{Resource/Init}: this also means that in cidfmap.MacTeX we would have to use absolute paths instead of relative ones, so that for example
%\begin{verbatim}
% /Path (ipam.ttf) >> ; % TeX Live
%\end{verbatim}
%would need to be replaced by
%\begin{verbatim}
% /Path (/Library/TeX/Root/texmf-dist/fonts/truetype/public \\
% 	/ipaex/ipag.ttf) >> ; % TeX Live
%\end{verbatim}
%So the only actual benefit would be fewer symlinks to create, with the drawback that cidfmap would become more complicated.
%
%There would be several other issues to consider, on the cons side:
%
%- Security implications: adding the OS font directories to the search path would open the possibility that malicious files could be installed there to use Ghostscript as a backdoor, despite the -dSAFER default. That's not even speaking of the event that not only the above directories but also \path{~/Library/Fonts}, \path{/Users/Shared/Library/Fonts} and \path{/Network/Library/Fonts} were added to the path.
%
%- Compatibility with other Ghostscript distros: not all change the default search path.
%
%- Compatibility with Norbert's script cjk-gs-integrate.pl \url{http://www.preining.info/blog/software-projects/cjk-fonts-ghostscript/}: this could break the script. Given this script creates all the required symlinks automatically, taking all the tedious job out of the user's hands, why bother about a risky procedure whose only benefit would be to make the symlinks superfluous?
%
%- Recursive directory searching: I don't know whether Ghostscript searches directories recursively. If not, each relevant subdirectory of \path{texmf-dist/fonts/{opentype,truetype,type1}} would have to be included in the path, which would mean very little benefit if any compared with the symlinks.
%
%- Path specification syntax: to be honest, I've no idea about the syntax to be used for the paths in --with-fontpath.
%
%For all these reasons, I think our approach is more satisfactory. But I may have missed other aspects, so if you disagree, please speak up.
%
%Bruno


\end{document}
  