From 03e895528bdcda911fdf41b8e1da264aef4516d5 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Mon, 29 Sep 2008 00:11:18 +0000
Subject: fontinst 1.929 (28sep08)

git-svn-id: svn://tug.org/texlive/trunk@10781 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/source/fontinst/base/ficonv.dtx | 149 +++++++++++++++++++++-
 1 file changed, 147 insertions(+), 2 deletions(-)

(limited to 'Master/texmf-dist/source/fontinst/base/ficonv.dtx')

diff --git a/Master/texmf-dist/source/fontinst/base/ficonv.dtx b/Master/texmf-dist/source/fontinst/base/ficonv.dtx
index e1fee953b8c..8af04ffc216 100644
--- a/Master/texmf-dist/source/fontinst/base/ficonv.dtx
+++ b/Master/texmf-dist/source/fontinst/base/ficonv.dtx
@@ -1,4 +1,4 @@
-% \CheckSum{2221}
+% \CheckSum{2337}
 % \iffalse meta-comment
 %
 % Copyright 1993, 1994, 1995, 1996 Alan Jeffrey,
@@ -301,9 +301,152 @@
       \out_line{\percent_char\four_spaces #1~=~"See~file~#2",}
    \fi
 }
+%    \end{macrocode}
+% \end{macro}
+%
+% 
+% \subsection{Converting an ETX file to CMAP file}
+% \changes{1.928}{2004/11/28}{ETX to CMAP converter added. (LH)}
+% 
+% \DescribeMacro{\etxtocmap}
+% The command
+% \begin{quote}
+%    |\etxtocmap|\marg{etxfile}\marg{cmapfile}
+% \end{quote}
+% reads \meta{etxfile}|.etx| and generates a ToUnicode CMap file 
+% \meta{cmapfile}|.cmap| that maps slots to Unicode strings as 
+% specified by the \meta{etxfile}.
+% 
+% \begin{macro}{\write_cmap_body}
+%    The |\write_cmap_body| command writes the actual CMap 
+%    data\footnote{As opposed to silly stuff that is requested by the 
+%    file format specification but probably isn't of any use for 
+%    anything, which is written by \cs{ref_to_sourcefile}.} to the 
+%    current output file. The syntax is
+%    \begin{quote}
+%      |\write_cmap_body|\marg{etxfile}
+%    \end{quote}
+%    
+%    More precisely, what this command writes is the codespace range 
+%    specification and the mappings. The latter are all encoded using 
+%    \texttt{bfchar} operators. 
+%     \begin{macrocode}
+\def\write_cmap_body#1{
+   \out_line{1~begincodespacerange~<00>~<FF>~endcodespacerange}
+   \let\do_slot=\_a_true
+   \def\Unicode##1##2{\cmap_charseq{\cmap_codepoint{##1}{##2}}}
+   \let\charseq=\cmap_charseq
+   \inputetx{#1}
+}
+%    \end{macrocode}
+% \end{macro}
+% 
+% 
+% \begin{macro}{\cmap_codepoint}
+%   This is what |\Unicode| is inside a |\charseq|. It appends a 
+%   UTF-16BE character in hexadecimal notation (either four hex 
+%   digits for a character in the BMP, or eight hex digits for 
+%   a surrogate pair) to |\a_macro|, and also appends a space for 
+%   grouping the digits for easier reading.
+%   \changes{1.928}{2004/12/05}{Added \cs{uppercase} to ensure case 
+%     independence. (LH)}
+%    \begin{macrocode}
+\def\cmap_codepoint#1#2{
+   \uppercase{\a_count="#1\x_relax}
+   \ifnum "10000>\a_count
+      \format_hex\b_macro{\a_count}{4}
+      \edef\a_macro{\a_macro \b_macro \space}
+   \else
+      \advance \a_count -"10000
+      \d_count=\a_count
+      \divide \a_count "400
+      \b_count=\a_count
+      \multiply \b_count "400
+      \advance \d_count -\b_count
+      \advance \a_count "D800
+      \advance \d_count "DC00~
+      \format_hex\b_macro{\a_count}{4}
+      \format_hex\c_macro{\d_count}{4}
+      \edef\a_macro{\a_macro \b_macro \c_macro \space}
+   \fi
+}
+%    \end{macrocode}
+% \end{macro}
+% 
+% \begin{macro}{\cmap_charseq}
+%   This macro is what |\charseq| is when generating a CMap; all 
+%   writing of CMap entries is routed through it. Only the first 
+%   character equivalent of each slot should get written to file, so 
+%   the |_a_| switch is used for keeping track of whether this would be 
+%   the first.
+%   
+%    \begin{macrocode}
+\def\cmap_charseq#1{%
+   \if_a_
+      \bgroup
+         \let\Unicode=\cmap_codepoint
+         \let\a_macro=\empty_command
+         #1
+         \format_hex\b_macro{\slot_number}{2}
+         \out_line{1~beginbfchar~<\b_macro>~<~\a_macro>~endbfchar}
+      \egroup
+      \_a_false
+   \fi
+}
+%    \end{macrocode}
+% \end{macro}
+% 
+% 
+% 
+% 
+% \begin{macro}{\etxtocmap}
+%   The 
+%    \begin{macrocode}
+\def\etxtocmap#1#2{\begingroup
+   \inputetx{#1}
+   \open_out{#2.cmap}
+   \out_line{\percent_char !PS-Adobe-3.0~Resource-CMap}
+   \out_line{\percent_char\percent_char
+     DocumentNeededResources:~procset~CIDInit}
+   \out_line{\percent_char\percent_char
+     IncludeResource:~procset~CIDInit}
+%    \end{macrocode}
+%   Here comes the first problem: the CMap must have a name. If the ETX 
+%   file sets the string variable \texttt{cmapname} then that is used 
+%   as name, but otherwise |fontinst-|\meta{cmapfile} is used as name. 
+%   Note that this is different from the pattern in |\etxtoenc|, which 
+%   instead uses the \meta{etxname}.
+%    \begin{macrocode}
+   \setstr{cmapname}{fontinst-#2}
+   \out_line{\percent_char\percent_char
+     BeginResource:~CMap~\str{cmapname}}
+%    \end{macrocode}
+%   The next problem is whether one should bother with the quite 
+%   extensive version control junk that Adobe has specified. I prefer 
+%   not to, because it is very much geared towards using CMaps with 
+%   CIDFonts, which is not the case here.
+%   
+%   Thus it is time for the actual PS code.
+%    \begin{macrocode}
+   \out_line{/CIDInit~/ProcSet~findresource~begin}
+   \out_line{7~dict~begin}
+   \out_line{begincmap}
+   \out_line{/CMapName~/\str{cmapname}~def}
+   \out_line{/CMapType~2~def}
+   \write_cmap_body{#1}
+   \out_line{endcmap}
+   \out_line{CMapName~currentdict~/CMap~defineresource~pop}
+   \out_line{end}
+   \out_line{end}
+   \out_line{\percent_char\percent_char EndResource}
+   \out_line{\percent_char\percent_char EOF}
+   \close_out{ToUnicode~CMap}
+\endgroup}
 %</misc>
 %    \end{macrocode}
 % \end{macro}
+% 
+% 
 %
 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
@@ -1384,6 +1527,8 @@
 %   \changes{1.917}{2001/03/13}{Added resetting of 
 %      \cs{setsomething_global}---assignments made here must be 
 %      local. (LH)}
+%   \changes{1.929}{2005/02/05}{Corrected `\texttt{pltotf}' in 
+%      comment. (LH)}
 %    \begin{macrocode}
 \def\mtxtopl#1#2{{
    \let\setsomething_global=\x_relax
@@ -1398,7 +1543,7 @@
    \out_line{}
    \out_line{(COMMENT~This~file~can~be~turned~into~
       a~ligless~TeX~font~with)}
-   \out_line{(COMMENT~pltotfm~#2.pl~#2.tfm)}
+   \out_line{(COMMENT~pltotf~#2.pl~#2.tfm)}
    \out_line{}
    \out_line{(COMMENT~THIS~FILE~CAN~THEN~BE~DELETED.)}
    \out_line{}
-- 
cgit v1.2.3

