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 | 151 |
1 files changed, 11 insertions, 140 deletions
diff --git a/Master/texmf-dist/tex/optex/base/fonts-resize.opm b/Master/texmf-dist/tex/optex/base/fonts-resize.opm index 7d1ce6cbedc..68ebf763db4 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 <2021-04-17>} % preloaded in format +\_codedecl \setfontsize {Font resizing macros <2021-05-02>} % preloaded in format \_doc ----------------------------- The \`\setfontsize` `{<sizespec>}` saves the `<sizespec>` to the \`\_sizespec` macro. @@ -33,75 +33,6 @@ \_public \setfontsize \defaultoptsize ; \_doc ----------------------------- - \`\_resizefont` `{<variant-name>}\<font switch>`, - 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 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>`.\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\_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 - \_fontname \_cs{_ten\_whatresize} \_relax\_space \_sizespec \_relax -} -\_let\_doresizefont=\_doresizetfmfont -\_def\_logfont#1{} % default is no logging of used fonts - -\_def\_rfontskipat#1{\_ifx#1"\_ea\_rfskipatX \_else\_ea\_rfskipatN\_ea#1\_fi} -\_def\_rfskipatX #1" #2\_relax{"\_whichtfm{#1}"} -\_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 - because the variant selector runs the \^`\_resizefont`. Now, we need to - keep the current meaning of the font switch `#1` but we must leave the - opened group. This is done by the \`\_keepmeaning` macro. - \nl \`\fontlet` `<font switch A> <font switch B> <size spec>` does \begtt \catcode`\<=13 \font <font switch A> = <fontname> <sizespec> @@ -109,18 +40,10 @@ The `<fontname>` is extracted using the primitive command `\_fontname <font switch B>`. \_cod ----------------------------- -\_def \_fontdef #1#2{\_begingroup - \_ifx\_fontselector\_undefined \_def\_fontselector{#1}\_fi - \_reloading #2% - \_ea \_keepmeaning \_fontselector \_endgroup -} \_def\_fontlet#1#2{\_ifx #2=\_ea\_fontlet \_ea#1\_else - \_ea\_font\_ea#1\_ea\_rfontskipat\_fontname#2 \_relax\_space \_fi + \_ea\_font\_ea#1\_ea\_rfontskipat\_fontname#2 \_relax\_space \_fi } -\_def \_keepmeaning #1#2{\_global\_let\_keepmeaningdata=#1% - #2\_let#1=\_keepmeaningdata \_global\_let\_keepmeaningdata=\_undefined -} -\_public \fontdef \fontlet ; +\_public \fontlet ; \_doc ----------------------------- \`\newcurrfontsize` `<size spec>` sets current font size to the `<size spec>` @@ -144,39 +67,6 @@ \_public \newcurrfontsize \resizethefont ; \_doc ----------------------------- - The variant selector is defined by `\protected\def\XX{\_tryloadXX \_tenXX}` - The `\_tryloadXX` can be in `\_relax` state if no font modifiers were - declared. But normally it does \^`\_resizefont``{XX}\tenXX`. This meaning - is activated by the \`\_reloading` macro. - \_cod ----------------------------- - -\_def\_reloading{\_loadf{rm}\_tenrm \_loadf{bf}\_tenbf - \_loadf{it}\_tenit \_loadf{bi}\_tenbi -} -\_def\_loadf#1#2{\_sdef{_tryload#1}{\_ifmmode \_else \_resizefont{#1}#2\_fi}} -\_def\_tryloadtt{\_resizefont{tt}\_tentt} % only in TFM mode - -\_let\_tryloadrm=\_relax -\_let\_tryloadbf=\_relax -\_let\_tryloadit=\_relax -\_let\_tryloadbi=\_relax - - \_doc ---------------------------- - The font selection system allows to use \`\currvar` - instead explicitly specified variant selector. The current variant - is extracted from `\the\font` output which could be `\_tenXX` control - sequence. Then `\currvar` expands to `\_rm` or `\_it` etc. - \_cod ---------------------------- - -\_protected \_def \_currvar{\_cs{_currvar:\_ea \_csstring \_the\_font}} -\_sdef{_currvar:_tenrm}{\_rm} -\_sdef{_currvar:_tenbf}{\_bf} -\_sdef{_currvar:_tenit}{\_it} -\_sdef{_currvar:_tenbi}{\_bi} -\_sdef{_currvar:_tentt}{\_tt} -\_public \currvar ; - - \_doc ----------------------------- The \`\_regtfm` `<font id> <optical size data>` saves the <optical size data> concerned to `<font id>`. The `<optical size data>` is in the form as shown below in the code where @@ -232,14 +122,17 @@ \_regtfm lmri 0 ec-lmri7 7.5 ec-lmri8 8.5 ec-lmri9 9.5 ec-lmri10 11.1 ec-lmri12 * \_regtfm lmtt 0 ec-lmtt8 8.5 ec-lmtt9 9.5 ec-lmtt10 11.1 ec-lmtt12 * -\_setfontsize {at10pt} % default font size - \_endcode %--------------------------------------------------- \sec[setfontsize] Scaling fonts in text mode (low-level macros) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +This section describes single part of Font Selection System: resizing fonts +to various sizes. This feature is available in both modes: TFM mode +(initialized when format starts) and OTF mode (after \~`\fontfam` or +\~`\initunifonts` is used). + \secc The `\setfontsize` macro The \^`\setfontsize` `{<size spec>}` @@ -310,28 +203,6 @@ these features by the \^`\initunifonts` command explicitly, for example: \cyklop The 12 pt text is here \endtt -\secc[fontdef] The \code{\\fontdef} declarator - -You can declare `\<newfont>` by the \~`\fontdef` command. - -\begtt \catcode`\<=13 - \fontdef \<newfont> {<font modifiers> \<variant-selector>} - example: - \fontdef \bigfont {\setfontsize{at15pt}\bf} -\endtt -% -This command runs `<font modifiers> \<variant-selector>` in an internal group and sets the -resulting selected font as `\<newfont>`. - -The resulting `\<newfont>` declared by \~`\fontdef` is \"fixed font switch" -independent of \^`\setfontsize` and other font modifiers. More exactly, it is -a fixed font switch when it is used but it can depend on the current font -modifiers and font family and given font modifiers when it is declared. - -The parameter of the \~`\fontdef` macro must be exactly finished by the -variant selector. More information about font modifiers -and variant selectors are in the section~\ref[fontsystem]. - \secc[fontlet] The \code{\\fontlet} declarator We have another command for scaling: \^`\fontlet` which can resize @@ -370,13 +241,13 @@ of the `\defaultoptsize` register and such font is scaled by the specified Font collections with optical sizes must be registered by the \^`\_regtfm` for `tfm` files or \^`\_regoptsizes` for Unicode fonts. -\OpTeX/ registers 8bit Latin Moder fonts in the format (`fonts-resize.opm` file) +\OpTeX/ registers 8bit Latin Modern fonts in the format and OTF Latin Modern fonts in the `f-lmfonts.opm` file. - -\secc Implementation notes +See also section~\ref[optsizes]. \_endinput +2021-05-02 better concept of doc, moving parts to fonts-select 2021-04-17 \_fontloaded, \_newfontloaded introduced 2020-04-17 \resizethefont introduced 2020-03-17 released |