From 9574391f1c92725d497fa2a84962aee68b5cbf25 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Fri, 28 Aug 2009 17:52:47 +0000
Subject: fontinst 1.933 (24aug09)

git-svn-id: svn://tug.org/texlive/trunk@14924 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/source/fontinst/base/ficonv.dtx | 337 ++++++++++++++++++----
 1 file changed, 277 insertions(+), 60 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 8af04ffc216..4281142ea16 100644
--- a/Master/texmf-dist/source/fontinst/base/ficonv.dtx
+++ b/Master/texmf-dist/source/fontinst/base/ficonv.dtx
@@ -1,4 +1,4 @@
-% \CheckSum{2337}
+% \CheckSum{2502}
 % \iffalse meta-comment
 %
 % Copyright 1993, 1994, 1995, 1996 Alan Jeffrey,
@@ -47,10 +47,6 @@
 % reads \meta{encfile}|.enc| and writes the same information to 
 % \meta{etxfile}|.etx|, in a format \TeX{} can read more easily.
 %
-% Each |/|\meta{glyph} command is recorded in a macro |\o-|\meta{glyph}, 
-% which expands to a corresponding |\setslot|\marg{glyph} 
-% \textellipsis\ |\endslot| 
-% statement.
 %
 %    \begin{macrocode}
 %<*misc>
@@ -59,6 +55,12 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\enctoetx}
+%   For every |/|\meta{glyph} command, the command |\o-|\meta{glyph} 
+%   gets passed code which writes the corresponding 
+%   |\setslot|\marg{glyph} \textellipsis\ |\endslot| statement.
+%   Normally that constrol sequence is undefined, hence equivalent to 
+%   |\relax|, and thus the code gets executed. However |\o-.notdef| will 
+%   instead gobble this argument and set |missingslots| to true.
 %    \begin{macrocode}
 {
    \catcode`\/=\active
@@ -67,20 +69,10 @@
       \catcode`\/=\active
       \catcode`\]=\active
       \def/##1[{
+         \encname_to_etx ##1~{#1}{#2}
          \a_count=0
          \global\missingslotsfalse
-         \def/####1~{
-            \csname~o-####1\endcsname{
-               \ifmissingslots
-                  \out_line{\string\nextslot{\the\a_count}}
-               \fi
-               \global\missingslotsfalse
-               \out_line{\string\setslot{####1}}
-               \out_line{\string\endsetslot}
-               \out_line{}
-            }
-            \advance\a_count by 1
-         }
+         \let/=\encslot_to_etx
       }
       \def]~def{}
       \make_etx{#1}{#2}
@@ -88,9 +80,63 @@
 }
 %    \end{macrocode}
 % \end{macro}
+% 
+% \begin{macro}{\encname_to_etx}
+%   This macro recieves the encoding vector name, the ENC file name, 
+%   and the ETX file name when converting an ENC file to an ETX file. 
+%   The call syntax is
+%   \begin{quote}
+%     |\encname_to_etx|\meta{vectorname}\textvisiblespace
+%     \marg{enc}\marg{etx}
+%   \end{quote}
+%   (making the first argument space-delimited but the second 
+%   undelimited is a trick to gobble any space that may be present at 
+%   the end of that which the caller thinks is the vector name).
+%   
+%   The command outputs a |\declarepsencoding| command to the 
+%   generated ETX file.
+%   \changes{1.931}{2005/05/13}{Macro added, to support caching 
+%      original ENC names in autogenerated ETX files. (LH) 
+%      Thanks to Alexej Kryukov for the inspiration for this.}
+%    \begin{macrocode}
+\def\encname_to_etx#1~#2#3{
+   \out_line{\percent_char\space REMOVE~THE~FOLLOWING~LINE~IF~
+      THIS~FILE~IS~MODIFIED~OR~RENAMED.}
+   \out_line{\string\declarepsencoding{#3}{#1}{\string\download{#2.enc}}}
+   \out_line{}
+}
+%    \end{macrocode}
+% \end{macro}
+% 
+% \begin{macro}{\encslot_to_etx}
+%   This macro grabs everything up to the next space and writes a 
+%   |\setslot| entry with the grabbed material as glyph name. It is 
+%   used as the definition of |/| (active character) when parsing 
+%   elements of an encoding vector.
+%   \changes{1.931}{2005/05/13}{Macro added (separated from 
+%      \cs{enctoetx}). (LH)}
+%    \begin{macrocode}
+\def\encslot_to_etx#1~{
+   \csname o-#1\endcsname{
+      \ifmissingslots
+         \out_line{\string\nextslot{\the\a_count}}
+      \fi
+      \global\missingslotsfalse
+      \out_line{\string\setslot{#1}}
+      \out_line{\string\endsetslot}
+      \out_line{}
+   }
+   \advance\a_count by 1
+}
+%    \end{macrocode}
+% \end{macro}
 %
-% |\make_etx| finishes the job of |\enctoetx|.
-%
+% \begin{macro}{\make_etx}
+%   |\make_etx| does the stuff that |\enctoetx| does not; it handles 
+%   writing the preamble and postamble of the ETX file, but also does 
+%   the actual |\input| of the ENC file to convert.
+%   \changes{1.931}{2005/05/13}{Now requiring a particular 
+%      \package{fontdoc} version. (LH)}
 %    \begin{macrocode}
 \def\make_etx#1#2{
    \open_out{\temp_prefix#2.etx}
@@ -108,13 +154,13 @@
    \out_line{\string\relax}
    \out_line{}
    \out_line{\string\documentclass[twocolumn]{article}}
-   \out_line{\string\usepackage{fontdoc}}
+   \out_line{\string\usepackage{fontdoc}[2005/05/13]}
    \out_line{}
    \out_line{\string\begin{document}}
    \out_line{}
    \out_line{This~document~describes~the~#1~encoding.}
    \out_line{It~was~automatically~generated~by~the}
-   \out_line{{\string\tt\space~fontinst}~package.}
+   \out_line{\string\texttt{fontinst}~package.}
    \out_line{}
    \out_line{\string\encoding}
    \out_line{}
@@ -125,9 +171,10 @@
    \out_line{\string\end encoding}
    \out_line{}
    \out_line{\string\end{document}}
-   \close_out{Encoding~vector}
+   \close_out{Encoding}
 }
 %    \end{macrocode}
+% \end{macro}
 %
 %
 % \subsection{Converting an ETX file to an ENC file}
@@ -400,7 +447,9 @@
 % 
 % 
 % \begin{macro}{\etxtocmap}
-%   The 
+%   As usual for macros with this kind of name, this is the user 
+%   level command to call to generate a CMAP from an ETX. The 
+%   arguments are file names (not including extensions).
 %    \begin{macrocode}
 \def\etxtocmap#1#2{\begingroup
    \inputetx{#1}
@@ -561,8 +610,9 @@
 {\afm_command#1~\end_of_line\afm_line}}
 %    \end{macrocode}
 %
-% The command |\afm_command| reads the first word |FOO|, and calls
-% |afm-FOO|.  If this does not exist, then |\gobble_one_line| will
+% The command |\afm_command| reads the first word \meta{FOO}, and 
+% calls |\afm-|\meta{FOO}\describecsfamily{afm-\meta{key}}.  If this 
+% does not exist, then |\gobble_one_line| will
 % eat up the rest of the line.
 %
 %    \begin{macrocode}
@@ -580,10 +630,12 @@
 %   To define an AFM command, you say |\afm_def|\marg{command}^^A
 %   \parg{pattern}\marg{result}
 %   \begin{macrocode}
-\def\afm_def#1(#2)#3{\x_cs\def{afm-#1}
-   \gobble_one_line#2\end_of_line{#3}}
+\def\afm_def#1(#2)#3{
+   \x_cs\def{afm-#1}\gobble_one_line#2\end_of_line{#3}
+}
 %    \end{macrocode}
 % \end{macro}
+% 
 % \begin{macro}{\afm_let}
 %   Saying |\afm_let|\marg{dest-command}\marg{source-command} copies 
 %   the definition of one AFM command to another.
@@ -654,9 +706,20 @@
 }
 %    \end{macrocode}
 % \end{macro}
-%
-% Processing kern pairs.  If one of the glyph name starts with
-% a dot as in |.notdef| or |.null| the kern pair is ignored.
+% 
+% \begin{macro}{\afm-KPX}
+% \begin{macro}{\afm-KP}
+%   Processing kern pairs.  If one of the glyph name starts with
+%   a dot as in |.notdef| or |.null| the kern pair is ignored. 
+%   The pair is also ignored if the absolute value of the kern 
+%   amount is |\minimum_kern| or less.
+%   
+%   That \texttt{KPX} can have the same definition as \texttt{KP} is 
+%   due to an edge case in the processing of AFM lines: |\afm_line| 
+%   inserts an extra space at the end of a line. For \texttt{KPX} 
+%   which really only has three arguments this extra space matches 
+%   the space in |#3~#4|, whereas for \texttt{KP} which has four 
+%   arguments this extra space appears at the end of |#4|.
 %
 %    \begin{macrocode}
 \afm_def{KP}(#1~#2~#3~#4){
@@ -664,21 +727,42 @@
    \if\first_char#2=.\else
       \afm_length\a_count{#3}
       \ifnum \a_count>\minimum_kern
-         \out_line{\string\setkern{#1}{#2}{\the\a_count}}
+         \afm_write_setkern{#1}{#2}{\the\a_count}
       \else\ifnum \a_count<-\minimum_kern
-         \out_line{\string\setkern{#1}{#2}{\the\a_count}}
+         \afm_write_setkern{#1}{#2}{\the\a_count}
       \fi\fi
    \fi\fi
 }
 \afm_let{KPX}{KP}
 %    \end{macrocode}
+% \end{macro}\end{macro}
+% 
+% \begin{macro}{\afm_write_setkern}
+%   This macro is a hook for the auto-aliasing mechanism to redefine. 
+%   In this plain form, it just outputs a |\setkern| command with the 
+%   given three arguments.
+%   \changes{1.933}{2007/01/23}{Macro added. (LH)}
+%    \begin{macrocode}
+\def\afm_write_setkern#1#2#3{\out_line{\string\setkern{#1}{#2}{#3}}}
+%    \end{macrocode}
+% \end{macro}
 %
 % Processing char metrics.
 %
 %    \begin{macrocode}
 \afm_def{C}(#1~;#2){\init_afm{#1}\do_list[#2]\afm_char}
-\afm_let{CH}{C}
 %    \end{macrocode}
+%    
+% \begin{macro}{\afm-CH}
+%   The |CH| keyword is like |C|, but signals that the following 
+%   character code is given in hexadecimal.
+%   \changes{1.933}{2007/01/22}{Proper definition, that parses the 
+%      following hexadecimal value. (LH) Since noone has complained 
+%      about this before, it's probably not very common.}
+%    \begin{macrocode}
+\afm_def{CH}(<#1>~;#2){\uppercase{\init_afm{"#1}}\do_list[#2]\afm_char}
+%    \end{macrocode}
+% \end{macro}
 %
 % Processing composite chars.
 %
@@ -700,8 +784,9 @@
 \let\char_name=\empty_command
 %    \end{macrocode}
 %
-% |\init_afm| initializes the variables the AFM character list writes to.
-%
+% \begin{macro}{\init_afm}
+%   |\init_afm| initializes the variables the AFM character list 
+%   writes to.
 %    \begin{macrocode}
 \def\init_afm#1{
    \char_slot=#1\x_relax
@@ -713,23 +798,17 @@
    \let\char_name=\empty_command
 }
 %    \end{macrocode}
+% \end{macro}
 %
-% ^^A Commented out, since it describes the way of things before 
-% ^^A v1.308 (this comment has been wrong for over five years!):
-% ^^A 
-% ^^A |\afm_char| writes the values of these variables to the |.mtx| 
-% ^^A file, and saves them in a macro |\g-GLYPHNAME|, in the form:
-% ^^A \begin{quote}
-% ^^A    |{WIDTH}{HEIGHT}{DEPTH}{ITALIC}|
-% ^^A \end{quote}
-% ^^A 
-% ^^A These are needed, because the (grumble grumble) syntax of |CC| 
-% ^^A commands doesn't include the glyph measurements, so we have to 
-% ^^A remember them.
-%
+% \begin{macro}{\afm_char}
+%   This command is executed at the end of processing a \texttt{C} 
+%   (or \texttt{CH}) line. It outputs the corresponding 
+%   |\setrawglyph| or |\setnotglyph| command, based on information 
+%   stored into registers when processing that line.
+%   \changes{1.933}{2007/01/23}{Negating \cs{bbox_lly} using 
+%      \cs{number} instead of an assignment to \cs{a_count}. (LH)}
 %    \begin{macrocode}
 \def\afm_char{
-   \a_count=-\bbox_lly
    \eval_expr{
       \italcorr_expression\x_width\bbox_llx\bbox_urx\bbox_lly\bbox_ury
    }
@@ -745,11 +824,12 @@
       {\the\char_slot}
       {\the\x_width}
       {\the\bbox_ury}
-      {\the\a_count}
+      {\number -\bbox_lly}
       {\the\result}
    }
 }
 %    \end{macrocode}
+% \end{macro}
 %
 % |\init_cc| and |\cc_char| write out a composite character glyph.
 %
@@ -840,7 +920,10 @@
 % \end{macro}
 %
 % To process a list of commands separated by semi-colons, we call
-% |\do_list[LIST]|.  This works in a similar way to |\afm_line|.
+% |\do_list[LIST]|.  This works in a similar way to |\afm_line|, but 
+% the control sequence family used for decoding is 
+% \describecsfamily{list-\meta{key}}|\list-|\meta{keyword} rather 
+% than |\afm-|\meta{keyword}.
 %
 %    \begin{macrocode}
 \def\do_list[~#1~#2;~#3]{
@@ -879,7 +962,129 @@
    \out_lline{\string\glyphpcc{#1}{\the\a_count}{\the\b_count}}
 }
 %    \end{macrocode}
-%
+% 
+% \begin{macro}{\definealias}
+%   The |\definealias| command can be used to define a glyph name 
+%   alias, for generation of |\aliased| clauses in glyph names. The 
+%   syntax is
+%   \begin{quote}
+%     |\definealias|\marg{alias name}\marg{font's name}\marg{int}
+%   \end{quote}
+%   where \meta{font's name} is the glyph name that if found in an 
+%   AFM file should be converted to an |\aliased| clause using the 
+%   \meta{alias name}. The \meta{int} is the name of an integer which 
+%   will be incremented every time this alias applies to a glyph 
+%   definition; this mechanism is meant to help higher level code 
+%   pick an ETX file that fits the font's glyph names.
+%   
+%   \changes{1.933}{2007/01/22}{Command added. (LH)}
+%   
+%   Defined aliases are stored in the 
+%   \describecsfamily{GN-\meta{font's name}}|\GN-|\meta{font's name} 
+%   family of control sequences. These control sequences are defined 
+%   to be macros expanding to the two tokens
+%   \begin{quote}
+%     |\g-|\meta{alias name}\,|\i-|\meta{int}
+%   \end{quote}
+%   In the case of |\g-|\meta{alias name}, this is purely a trick to 
+%   save memory (it is very likely that these control sequences will 
+%   anyway occur during the fontmaking part of the processing).
+%    \begin{macrocode}
+\def\definealias#1#2#3{
+   \expandafter\def \csname GN-#1 \expandafter\endcsname
+      \expandafter{ \csname g-#2 \expandafter\endcsname
+      \csname i-#3\endcsname}
+}
+%    \end{macrocode}
+% \end{macro}
+% 
+% \begin{macro}{\glyph_alias}
+% \begin{macro}{\glyph_alias_i}
+%   The |\glyph_alias| macro has the syntax
+%   \begin{quote}
+%     |\glyph_alias|\marg{font's name}
+%   \end{quote}
+%   It expands to the \meta{alias name} corresponding to the 
+%   \meta{font's name}, that had previously been set up using 
+%   |\definealias|. Where this macro is used, it must already have 
+%   been checked that |\GN-|\meta{font's name} is defined.
+%    \begin{macrocode}
+\def\glyph_alias#1{
+   \expandafter\expandafter \expandafter\glyph_alias_i
+      \csname GN-#1\endcsname
+}
+\def\glyph_alias_i#1#2{
+   \expandafter\gobble_three \string#1
+}
+%    \end{macrocode}
+% \end{macro}\end{macro}
+% 
+%    \begin{macrocode}
+\let\charnameprefix\empty
+\def\charnamealias#1{
+   \if_defined{GN-\charnameprefix#1}\then
+      \glyph_alias{\charnameprefix#1}
+   \else\if_defined{GN-#1}\then
+      \glyph_alias{#1}
+   \else
+      #1
+   \fi\fi
+}
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
+\def\alias_incr#1{
+   \expandafter\expandafter \expandafter\alias_incr_i
+      \csname GN-#1\endcsname
+}
+\def\alias_incr_i#1#2{
+   \ifx#2\x_relax
+      \mathchardef#2=\@ne
+   \else
+      \a_count=#2
+      \advance\a_count\@ne
+      \mathchardef#2=\a_count
+   \fi
+}
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
+\def\alias_char_name#1{
+   \if_defined{GN-\charnameprefix#1}\then
+      \edef\char_name{
+         \string\aliased{#1}{\glyph_alias{\charnameprefix#1}}
+      }
+      \alias_incr{\charnameprefix#1}
+   \else\if_defined{GN-#1}\then
+      \edef\char_name{
+         \string\aliased{#1}{\glyph_alias{#1}}
+      }
+      \alias_incr{#1}
+   \else
+      \edef\char_name{#1}
+   \fi\fi
+}
+\def\autoaliasafm{
+   \begingroup
+   \list_def{N}(##1){\alias_char_name{##1}}
+   \def\afm_write_setkern##1##2##3{
+      \out_line{
+         \string\setkern{\charnamealias{##1}}{\charnamealias{##2}}{##3}
+      }
+   }
+   \def\init_cc##1{%
+      \edef\char_name{\charnamealias{##1}}
+      \out_line{\string\setglyph{\char_name}}
+   }
+   \list_def{PCC}(##1~##2~##3){
+      \afm_length\a_count{##2}
+      \afm_length\b_count{##3}
+      \out_lline{\string\glyphpcc
+        {\charnamealias{##1}}{\the\a_count}{\the\b_count}}
+   }
+}
+\def\endautoaliasafm{\endgroup}
+%    \end{macrocode}
 %
 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
@@ -2043,16 +2248,14 @@
 %   \changes{1.911}{1999/11/19}{\cs{edef}ing \cs{raw_font_name}. (LH)}
 %   \changes{1.915}{2000/09/09}{Locally redefining \cs{aliased}. (LH)}
 %   \changes{1.924}{2003/02/08}{Added \cs{directfalse}. (LH)}
+%   \changes{1.931}{2005/05/13}{Placed ETX processing after 
+%      \cs{needsfontinstversion} had been written, so that ETX commands 
+%      can write data directly to the output MTX file. (LH)}
+%   \changes{1.931}{2005/05/13}{Copying \cs{declarepsencoding} data to 
+%      generated MTX file as a \cs{setpsencoding} command. (LH)}
 %    \begin{macrocode}
 \def\mtxtomtx#1#2{{
-   \ifisstr{etx-name}\then
-      \def\do_slot{\x_cs\edef{slots-\slot_name}{\the\slot_number}}
-      \directfalse
-      \inputetx{\str{etx-name}}
-      \edef\a_macro{\string\reencodefont{\str{etx-name}}}
-   \else
-      \let\a_macro=\empty_command
-   \fi
+   \let\a_macro=\empty_command
    \_a_true
    \ifnum \int{x-scale}=\int{y-scale}
       \ifnum \int{slant-scale}=\z@
@@ -2082,6 +2285,20 @@
    \out_line{}
    \out_line{\string\needsfontinstversion{\fontinstversion}}
    \out_line{}
+   \ifisstr{etx-name}\then
+      \def\do_slot{\x_cs\edef{slots-\slot_name}{\the\slot_number}}
+      \def\declarepsencoding##1##2##3{
+         \a_toks={{##1}{##2}{##3}}
+         \out_line{\string\providepsencoding\the\a_toks}
+         \ifnum \transform_record_file=\closed_stream \else
+            \pout_line\transform_record_file
+              {\string\providepsencoding\the\a_toks}
+         \fi
+      }
+      \directfalse
+      \inputetx{\str{etx-name}}
+      \edef\a_macro{\a_macro\string\reencodefont{\str{etx-name}}}
+   \fi
    \record_transform{#2}{\string\frommtx{#1}}{\a_macro}\iftrue
    \out_line{}
    \mtxtomtx_redefinitions
-- 
cgit v1.2.3

