From a5ae129f3aa3a3a0aeaa21c55b75a1d543fe4111 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 4 Jun 2021 03:02:48 +0000 Subject: CTAN sync 202106040302 --- macros/optex/README | 10 +- macros/optex/base/alloc.opm | 2 +- macros/optex/base/basic-macros.opm | 7 +- macros/optex/base/cite-bib.opm | 4 +- macros/optex/base/colors.opm | 30 +- macros/optex/base/doc.opm | 150 ++++++-- macros/optex/base/f-erewhon.opm | 31 ++ macros/optex/base/f-heros.opm | 7 +- macros/optex/base/f-lmfonts.opm | 2 +- macros/optex/base/fams-ini.opm | 5 +- macros/optex/base/fnotes.opm | 2 +- macros/optex/base/fonts-opmac.opm | 2 +- macros/optex/base/fonts-preload.opm | 2 +- macros/optex/base/fonts-resize.opm | 151 +------- macros/optex/base/fonts-select.opm | 314 +++++++++++++---- macros/optex/base/hyperlinks.opm | 203 ++++++----- macros/optex/base/languages.opm | 7 +- macros/optex/base/makeindex.opm | 2 +- macros/optex/base/math-macros.opm | 1 + macros/optex/base/multicolumns.opm | 9 +- macros/optex/base/optex.ini | 2 +- macros/optex/base/optex.lua | 2 - macros/optex/base/styles.opm | 62 +--- macros/optex/base/table.opm | 94 +++-- macros/optex/base/usebib.opm | 5 +- macros/optex/doc/mte-doc.tex | 26 ++ macros/optex/doc/optex-doc.pdf | Bin 1405606 -> 1383214 bytes macros/optex/doc/optex-doc.tex | 11 +- macros/optex/doc/optex-techdoc.tex | 6 +- macros/optex/doc/optex-userdoc.tex | 12 +- macros/optex/pkg/emoji.opm | 4 +- macros/optex/pkg/mte.opm | 685 ++++++++++++++++++++++++++++++++++++ macros/optex/pkg/vlna.opm | 4 +- 33 files changed, 1406 insertions(+), 448 deletions(-) create mode 100644 macros/optex/base/f-erewhon.opm create mode 100644 macros/optex/doc/mte-doc.tex create mode 100644 macros/optex/pkg/mte.opm (limited to 'macros/optex') diff --git a/macros/optex/README b/macros/optex/README index d3a5becec4..61c4698328 100644 --- a/macros/optex/README +++ b/macros/optex/README @@ -17,8 +17,14 @@ pkg/ ... external macros. Maybe, they can be created by other authors if in the OpTeX documentation. doc/ ... PDF version of the OpTeX documentation and sources. -History: - +<1.03> Jun. 2021: + mte: Package for MicroTypographic Extensions released. + Erewhon: font family support added. + \rgbcmykmap for RGB-CMYK mapping introduced. + \table: sum of \tsizes allowed different from one. + doc: hyperlinks from Index created. + \url and \link macros re-written. + Bugs fixing. <1.02> Apr. 2021 Location CTAN:macros/luatex/optex moved to CTAN:macros/optex (similarly for TDS). NewComputerModern font support added. diff --git a/macros/optex/base/alloc.opm b/macros/optex/base/alloc.opm index 5d874134d4..13252cae70 100644 --- a/macros/optex/base/alloc.opm +++ b/macros/optex/base/alloc.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \newdimen {Allocators for registers <2021-02-15>} % loaded in format +\_codedecl \newdimen {Allocators for registers <2021-02-15>} % preloaded in format \_doc ----------------------------- The limits are set first. diff --git a/macros/optex/base/basic-macros.opm b/macros/optex/base/basic-macros.opm index 4d465c3010..57393fc323 100644 --- a/macros/optex/base/basic-macros.opm +++ b/macros/optex/base/basic-macros.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \sdef {Basic macros for OpTeX <2021-02-03>} % loaded in format +\_codedecl \sdef {Basic macros for OpTeX <2021-05-16>} % preloaded in format \_doc ------------------------------ \`\bgroup`, \`\egroup`, \`\empty`, \`\space`, \`\null` and \`\wlog` @@ -51,7 +51,9 @@ \_def \_sdef #1{\_ea\_def \_csname#1\_endcsname} \_def \_sxdef #1{\_ea\_xdef \_csname#1\_endcsname} -\_def \_slet #1#2{\_ea\_let \_csname#1\_ea\_endcsname \_csname#2\_endcsname} +\_def \_slet #1#2{\_ea\_let \_csname#1\_ea\_endcsname + \_ifcsname#2\_ea\_endcsname \_begincsname#2\_endcsname \_else \_undefined \_fi +} \_public \sdef \sxdef \slet ; \_doc ------------------------------ @@ -123,6 +125,7 @@ \_endcode % ------------------------------------- +2021-05-16: \slet reimplemnted (to allow \slet{foo}{undefined}). 2021-02-03: \useit defined. 2021-01-22: \trycs: \ea added in order to be able to use cs with parameters 2021-01-08: \opwarning format changed (secondly, hope that conclusively) diff --git a/macros/optex/base/cite-bib.opm b/macros/optex/base/cite-bib.opm index 56954a4ee0..adef0eaef8 100644 --- a/macros/optex/base/cite-bib.opm +++ b/macros/optex/base/cite-bib.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \cite {Cite, Biblioraphy <2021-04-13>} % loaded in format +\_codedecl \cite {Cite, Biblioraphy <2021-04-13>} % preloaded in format \_doc ----------------------------- Registers used by `\cite`, `\bib` macros are declared here. @@ -280,7 +280,7 @@ \_def\usebib{\_usebib} \_doc ------------------------------ - \_forwardlink\`\nobibwarning` `[]` + \_fw\`\nobibwarning` `[]` declares a list of bib labels which are not fully declared in `.bib` file but we want to suppress the warning about it. List of bib labels are comma-separated case sensitive diff --git a/macros/optex/base/colors.opm b/macros/optex/base/colors.opm index bbda496761..23ec22dd9f 100644 --- a/macros/optex/base/colors.opm +++ b/macros/optex/base/colors.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \colordef {Colors <2020-03-18>} % loaded in format +\_codedecl \colordef {Colors <2021-05-28>} % preloaded in format \_doc ----------------------------- We declare internal boolean value \`\_iflocalcolor` ad do @@ -129,9 +129,12 @@ to they are in $[0,1]$ interval. The `\colordefFin` expands to the values accumulated in Lua code `color_C`, `color_M`, `color_Y` and `color_K`. The `\_douseK` applies \^`\useK` to CMYK components. + \nl + The `\_tocmyk:` or `\_torgb:` control sequences (given by + \^`\rgbcmykmap`) have precedence. \_cod ----------------------------- -\_def\_rgbtocmyk #1 #2 #3 ;{% +\_def\_rgbtocmyk #1 #2 #3 ;{\_trycs{_tocmyk:#1 #2 #3}{% \_ea \_stripzeros \_detokenize \_ea{\_directlua{ local kr = math.max(#1,#2,#3) if (kr==0) then @@ -140,13 +143,13 @@ tex.print(string.format('\_pcent.3f \_pcent.3f \_pcent.3f \_pcent.3f ;', (kr-#1)/kr, (kr-#2)/kr, (kr-#3)/kr, 1-kr)) end -}}} -\_def\_cmyktorgb #1 #2 #3 #4 ;{% +}}}} +\_def\_cmyktorgb #1 #2 #3 #4 ;{\_trycs{_torgb:#1 #2 #3 #4}{% \_ea \_stripzeros \_detokenize \_ea{\_directlua{ local kr = 1-#4 tex.print(string.format('\_pcent.3f \_pcent.3f \_pcent.3f ;', (1-#1)*kr, (1-#2)*kr, (1-#3)*kr)) -}}} +}}}} \_def\_colorcrop{\_directlua{ local m=math.max(color_C, color_M, color_Y, color_K) if (m>1) then @@ -180,6 +183,19 @@ \_def\_stripzeroB #10 #2:{\_ifx^#2^\_stripzeroC#1:\_else #1\_fi} \_def\_stripzeroC #1 #2:{#1} + \_doc ----------------------------- + \`\rgbcmykmap` `{ }`\,`{ }` declares mapping from + RGB to CMYK and from CMYK to RGB for given color. It has precedence + before general formulae used in the \^`\_rgbtocmyk` and \^`\_cmyktorgb` + macros. Note, that the values must be given + exacly in the same format as in \^`\setcmykcolor` and \^`\setrgbcolor` + parameters. For example, `0.5` or `.5` or `.50` are different values from + point of view of this mapping. + \_cod ----------------------------- + +\_def\_rgbcmykmap#1#2{\_sxdef{_torgb:#2}{#1}\_sxdef{_tocmyk:#1}{#2}} +\_public \rgbcmykmap ; + \_doc ----------------------------- The \`\rgbcolordef` and \`\cmykcolordef` use common macro \`\_commoncolordef` with different first four parameters. @@ -373,7 +389,8 @@ The \^`\rgbcolordef` can be used to mix colors in additive color model RGB. If \^`\onlyrgb` is declared, then \^`\colordef` works as \^`\rgbcolordef`. If a CMYK to RGB or RGB to CMYK conversion is needed then -the following simple formulae are used +direct conversion of given color is used (if declared using +\^`\rgbcmykmap``{}{}`) or the following simple formulae are used (ICC profiles are not supported): $$ \displaylines{ @@ -390,5 +407,6 @@ and it is used in \^`\rgbcolordef` or if it is printed when \^`\onlyrgb` is decl \_endinput +2021-05-28 \rgbcmykmap introduced 2020-04-22 \replstring\tmpb{+ }{+}, {- }{-} added in \colordef, bug fixed 2020-03-18 introduced diff --git a/macros/optex/base/doc.opm b/macros/optex/base/doc.opm index ce571a9e81..643a283e7c 100644 --- a/macros/optex/base/doc.opm +++ b/macros/optex/base/doc.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \printdoc {Macros for documentation printing <2020-04-28>} +\_codedecl \printdoc {Macros for documentation printing <2021-05-15>} % loaded on demand by \load[doc] \_doc ----------------------------- General decalarations. @@ -34,6 +34,8 @@ \_doc ----------------------------- The listing mode is implemented here. The \`\maxlines` is maximal lines of code printed in the listing mode. + The \`\_catcodedot` sets dot as letter in listngs (for package + documentation where `\.foo` sequeces exist). \_cod ----------------------------- \_newcount \_maxlines \_maxlines=100000 @@ -45,9 +47,10 @@ \_typosize[8/10] \_let\_printverbline=\_printcodeline \_ttline=\_inputlineno - \_setverb + \_setverb \_catcodedot \_ifnum\_ttline<0 \_let\_printverblinenum=\_relax \_else \_initverblinenum \_fi \_adef{ }{\ }\_adef\^^I{\t}\_parindent=\_ttindent \_parskip=0pt + \_def\t{\_hskip \_dimexpr\_tabspaces em/2\_relax}% \_relax \_ttfont \_endlinechar=`^^J \_def\_tmpb{\_start}% @@ -57,27 +60,38 @@ \_def\_tmpa{\_empty#1}% \_let\_next=\_readverbline \_ea\_isinlist\_ea\_tmpa\_ea{\_Doc}\_iftrue \_let\_next=\_processinput \_fi - \_ea\_isinlist\_ea\_tmpa\_ea{\_Endcode}\_iftrue \_endinput \_let\_next=\_processinput \_fi + \_ea\_isinlist\_ea\_tmpa\_ea{\_Doctab}\_iftrue \_let\_next=\_processinput \_fi + \_ea\_isinlist\_ea\_tmpa\_ea{\_Endcode}\_iftrue \_def\_next{\_processinput\_endinput}\_fi \_ifx\_next\_readverbline \_addto\_tmpb{#1^^J}\_fi \_next } {\_catcode`\ =13 \_gdef\_aspace{ }}\_def\_asp{\_ea\_noexpand\_aspace} \_edef\_Doc{\_asp\_asp\_bslash _doc} +\_bgroup \_lccode`~=`\^^I \_lowercase{\_egroup\_edef\_Doctab{\_noexpand~\_bslash _doc}} \_edef\_Endcode{\_noexpand\_empty\_bslash _endcode} +\_def\_catcodedot{\_catcode`\.=11 } \_doc ----------------------------- - The scanner of the control sequences in the listing mode. + The scanner of the control sequences in the listing mode replaces all + occurrences of `\` by \`\_makecs`. This macro reads next tokens and + accumulates them to `\_tmpa` as long as they have category 11. It + means that `\_tmpa` includes the name of the following control sequence + when \fw\`\_makecsF` is run. The printing form of the control + sequence is set to `\_tmpb` and the test of existence `\,`is + performed. If it is true then active hyperlink is created. If not, then + the first `_` or `.` is removed from `\_tmpa` and the test is repeated. \_cod ----------------------------- -\_def\_makecs{\_def\_tmp{}\_futurelet\_next\_makecsA} +\_def\_makecs{\_def\_tmpa{}\_futurelet\_next\_makecsA} \_def\_makecsA{\_ifcat a\_noexpand\_next \_ea\_makecsB \_else \_ea\_makecsF \_fi} -\_def\_makecsB#1{\_addto\_tmp{#1}\_futurelet\_next\_makecsA} -\_def\_makecsF{\_ifx\_tmp\_empty \_csstring\\% - \_else \_ifcsname ,\_tmp\_endcsname \_link[cs:\_tmp]{\Blue}{\_csstring\\\_tmp}% - \_else \_let\_next=\_tmp \_remfirstunderscore\_next - \_ifx\_next\_empty \_let\_next=\_tmp \_fi - \_ifcsname ,\_next\_endcsname \_link[cs:\_next]{\Blue}{\_csstring\\\_tmp}% - \_else \_csstring\\\_tmp \_fi\_fi\_fi +\_def\_makecsB#1{\_addto\_tmpa{#1}\_futurelet\_next\_makecsA} +\_def\_makecsF{\_let\_tmpb=\_tmpa + \_ifx\_tmpa\_empty \_csstring\\% + \_else \_ifcsname ,\_tmpa\_endcsname \_trycs{el:\_tmpa}{\_intlink}% + \_else \_remfirstunderscoreordot\_tmpa + \_ifx\_tmpa\_empty \_let\_tmpa=\_tmpb \_fi + \_ifcsname ,\_tmpa\_endcsname \_trycs{el:\_tmpa}{\_intlink}% + \_else \_csstring\\\_tmpb \_fi\_fi\_fi } \_def\_processinput{% \_let\_start=\_relax @@ -96,8 +110,18 @@ \_endgroup \_ttskip \_isnextchar\_par{}{\_noindent}% } -\_def\_remfirstunderscore#1{\_ea\_remfirstunderscoreA#1\_relax#1} -\_def\_remfirstunderscoreA#1#2\_relax#3{\_if _#1\_def#3{#2}\_fi} +\_def\_remfirstunderscoreordot#1{\_ea\_remfirstuordotA#1\_relax#1} +\_def\_remfirstuordotA#1#2\_relax#3{\_if _#1\_def#3{#2}\_fi \_if\_string#1.\_def#3{#2}\_fi} + + \_doc ----------------------------- + By default the internal link is created by \`\_intlink` inside listing + mode. But you can define `\el:` which has precedence and it can + create an external link. The `\_tmpa` includes the name used in the link + and `\_tmpb` is the name to be printed. See \^`\_makecsF` above and the + example at the beginning of this section. + \_cod ----------------------------- + +\_def\_intlink{\_link[cs:\_tmpa]{\Blue}{\_csstring\\\_tmpb}} \_doc ----------------------------- The lines in the listing mode have a yellow background. @@ -166,6 +190,16 @@ \_sdef{_tocl:1}#1#2#3{\_nofirst\_bigskip \_bf\_llaptoclink{#1}{#2}\_hfill \_pgn{#3}\_tocpar\_medskip} + \_doc ----------------------------- + If this macro is loaded by \^`\load` then we need to initialize + catcodes using the `\_afteroad` macro. + \_cod ----------------------------- + +\_def\_afterload{\_catcode`\<=13 \_catcode`\`=13 \_catcode`\.=11 + \_wlog {doc.opm: catcodes of < and ` activated, catcode of . is letter.}% +} +\_catcode`.=11 + \_doc ----------------------------- The \code{} will be print as . \_cod ----------------------------- @@ -176,21 +210,12 @@ \_def<#1>{$\langle\hbox{\it#1\/}\rangle$} \_everyintt{\_catcode`\<=13 } - \_doc ----------------------------- - If this macro is loaded by \^`\load` then we need to initialize - catcodes using the `\_afteroad` macro. - \_cod ----------------------------- - -\_def\_afterload{\_catcode`\<=13 \_catcode`\`=13 } - \_doc ----------------------------- Main documentation points and hyperlinks to/from it. Main documentation point: \code{\\`\\foo`}. - User-level documentation point: \code{\\^`\\foo}, first occurence only. + User documentation point: \code{\\^`\\foo}, first occurence only. The next occurrences are only links to the main documentation point. - Link to user-level documentation point: \code{\\~`\\foo}. - If user-level documentation point follows the main documentation point - then use \code{\\_forwardlink\\`\\foo`}. + Link to user documentation point: \code{\\~`\\foo}. \_cod ----------------------------- \_verbchar` @@ -202,8 +227,6 @@ \_link[cs:^\_tmp]{\Red}{\_tt\_csstring\\\_tmp}\_else {\_tt\Red\_csstring\\\_tmp}\_fi}% } -\_def\_forwardlink\`#1`{{\_slet{cs:^\_csstring#1}{relax}\`#1`}} - \_def\^`#1{\_leavevmode\_edef\_tmp{\_csstring#1}\_iindex{\_tmp}% \_hbox{\_ifcsname cs:^\_tmp\_endcsname \_else \_dest[cs:^\_tmp]\_sxdef{cs:^\_tmp}{}\_fi \_link[cs:\_tmp]{\Blue}{\_tt\_string#1}}% @@ -216,6 +239,14 @@ \_futurelet\_next\_cslinkA } + \_doc ----------------------------- + The \`\fw` macro for forward links to user documentation point (given later) + is defined here. + \_cod ----------------------------- + +\_def\_fw\`#1`{{\_slet{cs:^\_csstring#1}{}\`#1`}} +\_public \fw ; + \_endcode %------------------------------------------- \noindent @@ -225,12 +256,13 @@ commands are defined after the file `doc.opm` is load by \^`\load`~`[doc]`. The `\printcoc` starts reading of given `` from the second line. The file is read in {\em the listing mode}. The `\prindoctail` starts reading given `` from the -first occurrence of the `\_encode`. The file is read +first occurrence of the `\_endcode`. The file is read in normal mode (like `\input `). The {\em listing mode} prints the lines as a listing of a code. This mode is finished when first {\visiblesp` \_doc`} occurs or first `\_endcode` -occurs. At least two spaces must precede before such `\_doc`. On the other +occurs. At least two spaces or one tab +character must precede before such `\_doc`. On the other hand, the `\_encode` must be at the left edge of the line without spaces. If this rule is not met then the listing mode continues. @@ -255,10 +287,6 @@ applied, the reading of the file opened by `\printdoc` is finished. You cannot reach the end of the file (without `\_endcode`) in the listing mode. -The listing mode creates all control sequences which are listed in the -index as an active link to the main documentation point of such control sequence -and prints them in blue. Another text is printed in black. - The main documentation point is denoted by \code{\\`\\}``\code{`} in red, for example \code{\\`\\foo`}. The user documentation point is the first occurrence of @@ -266,11 +294,63 @@ The user documentation point is the first occurrence of There can be more such markups, all of them are hyperlinks to the main documentation point. And main documentation point is a hyperlink to the user documentation point -if this point exists. Finally, the +if this point precedes. Finally, the \code{\\~`\\}``\code{`} (for example \code{\\~`\\foo`}) are hyperlinks to the user documentation point. +By default, the hyperink from main documentation point to the user +documentation point is active only if it is backward link, i.e.\ +the main documentation point is given later. The reason is that we don't +know if such user documentation point will exist when creating +main documentation point and we don't want +broken links. If you are sure that user documentation point will +follow then use prefix \^`\fw` before~\code{\\`}, for example +\code{\\fw\\`\\foo`} is main documentation point where the user +documentation point is given later and forward hyperlink is created here. + +Control sequences and their page positions of main documentation points and user +documentation points are saved to the index. + +The listing mode creates all control sequences which are listed in the +index as an active link to the main documentation point of such control sequence +and prints them in blue. Moreower, active links are control sequneces of the +type `\_foo` or `\.foo` although the documentation mentions only `\foo`. +Another text is printed in black. + +The listing mode is able to generate external links to another \OpTeX/-like +documentation, if the macros `\,` and `\el:` are defined. +The second macro should create a hyperlink using `\_tmpa` +where the link name of the is saved and `\_tmpb` where the name of +the to be printed is saved (`\tmpb` can include preceding `_` or +`.` unlike `\_tmpa`). For example, suppose, that we have created +`optex-doc.eref` file by: +\begtt +TEXINPUTS='.;$TEXMF/{doc,tex}//' optex optex-doc +grep Xindex optex-doc.ref > optex-doc.eref +\endtt +The `.eref` file includes only `\_Xindex{}{}` lines from +`optex-doc.ref` file. Then we can use following macros: +\begtt +\def\_Xindex#1#2{\sdef{,#1}{}\slet{el:#1}{optexdoclink}} +\def\optexdoclink{% + \edef\extlink{url:\optexdocurl\csstring\#cs:\_tmpa}% + \_ea\_urlactive\_ea[\extlink]{\Cyan}{\csstring\\\_tmpb}} +\def\optexdocurl{http://petr.olsak.net/ftp/olsak/optex/optex-doc.pdf} +\isfile{optex-doc.eref}\iftrue \input{optex-doc.eref}\fi +\endtt +All `\el:`, where is from `optex-doc.ref`, +have the same meaning: `\optexdoclink` in this example. And +`\optexdoclink` creates the external link in `\Cyan` color. + +\secc Implementation + \endinput +2021-05-15 \_endinput shifted after \_processinput when \_endcode is scanned. +2021-05-14 \_catcodedot, \_Doctab introduced. +2021-05-13 \def\t added, bug fixed. +2021-05-03 External links fom listing mode allowed. +2021-05-02 \_forwadlink replaced by \_fw, to be more consistent. +2021-05-02 \fw introduced, \.foo -> \foo allowed. 2020-04-28 \levevmode in \^ macros added (bug fixed) -2020-04-22 released \ No newline at end of file +2020-04-22 released diff --git a/macros/optex/base/f-erewhon.opm b/macros/optex/base/f-erewhon.opm new file mode 100644 index 0000000000..11fc55330e --- /dev/null +++ b/macros/optex/base/f-erewhon.opm @@ -0,0 +1,31 @@ +%% This is part of the OpTeX project, see http://petr.olsak.net/optex + +\_famdecl [Erewhon] \Erewhon {Derived from Heuristica with slanted variants} + {\caps} {\rm \bf \it \bi \sl \bs} {Erewhon} + {[Erewhon-Regular]} + {\_def\_fontnamegen {[Erewhon-\_currV]:\_capsV\_fontfeatures}} + +\_wlog{\_detokenize{% +Modifiers:^^J + \caps ...... caps & small caps^^J + \slant ..... slanted Regular, Bold^^J% +Variants:^^J + \sl ... slanted Regular, \sb ... slanted Bold^^J +}} + +\_moddef \resetmod {\_fsetV caps={} \_fvars Regular Bold Italic Bolditalic } +\_moddef \caps {\_fsetV caps=+smcp;\_ffonum; } +\_moddef \slant {\_fvars RegularSlanted BoldSlanted RegularSlanted BoldSlanted } +\_private \slant ; +\_famvardef \sl {\_slant\_rm} +\_famvardef \bs {\_slant\_bf} + +\_initfontfamily % new font family must be initialized + +\_loadmath {[Erewhon-Math]} + +\_endcode + +See the file `f-heros.opm` for information about principles of such +font-macro-files. + diff --git a/macros/optex/base/f-heros.opm b/macros/optex/base/f-heros.opm index 2aec4b466a..2195774b88 100644 --- a/macros/optex/base/f-heros.opm +++ b/macros/optex/base/f-heros.opm @@ -33,6 +33,7 @@ Modifiers:^^J \_let\_bsansdigits=\_bfdigits \_let\_bisansvariables=\_bivariables \_let\_bisansgreek=\_bigreek + \_Umathchardef \triangle "0 "5 "25B3 \_Umathcode "25B3 "0 "5 "25B3 \_fi \_endcode @@ -81,12 +82,12 @@ name) and to optional font features appended. The Font Selection System uses this macro at the primitive level in the following sense: \begtt \catcode`\<=13 -\font \ {\_fontnamegen} \_sizespec +\font \ {\_fontnamegen} \_sizespec \endtt % Note that the extended `\font` syntax -`\font\ {:} ` or -`\font\ {[]:} ` +`\font\ {:} ` or +`\font\ {[]:} ` is expected here. \seccc Example 1 diff --git a/macros/optex/base/f-lmfonts.opm b/macros/optex/base/f-lmfonts.opm index 3b1e0d0c40..5356680e9d 100644 --- a/macros/optex/base/f-lmfonts.opm +++ b/macros/optex/base/f-lmfonts.opm @@ -115,7 +115,7 @@ Note: Text fonts support optical sizes, but LatinModern-Math only for scripts.^^ \_endcode -\secc How to write the font family file with optical sizes +\secc[optsizes] 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 diff --git a/macros/optex/base/fams-ini.opm b/macros/optex/base/fams-ini.opm index 1d4d9f5c59..1d47504fc5 100644 --- a/macros/optex/base/fams-ini.opm +++ b/macros/optex/base/fams-ini.opm @@ -95,6 +95,9 @@ { -,\caps: {\rm\bf\it\bi} } \_famalias [BaskervilleF] +\_faminfo [Erewhon] {Derived from Heuristica with slanted variants} {f-erewhon} + { -: {\rm\bf\it\bi\sl\bs} \caps: {\rm\bf\it\bi} } + \_famfrom {Georg Duffner, Octavio Pardo} \_faminfo [EB Garamond] {Free variants of classical Garamond} {f-ebgaramond} { -,\caps,\medium,\medium\caps,\semibold,\semibold\caps: {\rm\bf\it\bi} @@ -184,7 +187,7 @@ have the original Times purchased from Adobe then you can register your declaration of Adobe's Times family in `fams-local.opm`. When a user writes `\fontfam[Times]` then the original Times (not Termes) is used. -The `fams-ini.opm` and `fams-local.opm` files use the macros +The `fams-ini.opm` and `fams-local.opm` files can use the macros \~`\_faminfo`, \~`\_famalias` and \~`\_famtext`. See the example from `fams-ini.tex`: diff --git a/macros/optex/base/fnotes.opm b/macros/optex/base/fnotes.opm index 1445c57d4c..62912d0400 100644 --- a/macros/optex/base/fnotes.opm +++ b/macros/optex/base/fnotes.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \fnote {Footnotes, marginal notes OpTeX <2020-05-26>} % loaded in format +\_codedecl \fnote {Footnotes, marginal notes OpTeX <2020-05-26>} % preloaded in format \_doc ----------------------------- \`\_gfnotenum` is a counter which counts footnotes globally in the whole document.\nl diff --git a/macros/optex/base/fonts-opmac.opm b/macros/optex/base/fonts-opmac.opm index 3ae2f0c5e1..025df761a5 100644 --- a/macros/optex/base/fonts-opmac.opm +++ b/macros/optex/base/fonts-opmac.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \typosize {Font managing macros from OPmac <2021-03-10>} % loaded in format +\_codedecl \typosize {Font managing macros from OPmac <2021-03-10>} % preloaded in format \_doc ----------------------------- \`\typosize` `[/]` sets given parameters. diff --git a/macros/optex/base/fonts-preload.opm b/macros/optex/base/fonts-preload.opm index 712730436c..d56d5c0a78 100644 --- a/macros/optex/base/fonts-preload.opm +++ b/macros/optex/base/fonts-preload.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \tenrm {Latin Modern fonts (EC) preloaded <2020-01-23>} % loaded in format +\_codedecl \tenrm {Latin Modern fonts (EC) preloaded <2020-01-23>} % preloaded in format % Only few text fonts are preloaded: diff --git a/macros/optex/base/fonts-resize.opm b/macros/optex/base/fonts-resize.opm index 7d1ce6cbed..68ebf763db 100644 --- a/macros/optex/base/fonts-resize.opm +++ b/macros/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` `{}` saves the `` to the \`\_sizespec` macro. @@ -33,75 +33,6 @@ \_public \setfontsize \defaultoptsize ; \_doc ----------------------------- - \`\_resizefont` `{}\`, - resizes the font given by the variant. - The is `rm` or `bf` or `it` or `bi`. - The new is declared (roughly speaking) by: - \begtt \catcode`<=13 - \_font = \_ten \_sizepec - \endtt - If the \^`\_fontselector` is defined then it has priority before - and the font is loaded by: - \begtt \catcode`<=13 - \_ea\_font \_fontselector = \_ten \_sizepec - \endtt - The font is loaded by \`\_doresizefont```. This macro has - meaning \`\_doresizetfmfont` in TFM mode and it switches to - \^`\_doresizeunifont` when \^`\initunifonts` is used.\nl - The `` is generated by the `\fontname` \TeX/ primitive where - \`\_rfontskipat` removes the `at` part of the `\fontname` output. - The `` is generated differently in OTF mode, see - \^`\_doresizeunifont` macro.\nl - The \`\_whatresize` is defined as ``.\nl - The \^`\_fontloaded``` 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``` is called immediately after it. If the font - is loaded first then its `\skewchar` is equal to $-1$. We run - \`\_newfontloaded``` 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` `{}` - opens group, runs `` (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` ` ` does \begtt \catcode`\<=13 \font = @@ -109,18 +40,10 @@ The `` is extracted using the primitive command `\_fontname `. \_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` `` sets current font size to the `` @@ -143,39 +66,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` ` ` saves the concerned to ``. @@ -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` `{}` @@ -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 `\` by the \~`\fontdef` command. - -\begtt \catcode`\<=13 - \fontdef \ { \} - example: - \fontdef \bigfont {\setfontsize{at15pt}\bf} -\endtt -% -This command runs ` \` in an internal group and sets the -resulting selected font as `\`. - -The resulting `\` 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 diff --git a/macros/optex/base/fonts-select.opm b/macros/optex/base/fonts-select.opm index eab114fcc4..5dab510453 100644 --- a/macros/optex/base/fonts-select.opm +++ b/macros/optex/base/fonts-select.opm @@ -1,6 +1,131 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \fontfam {Fonts selection system <2021-04-22>} % preloaded in format +\_codedecl \fontfam {Fonts selection system <2021-05-23>} % preloaded in format + + \_doc ----------------------------- + The variant selectors \^`\rm`, \^`\bf`, \^`\it`, \^`\bi`, \^`\tt` + are defined (roughly speaking) by + \begtt \catcode`\<=13 + \def\ {\_tryload\_ten} + \endtt + where is \"internal variant name" `rm` or `bf` or `it` or `bi` or `tt`. + There are five \"internal font switchers" `\_tenrm`, `\_tenbf`, `\_tenit`, + `\_tenbi` and `\_tentt`. They are used almost for all fonts selected by the Fonts + Selection System. For example, `\_tenbf` is the switcher for bold variant of + the current family in the current font context. The \^`\bf` macro is defined as + `\_tryloadbf \_tenbf`. If the font context (font family, font size, features) + is not changed, then `\_tryloadbf` is `\relax` and `\_tenbf` font switcher selects + given font. If the font context is changed, then `\_tryloadbf` is re-defined (see + \^`\_reloading` macro) to load new bold varinat of the font using \^`\_resizefont` + The loaded font is saved to `\_tenbf` switcher and `\_tryloadbf` returns + back to the `\relax` meaning. So, `\bf` macro loads + new font with current font context and then selects it by `\_tenbf` + selector. The word \"ten" is used here + only for historical reason; the font can be at arbitrary size. + \nl + The \`\_reloading` macro is run whenever font context is changed. + It activates `\_tryload` for `` in `rm`, `bf`, `it` and `bi`. + The \`\_loadf``{}\ten` is processed for this. + \nl + The \`\_tryloadtt` is implemented differently because we want to keep + family independence for `\tt` macro, see section~\ref[tt]. + So, `\_tryloadtt` is defined constantly as \"loading `\tt` font" and it is + not re-defined to `\relax`. On the other hand, `\_tryloadtt` is + re-defined in the \^`\initunifonts` macro or when used + \~`\famvardef``\tt`. + \_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 `\_ten` 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 \`\_resizefont` `{}\` is the heart of the + Fonts Selection System. It resizes the font given by the variant with + respect to the current font context and sets a new . + The is `rm` or `bf` or `it` or `bi` or `tt`. + The new is declared (roughly speaking) by: + \begtt \catcode`<=13 + \_font = \_ten \_sizepec % in TFM mode + \_font = {\_fontnamegen} \_sizespec % in OTF mode + \endtt + The font is loaded by \`\_doresizefont```. This macro has + meaning \`\_doresizetfmfont` in TFM mode (default in format) and it + switches to \^`\_doresizeunifont` when \^`\initunifonts` is used.\nl + The `` is generated by the `\fontname` \TeX/ primitive where + \`\_rfontskipat` removes the `at` part of the `\fontname` output.\nl + The \`\_whatresize` is defined as ``.\nl + The \^`\_fontloaded``` is a macro which can be used for + post-processing when a font is loaded. + \_cod ----------------------------- + +\_def\_resizefont#1#2{% + \_edef\_whatresize{#1}\_doresizefont#2\_relax \_fontloaded #2% + \_lastmagsize=\_zo + \_if t\_ignoresecond#1\_else \_slet{_tryload#1}{_relax}\_fi +} +\_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 ----------------------------- + \`\_doresizeunifont``` implements the OTF mode of + loading fonts \^`\_doresizefont`. + There is a fallback to TFM mode if \^`\_fontnamegen` is not defined.\nl + The \^`\_fontnamegen` expands to the font name/file:font-features + depending on the current font context. + \_cod ----------------------------- + +\_def\_doresizeunifont #1{\_logfont{#1}% + \_ifx\_fontnamegen\_undefined \_doresizetfmfont#1\_else + \_font#1={\_fontnamegen} \_sizespec \_relax \_setwsp#1\_relax + \_fi +} + + \_doc ----------------------------- + If a font is loaded by \^`\_resizefont` or \^`\resizethefont` then the + \`\_fontloaded``` is called immediately after it. If the font + is loaded first then its `\skewchar` is equal to $-1$. We run + \`\_newfontloaded``` 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 ----------------------------- \`\initunifonts` macro extends \LuaTeX's font capabalities, @@ -10,30 +135,25 @@ from \LaTeX's `luatexbase` namespace, we provide our own replacements. Moreover, `\initunifont` switches with the \^`\_doresizefont` macro to OTF mode which is represented by the - macro \`\_doresizeunifont`. This mode includes - a fallback to TFM mode if \^`\_fontnamegen` is not defined. - Finally, `\initunifonts` sets itself to relax because we don't want to do + macro \^`\_doresizeunifont`. + Finally, \^`\initunifonts` sets itself to relax because we don't want to do this work twice.\nl - \`\_ttunifont` is default font for `\tt` variant if - `f-lmfonts.opm` (or another font file where `\tt` is declared) is not loaded. + \`\_ttunifont` is default font for `\tt` variant. + User can re-define it or use \^`\famvardef``\tt`. \_cod ----------------------------- \_def\_initunifonts {% - \directlua{% + \_directlua{% require('luaotfload-main') luaotfload.main() }% \_gdef\_rfskipatX ##1" ##2\_relax{"##1"}% \_global\_let \_doresizefont=\_doresizeunifont - \_gdef\_tryloadtt {\_fontdef\_tentt{\_let\_fontnamegen=\_ttunifont\_rm}}% + \_gdef\_tryloadtt {\_begingroup \_let\_fontnamegen\_ttunifont % \tt uses \_ttunifont + \_resizefont{tt}\_tentt\_relax \_ea\_endgroup \_ea\_let \_ea\_tentt \_the\_tentt}% \_global\_let \_initunifonts=\_relax % we need not to do this work twice \_global\_let \initunifonts=\_relax } -\_gdef\_doresizeunifont #1{\_logfont{#1}% - \_ifx\_fontnamegen\_undefined \_doresizetfmfont#1\_else - \_font#1={\_fontnamegen} \_sizespec \_relax \_setwsp#1\_relax - \_fi -} \_def\_ttunifont{[lmmono10-regular]:\_fontfeatures-tlig;} \_public \initunifonts ; @@ -71,31 +191,6 @@ \_csname _f:\_currfamily:main.fam\_endcsname \_reloading \_rm } - \_doc ----------------------------- - \`\_regoptsizes` ` ? ` - prepares data for using by the \`\_optname` `` macro. - The data are saved to the `\_oz:` macro. - When the `\_optname` is expanded then the data are scanned by the macro - \`\_optnameA` `? `\code{<}`` - in the loop.\nl - \`\_optfontalias` `{