29.5 Fonts (latex.ltx + fontmath.4ht)

<..fontmath.4ht..>
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % fontmath.4ht                          2014-07-12-22:36 %
 % Copyright (C) 1997--2009       Eitan M. Gurari         %
 <.TeX4ht copyright.>
 <.config fontmath.ltx utilities.>
 <.config fontmath.ltx shared.>
 <.config fontmath.>
 <.fontmath + plain classes.>
 <.over/under fontmath.>
 \Hinput{fontmath}
 \endinput
 -_-_-

<..fontmath + plain classes..>+
 <.plain, fontmath, amsmath, amstex.>
 <.plain, fontmath, amstex.>
 -_-_-

Fonts can create problems in edef environments. The following definition is to get protection in titles taht go to the top of hypertext pages. The ‘\text...’ belong to latex.ltx.

<..config fontmath.ltx utilities..>
 \def\:same#1{#1}
 \def\no:fonts{\more:no  \let\protect\@unexpandable@protect }
 \def\more:no{%
    \let\footnote=\:gobble \let\ =\space
  }
 -_-_-

Definitions like \def\mathbf#1{\a:mathbf#1\b:mathbf} must take care of commands like \bf. The latter commands in effect tranform the \mathbf commands into old fashion $\bf R$.

<..config fontmath.ltx shared..>
 \def\choose:mfont#1{\ifx \math@bgroup \relax
      \expandafter\old:mfont
    \else
      \expandafter\new:mfont
    \fi
    {#1}}
 \def\old:mfont#1{\csname o:@#1:\endcsname}
 <.new fonts setting.>
 \:tempd{mathbf}
 \:tempd{mathrm}
 \:tempd{mathsf}
 \:tempd{mathit}
 \:tempd{mathtt}
 -_-_-

<..new fonts setting..>
 \def\new:mfont#1#2{%
       \csname a:#1\endcsname
       \csname o:#1@@:\endcsname
   {#2}\csname b:#1\endcsname
 }
 \def\:temp{\protect \@mathtt}
 \ifx \mathtt\:temp
    <.pre 2005 fontmath.>
 \else
    <.2005 fontmath.>
 \fi
 -_-_-

<..pre 2005 fontmath..>
 \def\:tempd#1{%
    \expandafter\edef\csname #1\endcsname{%
        \noexpand\protect \expandafter\noexpand
             \csname #1@@\endcsname}
    \expandafter\edef\csname #1@@\endcsname{%
        \noexpand\protect \expandafter\noexpand
        \csname @#1\endcsname}
    \def\:tempc{\choose:mfont {#1}}
    \expandafter\HLet\csname #1@@\endcsname\:tempc
    \NewConfigure{#1}{2}%
 }
 -_-_-

<..2005 fontmath..>
 \def\:tempd#1{%
    \expandafter\edef\csname #1\endcsname{%
        \noexpand\protect \expandafter\noexpand
             \csname #1@@\endcsname}
    \expandafter\edef\csname #1@@\endcsname{%
        \noexpand\protect \expandafter\noexpand
        \csname #1\space\endcsname}
    \def\:tempc{\choose:mfont {#1}}
    \expandafter\HLet\csname #1@@\endcsname\:tempc
    \NewConfigure{#1}{2}%
 }
 -_-_-

The following configuration break, for instance, with the following source due to dynamic change of fonts.

\documentclass{article} 
\begin{document} 
prima  {\boldmath $\mathrm{{\csname HCode\endcsname{}}^{14}C}$} 
 
seconda   {\boldmath $\mathsf{{\csname HCode\endcsname{}}^{15}C}$} 
 
terza   {\boldmath $\mathrm{{\csname HCode\endcsname{}}^{16}C}$} 
 
quarta   {\boldmath $\mathsf{{\csname HCode\endcsname{}}^{17}C}$} 
 
 quinta   {$\mathtt{{\csname HCode\endcsname{}}^{18}C}$} 
\end{document} 

<..new fonts settingNO..>
 \def\new:mfont#1#2{%
       \csname a:#1\endcsname
       \csname o:@#1:\endcsname
   {#2}\csname b:#1\endcsname
 }
 \def\:tempd#1{%
    \def\:tempc{\choose:mfont {#1}}
    \expandafter\HLet\csname @#1\endcsname=\:tempc
    \NewConfigure{#1}{2}%
 }
 -_-_-

The \csname mv@\math@version \endcsname showas the installed math macros. The following modification might also become handy.

\def\install@mathalphabet#1{% 
  \expandafter\ifx \csname o:\expandafter\:gobble\string #1:\endcsname\relax 
     \:warning{\expandafter\:gobble\string #1 not configured}% 
     \expand:after{\gdef#1}% 
  \else 
     \expand:after{\expandafter\gdef\csname o:\expandafter 
         \:gobble\string #1:\endcsname}% 
  \fi 
} 
 
The issue of font decoration in math is currently problematic. 
 
*  In unicode, decorated symbols get distinguished codes if 
   the decoration implies special math meaning.  Consequently, 
   symbols with ‘meaningful’ decorations should be embedded 
   in decorated unicode entries, whereas ‘meaningless’ decorations 
   should be set through style sheets (e.g., css or xslt). 
 
*  The behavior of latex doesn’t seem to always be meaningful, for 
   instance, \mathbf in the following example. 
 
     \documentclass{amsart} 
        \RequirePackage{bm} 
     \begin{document} 
 
       \def\x{ A + \alpha + \Delta } 
 
       $ \x            $ \par       % none in bold 
       $ \bm{ \x }     $ \par       % all in bold 
       $ \mathbf{ \x } $            % just A and Delta in bold 
 
     \end{document} 
 
*   The decorations by \bm, I think, should be considered meaningless. 
    Currently they can’t be realized through style sheets, because the 
    browsers don’t seem to support such capabilities for mathml. 
 
*   A few cases, like \mathbb, seem to have ‘meaningful’ decorations. 
    So tex4ht tries to implement these decorations. 

<..config latex.ltx shared..>+
 \NewConfigure{texttt}[2]{\expandafter\ifx \csname o:texttt :\endcsname\relax
   \long\def\:temp##1{{\a:texttt \csname o:texttt :\endcsname{##1}\b:texttt}}%
   \expandafter\HLet\csname texttt \endcsname=\:temp
   \fi \c:def\a:texttt{#1}\c:def\b:texttt{#2}}
 \NewConfigure{textit}[2]{\expandafter\ifx \csname o:textit :\endcsname\relax
   \long\def\:temp##1{{\a:textit \csname o:textit :\endcsname{##1}\b:textit}}%
   \expandafter\HLet\csname textit \endcsname=\:temp
   \fi \c:def\a:textit{#1}\c:def\b:textit{#2}}
 \NewConfigure{textrm}[2]{\expandafter\ifx \csname o:textrm :\endcsname\relax
   \long\def\:temp##1{{\a:textrm \csname o:textrm :\endcsname{##1}\b:textrm}}%
   \expandafter\HLet\csname textrm \endcsname=\:temp
   \fi \c:def\a:textrm{#1}\c:def\b:textrm{#2}}
 \NewConfigure{textup}[2]{\expandafter\ifx \csname o:textup :\endcsname\relax
   \long\def\:temp##1{{\a:textup \csname o:textup :\endcsname{##1}\b:textup}}%
   \expandafter\HLet\csname textup \endcsname=\:temp
   \fi \c:def\a:textup{#1}\c:def\b:textup{#2}}
 \NewConfigure{textsl}[2]{\expandafter\ifx \csname o:textsl :\endcsname\relax
   \long\def\:temp##1{{\a:textsl \csname o:textsl :\endcsname{##1}\b:textsl}}%
   \expandafter\HLet\csname textsl \endcsname=\:temp
   \fi \c:def\a:textsl{#1}\c:def\b:textsl{#2}}
 \NewConfigure{textsf}[2]{\expandafter\ifx \csname o:textsf :\endcsname\relax
   \long\def\:temp##1{{\a:textsf \csname o:textsf :\endcsname{##1}\b:textsf}}%
   \expandafter\HLet\csname textsf \endcsname=\:temp
   \fi \c:def\a:textsf{#1}\c:def\b:textsf{#2}}
 \NewConfigure{textbf}[2]{\expandafter\ifx \csname o:textbf :\endcsname\relax
   \long\def\:temp##1{{\a:textbf \csname o:textbf :\endcsname{##1}\b:textbf}}%
   \expandafter\HLet\csname textbf \endcsname=\:temp
   \fi \c:def\a:textbf{#1}\c:def\b:textbf{#2}}
 \NewConfigure{textsc}[2]{\expandafter\ifx \csname o:textsc :\endcsname\relax
   \long\def\:temp##1{{\a:textsc \csname o:textsc :\endcsname{##1}\b:textsc}}%
   \expandafter\HLet\csname textsc \endcsname=\:temp
   \fi \c:def\a:textsc{#1}\c:def\b:textsc{#2}}
 \NewConfigure{emph}[2]{\expandafter\ifx \csname o:emph :\endcsname\relax
   \long\def\:temp##1{{\a:emph \csname o:emph :\endcsname{##1}\b:emph}}%
   \expandafter\HLet\csname emph \endcsname=\:temp
   \fi \c:def\a:emph{#1}\c:def\b:emph{#2}}
 -_-_-

<..base fonts..>
 \def\:temp#1#2<.par del.>{\def\:temp{#1}}
 \expandafter\:temp\usepackage<.par del.>
 \def\:tempa{\@latex@e@error}
 \ifx \:temp\:tempa \else
    <.not latex209 base fonts.>
 \fi
 -_-_-

<..not latex209 base fonts..>
 \def\:tempa#1#2#3#4{\tmp:toks{#1{#2}}%
    \long\expandafter\edef\csname #4 \endcsname{\the\tmp:toks
         {\expandafter\noexpand
    \csname o:\expandafter\:gobble\string #3:\endcsname}}}
 \def\:temp#1{%
   \expandafter\ifx \csname #1 \endcsname\relax\else
      \expandafter\expandafter\expandafter\:tempa\csname #1 \endcsname{#1}%
   \fi
 }
 \:temp{rm}
 \:temp{sf}
 \:temp{tt}
 \:temp{bf}
 \:temp{it}
 -_-_-

<..book / report / article..>+
 <.base fonts.>
 -_-_-

<..ams art + book + proc..>
 <.base fonts.>
 -_-_-

The else part is for compabibility when the ‘fonts’ option is inactive.

[comment]