%% This is part of the OpTeX project, see http://petr.olsak.net/optex

\_codedecl \_undefined {Font catalogue <2023-03-09>} % loaded on demand by \fontfam[catalog]

\_tracinglostchars=1 % only to log file
\_initunifonts
\_raggedbottom
\_begingroup

\_istoksempty\_catalogmathsample \_iftrue \_noloadmath \_fi
\_global\_font\_ttfixed=[LMMono10-Regular]\_relax
\_fontlet\_smalltt=\_ttfixed at7pt
\_suppressfontnotfounderror=1

\_lowercase\_ea{\_ea\_def\_ea\_cataloglist\_ea{\_the\_catalogonly}}
\_lowercase\_ea{\_ea\_def\_ea\_catalognolist\_ea{\_the\_catalogexclude}}

\_ifx\_cataloglist\_empty \_else
   \_addto\_cataloglist{ }
   \_edef\_cataloglist{\_ea\_removespaces\_cataloglist{} }
\_fi
\_ifx\_catalognolist\_empty \_else
   \_addto\_catalognolist{ }
   \_edef\_catalognolist{\_ea\_removespaces\_catalognolist{} }
\_fi

\_def\_faminfo [#1]#2#3#4{%
   \_bgroup
       \_lowercase{\_edef\_famname{\_ea\_removespaces #1 {} }}%
       \_edef\_act{\_noexpand\_isinlist{,\_cataloglist,}{,\_famname,}}\_act
       \_iftrue \def\_cataloglist{}\_fi
       \_edef\_act{\_noexpand\_isinlist{,\_catalognolist,}{,\_famname,}}\_act
       \_iftrue \def\_cataloglist{.}\_fi
       \_ifx\_cataloglist\_empty
       \_ifx^#4^\_else
          \_bigskip {\_ttfixed\_string\fontfam [#1] -- (#2)\_par}
          \_input #3.opm
          \_ifexistfam \_nobreak\_medskip \_dosamples #4:{}
              \_ifx\_mathfaminfo\_empty
              \_else \_istoksempty\_catalogmathsample
                  \_iftrue {\_ttfixed \$Default math font\$: \_mathfaminfo \_par}
                  \_else Default math font (\_mathfaminfo): \_the\_catalogmathsample \_par
              \_fi\_fi
          \_else {\_qquad\_ttfixed ... family skipped, fonts not found in your system.\_nl
                  \_null\_qquad ... where is the family from:\_nl
                  \_null\_qquad\_qquad\_the\_famsrc}
       \_fi\_fi\_fi
   \_egroup
}
\_def\_dosamples #1:#2{\_ifx^#2^\_else
   \_def\_printvars{#2}%
   \_nospaceafter\_dosamplesA #1,,%
   \_ea\_dosamples\_fi
}
\_def\_dosamplesA#1,{%
   \_ifx^#1^\_else
      \_ifx-#1\_def\_usemodifiers{}\_else \_def\_usemodifiers{#1}\_fi
      \_ea \_dosamplesB \_printvars \_relax
      \_ea \_dosamplesA \_fi
}
\_def\_dosamplesB#1{%
   \_ifx\_relax#1 \_else
      {\_ttfixed \_detokenize\_ea{\_usemodifiers}\_detokenize{#1}\_unskip:}
      {\_usemodifiers #1\_ea\_ifx\_the\_font \_nullfont
          \_ttfixed ... This font isn't available in your system.%
      \_else \_the\_catalogsample \_fi }\_par
      \_ea \_dosamplesB \_fi
}

\_def\_wlog#1{\_nobreak\_smallskip
   \_hbox to\_hsize{\_hskip25pt
      \_edef\_tmp{#1}\_replstring\_tmp{^^J}{\_endgraf}%
      \_smalltt \_noindent \_ea \string \_csname \_currfamily\_endcsname
      \_vtop{\leftskip=1em \_baselineskip=9pt \_tmp \_par}\_hss
      \_if\_relax\_the\_famfrom\_relax \_else from: \_the\_famfrom \_fi
   }
}

\_gdef\0#1{\_ifnum#1<10 0\_fi\_the#1}
\_global\_footline={\_hfil\_ttfixed\_the\_pageno\_hfil}
\_global\_headline={\_ttfixed Font Catalogue generated by \_OpTeX/ \_hfill \_the\_year-\0\_month-\0\_day}
\_parindent=0pt
\_ttfixed

\_input fams-ini.opm

\_isfile {fams-local.opm}\_iftrue \_famfrom{}\_input fams-local.opm \_fi

\_endgroup

\parindent=0pt

\nonum\sec Customization of the catalog


You can redeclare the printed sample of each font by:

\begtt
\catalogsample={Hello world!}
\endtt

before \code{\\fontfam[catalog]} command is used. You can specify
\code{\\catalogmathsample} if you want to show default math fonts too, for example

\begtt
\catalogmathsample={Gamma function is defined as
   $$
   \Gamma(z) = \int_0^\infty x^{z-1} e^{-x}{\rm d}x, \quad \Re(z)>0.
   $$}
\endtt
%
The \code{\\catalogmathsample} is empty by default, so math fonts are not loaded,
only the family of default math font is listed.

\bigskip
You can restrict the families to be printed in the catalog by:

\begtt
\catalogonly={Termes, Latin Modern, Heros}
\endtt

If the \code{\\catalogonly} is empty (this is default value) then all families are
printed but families listed in the \code{\\catalogexclude} are excluded. For example

\begtt
\catalogexclude={Latin Modern, XCharter}
\endtt

The \code{\\cataogexclude} is empty by default.

\bigskip The font families printed in the catalogue must be declared by the
\code{\\_faminfo} command in the file \code{fams-ini.opm} (declarations used
as default for \OpTeX/) or in the file \code{fams-local.opm}. The second file
does not exist by default but users can create it. The syntax rules are
described in the \code{fams-ini.opm} file.

\_endcode % -------------------------------------

2023-03-09  \_famsrc introduced
2022-07-11  \_raggedbottom added
2022-02-22  \_ttfixed, \footline set as global, bug fixed
2020-02-26  released
