%% This is part of OpTeX project, see http://petr.olsak.net/optex \_famdecl [Latin Modern] \LMfonts {TeX Gyre fonts based on Coputer Modern} {\roman \sans \quotset \ttset \ttprop \ttlight \ttcond \upital \dunhill submods:\caps \slant \nbold \bolder} {\rm \bf \it \bi \tt} {LM} {[lmroman10-regular]} {\_def\_fontnamegen {[\_optname{lm\_subfamV.\_currV}]:\_fontfeatures}} \_wlog{\_detokenize{% Modifiers (selects subfamily):^^J \modreset .. implicit values (serif, bold extended, nocaps)^^J \sans ...... sans serif subfamily^^J \quotset ... quotation subfamily^^J \ttset ..... typewriter subfamily^^J \ttprop .... proportional typewriter-like subfamily^^J \ttlight ... light typewriter subfamily^^J \ttcond .... condensed typewriter subfamily^^J \upital .... upright italic (only \rm)^^J \dunhill ... dunhill roman subfamily (only \rm, \it)^^J% Sub-modifiers (selects special variants of given subfamily):^^J \caps ...... caps & small caps (available only at limited shapes)^^J \slant ..... slanted (default in some subfamilies)^^J \nbold ..... normal bold (extended bold is default)^^J \bolder .... extended bold^^J }} \_def\_LMregfont #1 #2 #3{% \_edef\_tmp {\_noexpand\_regoptsizes #1 #2 \_ea\_detokenize\_ea{#3}}% \_lowercase\_ea{\_tmp}% OTF file names are lowercase } \_def \_regoptFS {5 <5.5 6 <6.5 7 <7.5 8 <8.5 9 <9.5 10 <11.1 12 <15 17 <*} \_def \_regoptFT {5 <5.5 6 <6.5 7 <7.5 8 <8.5 9 <9.5 10 <11.1 12 <*} \_def \_regoptST {7 <7.5 8 <8.5 9 <9.5 10 <11.1 12 <*} \_def \_regoptES {8 <8.5 9 <9.5 10 <11.1 12 <15 17 <*} \_def \_regoptET {8 <8.5 9 <9.5 10 <11.1 12 <*} \_def \_regoptT {10 <*} \_def \_regoptE {8 <*} \_LMregfont lmrm.r LMRoman?-Regular \_regoptFS % 5-17 \_LMregfont lmrm.bx LMRoman?-Bold \_regoptFT % 5-12 \_LMregfont lmrm.i LMRoman?-Italic \_regoptST % 7-12 \_LMregfont lmrm.bxi LMRoman?-BoldItalic \_regoptT % 10 \_LMregfont lmrm.isl LMRomanSlant?-Regular \_regoptES % 8-17 \_LMregfont lmrm.bxisl LMRomanSlant?-Bold \_regoptT % 10 \_LMregfont lmrm.b LMRomanDemi?-Regular \_regoptT % 10 \_LMregfont lmrm.bi LMRomanDemi?-Oblique \_regoptT % 10 \_LMregfont lmss.r LMSans?-Regular \_regoptES % 8-17 \_LMregfont lmss.bx LMSans?-Bold \_regoptT % 10 \_LMregfont lmss.i LMSans?-Oblique \_regoptES % 8-17 \_LMregfont lmss.bxi LMSans?-BoldOblique \_regoptT % 10 \_LMregfont lmss.b LMSansDemiCond?-Regular \_regoptT % 10 \_LMregfont lmss.bi LMSansDemiCond?-Oblique \_regoptT % 10 \_LMregfont lmsq.r LMSansQuot?-Regular \_regoptE % 8 \_LMregfont lmsq.b LMSansQuot?-Bold \_regoptE % 8 \_LMregfont lmsq.i LMSansQuot?-Oblique \_regoptE % 8 \_LMregfont lmsq.bi LMSansQuot?-BoldOblique \_regoptE % 8 \_LMregfont lmtt.r LMMono?-Regular \_regoptET % 8-12 \_LMregfont lmtt.b LMMonoLt?-Bold \_regoptT % 10 \_LMregfont lmtt.i LMMono?-Italic \_regoptT % 10 \_LMregfont lmtt.bi LMMonoLt?-BoldOblique \_regoptT % 10 \_LMregfont lmtt.isl LMMonoSlant?-Regular \_regoptT % 10 \_optfontalias {lmtt.bisl} {lmtt.bi} \_LMregfont lmtp.r LMMonoPropLt?-Regular \_regoptT % 10 \_LMregfont lmtp.bx LMMonoPropLt?-Bold \_regoptT % 10 \_LMregfont lmtp.i LMMonoPropLt?-Oblique \_regoptT % 10 \_LMregfont lmtp.bxi LMMonoPropLt?-BoldOblique \_regoptT % 10 \_LMregfont lmtp.b LMMonoProp?-Regular \_regoptT % 10 \_LMregfont lmtp.bi LMMonoProp?-Oblique \_regoptT % 10 \_LMregfont lmtl.r LMMonoLt?-Regular \_regoptT % 10 \_LMregfont lmtl.i LMMonoLt?-Oblique \_regoptT % 10 \_LMregfont lmtc.r LMMonoLtCond?-Regular \_regoptT % 10 \_LMregfont lmtc.i LMMonoLtCond?-Oblique \_regoptT % 10 \_LMregfont lmrm.rc LMRomanCaps?-Regular \_regoptT % 10 \_LMregfont lmrm.ic LMRomanCaps?-Oblique \_regoptT % 10 \_LMregfont lmtt.rc LMMonoCaps?-Regular \_regoptT % 10 \_LMregfont lmtt.ic LMMonoCaps?-Oblique \_regoptT % 10 \_LMregfont lmmu.r LMRomanUnsl?-Regular \_regoptT % 10 \_LMregfont lmdu.r LMRomanDunh?-Regular \_regoptT % 10 \_LMregfont lmdu.sl LMRomanDunh?-Oblique \_regoptT % 10 % main modifiers (they select a subfamily) \_moddef \resetmod {\_fsetV subfam=rm \_fvars r bx i bxi } \_moddef \sans {\_fsetV subfam=ss \_fvars r bx i bxi } \_moddef \quotset {\_fsetV subfam=sq \_fvars r b i bi } \_moddef \ttset {\_fsetV subfam=tt \_fvars r b i bi } \_moddef \ttprop {\_fsetV subfam=tp \_fvars r b i bi } \_moddef \ttlight {\_fsetV subfam=tl \_fvars r . i . } \_moddef \ttcond {\_fsetV subfam=tc \_fvars r . i . } \_moddef \upital {\_fsetV subfam=mu \_fvars r . . . } \_moddef \dunhill {\_fsetV subfam=du \_fvars r . sl . } % submodifiers (they select special vaiants in a subfamily) \_moddef \nbold {\_onlyif subfam=rm,ss,tp: {\_fvars r b i bi }} \_moddef \bolder {\_onlyif subfam=rm,ss,tp: {\_fvars r bx i bxi }} \_moddef \slant {\_onlyif subfam=rm: {\_fvars r bx isl bxisl }% \_onlyif subfam=tt: {\_fvars r b isl bisl }} \_moddef \caps {\_onlyif subfam=rm,tt: {\_fvars rc . ic . }} \_def \_tryloadtt {\_fontdef\_tentt{\_LMfonts \_addto\_fontfeatures{-tlig;}\_ttset \_rm}} \_private \LMfonts \ttset ; % used in \_tryloadtt \_initfontfamily % new font family must be initialized \_loadmath {[latinmodern-math]} \_endcode \secc How to write the font family file with optical sizes You can use \^`\_optname` macro when `\_fontnamegen` in expanded. This macro is fully expandable and its input is `` and its output is a part of the font file name `` with respect to given optical size. You can declare a collection of ``s for one given `` by the \^`\_regoptsizes` macro. The syntax is shown for one real case: \begtt \_regoptsizes lmr.r lmroman?-regular 5 <5.5 6 <6.5 7 <7.5 8 <8.5 9 <9.5 10 <11.1 12 <15 17 <* \endtt In general: \begtt \catcode`\<=13 \_regoptsizes \endtt Suppose our example above. Then `\_optname{lmr.r}` expands to lmroman?-regular where the question mark is substituted by a number depending on current `\_optsize`. If the `\_optsize` lies between two boundary values (they are prefixed by \code{<} character) then the number written between them is used. For example if $11.1 \lt `\_optsize` \le 15$ then 12 is substituted instead question mark. The virtually begins with zero \code{<0}, but it is not explicitly written. The right part of must be terminated by \code{<*} which means "less than infinity". If `\_optname` gets an argument which is not registered then it expands to `\_failedoptname` which typically ends to error message about missing font. You can redefine `\_failedoptname` macro to some existing font if you find it useful. We are using a special macro `\_LMregfont` in `f-lmfonts.opm`. It sets the file names to lowercase and enables to use a shortcasts isntead real . There are shortcats `\_regoptFS`, `\_regoptT`, etc. here. The collection of `` are declared, each of them covers a collection of real file names. The \^`\_optfontalias` `{} {}` declares `` with the same meaning as previously declared ``. The `\_optname` macro can be used even if no otical sizes are provided by a font family. Suppose that font file names are much more chaotic (because artists are very creative people), so you need to declare more systematic `` and do an alias from each `` to ``. For example, you can do it as follows: \begtt \def\fontalias #1 #2 {\_regoptsizes #1 ?#2 {} <*} % alias name real font name \fontalias crea-a-regular {Creative Font} \fontalias crea-a-bold {Creative FontBold} \fontalias crea-a-italic {Creative olique} \fontalias crea-a-bolditalic {Creative Bold plus italic} \fontalias crea-b-regular {Creative Regular subfam} \fontalias crea-b-bold {Creative subfam bold} \fontalias crea-b-italic {Creative-subfam Oblique} \fontalias crea-b-bolditalic {Creative Bold subfam Oblique} \endtt