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

\_famdecl [New Computer Modern] \NewCM {CM with Book variants, Cyrillic, Greek}
        {\book \ttset \sans \caps \bookMath \sansMath} {\rm \bf \it \bi} {NewCM-Regular}
        {[NewCM10-Regular]}
        {\_def\_fontnamegen {[NewCM\_typfV-\_currV]:\_capsV\_fontfeatures}}

\_wlog{\_detokenize{%
Modifiers:^^J
 \book ...... slightly bolder \rm, \it^^J
 \ttset ..... Typewriter variants^^J
 \sans ...... Sans serif variants^^J
 \caps ...... caps & small caps (not in Italic variants)^^J
 \bookMath .. Book variant for math fonts^^J
 \sansMath .. Sans serif variants for math fonts
}}

\_moddef \resetmod {\_fsetV caps={},typf=10,book={} \_fvars Regular Bold {\_ncmI} {\_ncmBI} }
\_moddef \book     {\_fsetV book=Book \_fvars Book Bold {\_ncmI} {\_ncmBI} }
\_moddef \ttset    {\_fsetV typf=Mono10 }
\_moddef \sans     {\_fsetV typf=Sans10 }
\_moddef \caps     {\_fsetV caps=+smcp;\_ffonum; }

\_moddef \bookMath {\_doloadmath
   \_loadmath {[NewCMMath-Book]}\_loadboldmath{NewCMMath-Bold} \to {[NewCMMath-Book]}}
\_moddef \sansMath {\_doloadmath \_loadmath {[NewCMSansMath-Regular]}}

\_def\_ncmtyprm{10}
\_def\_ncmtypsans{Sans10}
\_def\_ncmI  {\_bookV \_ifx\_typfV\_ncmtypsans Oblique\_else Italic\_fi}
\_def\_ncmBI {Bold\_ifx\_typfV\_ncmtyprm Italic\_else Oblique\_fi}

\_initfontfamily % new font family must be initialized

\_loadmath {[NewCMMath-Regular]}
\_loadboldmath{[NewCMMath-Bold]} \to {[NewCMMath-Regular]}

\_endcode

If you want to use \book variant in the whole document, you can load
NewCMMath-Book Unicode math font too. Use the following declaration in this
case:

\loadmath{[NewCMMath-Book]}
\loadboldmath{NewCMMath-Bold} \to {[NewCMMath-Book]}
\fontfam[newcm]
\book\rm

or for sans serif math you can use:

\loadmath{[NewCMSansMath-Regular]}
\fontfam[newcm]
\sans\rm

See the file `f-heros.opm` for information about principles of such
font-macro-files.