| 1 |
%% This is part of the OpTeX project, see http://petr.olsak.net/optex |
| 2 |
|
| 3 |
\_codedecl \_undefined {Font catalogue <2023-06-04>} % loaded on demand by \fontfam[catalog] |
| 4 |
|
| 5 |
\_tracinglostchars=1 % only to log file |
| 6 |
\_initunifonts |
| 7 |
\_raggedbottom |
| 8 |
\_begingroup |
| 9 |
|
| 10 |
\_istoksempty\_catalogmathsample \_iftrue \_noloadmath \_else \_input{unimath-codes.opm}\_fi |
| 11 |
\_global\_font\_ttfixed=[LMMono10-Regular]\_relax |
| 12 |
\_fontlet\_smalltt=\_ttfixed at7pt |
| 13 |
\_suppressfontnotfounderror=1 |
| 14 |
|
| 15 |
\_lowercase\_ea{\_ea\_def\_ea\_cataloglist\_ea{\_the\_catalogonly}} |
| 16 |
\_lowercase\_ea{\_ea\_def\_ea\_catalognolist\_ea{\_the\_catalogexclude}} |
| 17 |
|
| 18 |
\_ifx\_cataloglist\_empty \_else |
| 19 |
\_addto\_cataloglist{ } |
| 20 |
\_edef\_cataloglist{\_ea\_removespaces\_cataloglist{} } |
| 21 |
\_fi |
| 22 |
\_ifx\_catalognolist\_empty \_else |
| 23 |
\_addto\_catalognolist{ } |
| 24 |
\_edef\_catalognolist{\_ea\_removespaces\_catalognolist{} } |
| 25 |
\_fi |
| 26 |
|
| 27 |
\_def\_faminfo [#1]#2#3#4{% |
| 28 |
\_bgroup |
| 29 |
\_rightskip=0sp plus 1fill |
| 30 |
\_lowercase{\_edef\_famname{\_ea\_removespaces #1 {} }}% |
| 31 |
\_edef\_act{\_noexpand\_isinlist{,\_cataloglist,}{,\_famname,}}\_act |
| 32 |
\_iftrue \def\_cataloglist{}\_fi |
| 33 |
\_edef\_act{\_noexpand\_isinlist{,\_catalognolist,}{,\_famname,}}\_act |
| 34 |
\_iftrue \def\_cataloglist{.}\_fi |
| 35 |
\_ifx\_cataloglist\_empty |
| 36 |
\_ifx^#4^\_else |
| 37 |
\_the\_catalognextfam |
| 38 |
{\_ttfixed\_string\fontfam [#1] -- (#2)\_par}\_nobreak |
| 39 |
\_input #3.opm |
| 40 |
\_ifexistfam |
| 41 |
\_nobreak\_medskip \_dosamples #4:{}\_par |
| 42 |
\_ifx\_mathfaminfo\_empty |
| 43 |
\_else \_istoksempty\_catalogmathsample |
| 44 |
\_iftrue {\_nobreak \_ttfixed \$Default math font\$: \_mathfaminfo \_par} |
| 45 |
\_else Default math font (\_mathfaminfo): \_the\_catalogmathsample \_par |
| 46 |
\_fi\_fi |
| 47 |
\_else {\_qquad\_ttfixed ... family skipped, fonts not found in your system.\_nl |
| 48 |
\_null\_qquad ... where is the family from:\_nl |
| 49 |
\_null\_qquad\_qquad\_the\_famsrc} |
| 50 |
\_fi\_fi\_fi |
| 51 |
\_egroup |
| 52 |
} |
| 53 |
\_def\_dosamples #1:#2{\_ifx^#2^\_else |
| 54 |
\_def\_printvars{#2}% |
| 55 |
\_nospaceafter\_dosamplesA #1,,% |
| 56 |
\_ea\_dosamples\_fi |
| 57 |
} |
| 58 |
\_def\_dosamplesA#1,{% |
| 59 |
\_ifx^#1^\_else |
| 60 |
\_ifx-#1\_def\_usemodifiers{}\_else \_def\_usemodifiers{#1}\_fi |
| 61 |
\_ea \_dosamplesB \_printvars \_relax |
| 62 |
\_ea \_dosamplesA \_fi |
| 63 |
} |
| 64 |
\_def\_dosamplesB#1{% |
| 65 |
\_ifx\_relax#1 \_else |
| 66 |
\_ifhmode \_nl \_fi |
| 67 |
{\_ttfixed \_detokenize\_ea{\_usemodifiers}\_detokenize{#1}\_unskip:} |
| 68 |
{\_usemodifiers #1\_ea\_ifx\_the\_font \_nullfont |
| 69 |
\_ttfixed ... This font isn't available in your system.% |
| 70 |
\_else \_the\_catalogsample \_fi }% |
| 71 |
\_ea \_dosamplesB \_fi |
| 72 |
} |
| 73 |
|
| 74 |
\_def\_wlog#1{\_smallskip |
| 75 |
\_hbox to\_hsize{\_hskip25pt |
| 76 |
\_edef\_tmp{#1}\_replstring\_tmp{^^J}{\_endgraf}% |
| 77 |
\_smalltt \_noindent \_ea \string \_csname \_currfamily\_endcsname |
| 78 |
\_vtop{\leftskip=1em \_baselineskip=9pt \_tmp \_par}\_hss |
| 79 |
\_if\_relax\_the\_famfrom\_relax \_else from: \_the\_famfrom \_fi |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
\_gdef\0#1{\_ifnum#1<10 0\_fi\_the#1} |
| 84 |
\_global\_footline={\_hfil\_ttfixed\_the\_pageno\_hfil} |
| 85 |
\_global\_headline={\_ttfixed Font Catalogue generated by \_OpTeX/ \_hfill \_the\_year-\0\_month-\0\_day} |
| 86 |
\_parindent=0pt |
| 87 |
\_ttfixed |
| 88 |
|
| 89 |
\_input fams-ini.opm |
| 90 |
|
| 91 |
\_isfile {fams-local.opm}\_iftrue \_famfrom{}\_input fams-local.opm \_fi |
| 92 |
|
| 93 |
\_endgroup |
| 94 |
|
| 95 |
\_the\_catalognextfam {} |
| 96 |
|
| 97 |
\parindent=0pt |
| 98 |
|
| 99 |
\nonum\sec Customization of the catalog |
| 100 |
|
| 101 |
|
| 102 |
You can redeclare the printed sample of each font by: |
| 103 |
|
| 104 |
\begtt |
| 105 |
\catalogsample={Hello world!} |
| 106 |
\endtt |
| 107 |
|
| 108 |
before \code{\\fontfam[catalog]} command is used. You can specify |
| 109 |
\code{\\catalogmathsample} if you want to show default math fonts too, for example |
| 110 |
|
| 111 |
\begtt |
| 112 |
\catalogmathsample={Gamma function is defined as |
| 113 |
$$ |
| 114 |
\Gamma(z) = \int_0^\infty x^{z-1} e^{-x}{\rm d}x, \quad \Re(z)>0. |
| 115 |
$$} |
| 116 |
\endtt |
| 117 |
% |
| 118 |
The \code{\\catalogmathsample} is empty by default, so math fonts are not loaded, |
| 119 |
only the family of default math font is listed. |
| 120 |
|
| 121 |
\bigskip |
| 122 |
You can restrict the families to be printed in the catalog by: |
| 123 |
|
| 124 |
\begtt |
| 125 |
\catalogonly={Termes, Latin Modern, Heros} |
| 126 |
\endtt |
| 127 |
|
| 128 |
If the \code{\\catalogonly} is empty (this is default value) then all families are |
| 129 |
printed but families listed in the \code{\\catalogexclude} are excluded. For example |
| 130 |
|
| 131 |
\begtt |
| 132 |
\catalogexclude={Latin Modern, XCharter} |
| 133 |
\endtt |
| 134 |
|
| 135 |
The \code{\\cataogexclude} is empty by default. |
| 136 |
|
| 137 |
\bigskip The material printed at the beginning of each font family is stored in the |
| 138 |
\code{\\catalognextfam} tokens register. Default value is \code{\\bigskip} but you can |
| 139 |
set (for example) \code{\\catalognextfam={\\vfil\\break}} in order to start |
| 140 |
each font family on a next page. |
| 141 |
|
| 142 |
\bigskip The font families printed in the catalogue must be declared by the |
| 143 |
\code{\\_faminfo} command in the file \code{fams-ini.opm} (declarations used |
| 144 |
as default for \OpTeX/) or in the file \code{fams-local.opm}. The second file |
| 145 |
does not exist by default but users can create it. The syntax rules are |
| 146 |
described in the \code{fams-ini.opm} file. |
| 147 |
|
| 148 |
\_endcode % ------------------------------------- |
| 149 |
|
| 150 |
2023-06-04 line breaking optimized |
| 151 |
2023-06-01 \_catalognextfam introduced, \_nobreak inserted |
| 152 |
2023-03-09 \_famsrc introduced |
| 153 |
2022-07-11 \_raggedbottom added |
| 154 |
2022-02-22 \_ttfixed, \footline set as global, bug fixed |
| 155 |
2020-02-26 released |