diff options
Diffstat (limited to 'Master/texmf-dist/tex/optex/base/fonts-resize.opm')
-rw-r--r-- | Master/texmf-dist/tex/optex/base/fonts-resize.opm | 66 |
1 files changed, 47 insertions, 19 deletions
diff --git a/Master/texmf-dist/tex/optex/base/fonts-resize.opm b/Master/texmf-dist/tex/optex/base/fonts-resize.opm index ac0064df105..7d1ce6cbedc 100644 --- a/Master/texmf-dist/tex/optex/base/fonts-resize.opm +++ b/Master/texmf-dist/tex/optex/base/fonts-resize.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \setfontsize {Font resizing macros <2020-04-17>} % preloaded in format +\_codedecl \setfontsize {Font resizing macros <2021-04-17>} % preloaded in format \_doc ----------------------------- The \`\setfontsize` `{<sizespec>}` saves the `<sizespec>` to the \`\_sizespec` macro. @@ -34,27 +34,36 @@ \_doc ----------------------------- \`\_resizefont` `{<variant-name>}\<font switch>`, - for example `\resizefont{bf}\_tenbf` resizes the font given by the - variant. The variant `XX` have its font switch `\_tenXX`. - The \`\_doresizefont``\fontswitch` is used. It works in - TFM mode (\`\_doresizetfmfont`) or OTF mode (\^`\_doresizeunifont`). - In both modes, it does - \begtt \catcode`\<=13 - \_font \_tenXX = <fontname> \_sizespec + resizes the font given by the variant. + The <variant-name> is `rm` or `bf` or `it` or `bi`. + The new <font-switch> is declared (roughly speaking) by: + \begtt \catcode`<=13 + \_font <font switch> = <fontname of>\_ten<variant-name> \_sizepec + \endtt + If the \^`\_fontselector` is defined then it has priority before <font-switch> + and the font is loaded by: + \begtt \catcode`<=13 + \_ea\_font \_fontselector = <fontname of>\_ten<variant-name> \_sizepec \endtt - The `<fontname>` is generated by the `\fontname` \TeX/ primitive where - \`\_rfontskipat` removes the `at<dimen>` part of the `\_fontname` output. - The `<fontname>` is generated differently in OTF mode, see + The font is loaded by \`\_doresizefont``<font switch>`. This macro has + meaning \`\_doresizetfmfont` in TFM mode and it switches to + \^`\_doresizeunifont` when \^`\initunifonts` is used.\nl + The `<fontname of>` is generated by the `\fontname` \TeX/ primitive where + \`\_rfontskipat` removes the `at<dimen>` part of the `\fontname` output. + The `<fontname of>` is generated differently in OTF mode, see \^`\_doresizeunifont` macro.\nl - The \`\_whatresize` is defined as `<variant-name>`. + The \`\_whatresize` is defined as `<variant-name>`.\nl + The \^`\_fontloaded``<font switch>` is a macro which can be used for + post-processing when a font is loaded. \_cod ----------------------------- \_def\_resizefont#1#2{% - \_edef\_whatresize{#1}% - \_ifx \_fontselector \_undefined \_doresizefont#2% - \_else \_ea \_doresizefont \_fontselector \_fi - \_lastmagsize=\_zo - \_slet{_tryload#1}{_relax}% + \_edef\_whatresize{#1}% + \_ifx \_fontselector \_undefined + \_doresizefont#2\_relax \_ea\_fontloaded \_csname _ten#1\_endcsname + \_else \_ea\_doresizefont \_fontselector \_ea\_fontloaded \_fontselector \_fi + \_lastmagsize=\_zo + \_slet{_tryload#1}{_relax}% } \_def\_doresizetfmfont#1{\_logfont{#1}% \_ea\_font\_ea#1\_ea\_rfontskipat @@ -68,6 +77,24 @@ \_def\_rfskipatN #1 #2\_relax{\_whichtfm{#1}} \_doc ----------------------------- + If a font is loaded by \^`\_resizefont` or \^`\resizethefont` then the + \`\_fontloaded``<font switch>` is called immediately after it. If the font + is loaded first then its `\skewchar` is equal to $-1$. We run + \`\_newfontloaded``<font switch>` and set `\skewchar=-2` in this case. + A user can define a `\_newfontloaded` macro. We are sure that + `\_newfontloaded` macro is called only once for each instance of the font + given by its name, OTF features and size specification. The `\skewchar` value is + globally saved to the font (like `\fontdimen`). If it is used in math + typesetting then it is set to a positive value.\nl + The `\_newfontloaded` should be defined for micro-typographic configuration of + fonts, for example. See + \ulink[http://petr.olsak.net/optex/optex-tricks.html\#fontexpand]{OpTeX/ trick 0058}. + \_cod ----------------------------- + +\_def\_fontloaded #1{\_ifnum\_skewchar#1=-1 \_skewchar#1=-2 \_newfontloaded#1\_fi} +\_def\_newfontloaded #1{} + + \_doc ----------------------------- \`\fontdef` `<font switch>{<modifiers><variant selector>}` opens group, runs `<modifiers><variant selector>` (i.e.\ it runs `#2` parameter). The font switch `#1` saved in the \`\_fontselector` macro is re-declared @@ -110,7 +137,7 @@ \_def \_newcurrfontsize #1{% \newcurrfontsize{at25pt} \_edef\_tmp{\_ea\_csstring \_the\_font}% \_ea \_fontlet \_csname \_tmp\_ea\_endcsname \_the\_font \_space #1\_relax - \_csname \_tmp\_endcsname + \_ea\_fontloaded \_csname \_tmp \_ea\_endcsname \_csname \_tmp\_endcsname } \_protected\_def \_resizethefont{\_newcurrfontsize\_sizespec} @@ -127,7 +154,7 @@ \_loadf{it}\_tenit \_loadf{bi}\_tenbi } \_def\_loadf#1#2{\_sdef{_tryload#1}{\_ifmmode \_else \_resizefont{#1}#2\_fi}} -\_def\_tryloadtt{\_resizefont{tt}\_tentt} +\_def\_tryloadtt{\_resizefont{tt}\_tentt} % only in TFM mode \_let\_tryloadrm=\_relax \_let\_tryloadbf=\_relax @@ -350,5 +377,6 @@ and OTF Latin Modern fonts in the `f-lmfonts.opm` file. \_endinput +2021-04-17 \_fontloaded, \_newfontloaded introduced 2020-04-17 \resizethefont introduced 2020-03-17 released |