diff options
Diffstat (limited to 'Master/texmf-dist/tex/optex/pkg')
-rw-r--r-- | Master/texmf-dist/tex/optex/pkg/minim-mp.opm | 16 | ||||
-rw-r--r-- | Master/texmf-dist/tex/optex/pkg/minim-pdf.opm | 96 | ||||
-rw-r--r-- | Master/texmf-dist/tex/optex/pkg/minim.opm | 188 | ||||
-rw-r--r-- | Master/texmf-dist/tex/optex/pkg/plain-at.opm | 9 | ||||
-rw-r--r-- | Master/texmf-dist/tex/optex/pkg/tikz.opm | 123 |
5 files changed, 427 insertions, 5 deletions
diff --git a/Master/texmf-dist/tex/optex/pkg/minim-mp.opm b/Master/texmf-dist/tex/optex/pkg/minim-mp.opm new file mode 100644 index 00000000000..72462d86c27 --- /dev/null +++ b/Master/texmf-dist/tex/optex/pkg/minim-mp.opm @@ -0,0 +1,16 @@ +% This is macro package used by OpTeX, see http://petr.olsak.net/optex +% minim-mp.opm, Michal Vlasák <lahcim8@gmail.com>, 2022 +% see also https://github.com/vlasakm/optex-minim + +\_codedecl \_minimmp_used {Minim-PDF for \OpTeX/} +\_namespace{minimmp} + +\_def\.used{} + +\_load[minim] + +\_input minim-mp + +\_endnamespace +\_endcode + diff --git a/Master/texmf-dist/tex/optex/pkg/minim-pdf.opm b/Master/texmf-dist/tex/optex/pkg/minim-pdf.opm new file mode 100644 index 00000000000..3c4c0c73317 --- /dev/null +++ b/Master/texmf-dist/tex/optex/pkg/minim-pdf.opm @@ -0,0 +1,96 @@ +% This is macro package used by OpTeX, see http://petr.olsak.net/optex +% minim-pdf.opm, Michal Vlasák <lahcim8@gmail.com>, 2022 +% see also https://github.com/vlasakm/optex-minim + +\_codedecl \nohyphlang {Minim-PDF for \OpTeX/} +\_namespace{minimpdf} + + \_doc + Before loading `minim-pdf` we do a few preparations. Most importantly + adjusting core of minim, which is done in `minim.opm`. + \_cod + +\_load[minim] + +\_catcode`\@=11 +\_catcode`\:=11 + + \_doc + Minim hooks into language mechanism with standard \eTeX/ + `\uselanguage@hook`. It can then translate language names (e.g + \"SwissGerman") into BCP 47 language identifiers (e.g. \"de-ch-1901", the + naming scheme of the `hyph-utf8` package) which are then embedded into + tagged PDFs. For simplicity, we use what \OpTeX/ calls \"lang-tag" (e.g. + \"de") which may not be precise enough (i.e. the right thing for Swiss + German would be \"de-ch") and may even be wrong(?). + + When e.g. `\gswlang` (Swiss German) is used, `\uselang{gsw}\_gswPatt<...>` + is called in \OpTeX/. We use the fact, the there is mapping from language + register numbers (`\_gswPatt`) to \"lang-tag"s (\"de"). To avoid confusion + with any other language mappings, we prefix what we give to minim with `o:`. + + We also don't incorporate the \eTeX/ `\uselanguage@hook`, but call minim's + callback directly, maybe it will cause less trouble with other packages + (since we don't pass standard names to the callback) and also gives a better + idea of what happens. + \_cod + +\_let\.uselang=\_uselang +\_def\_uselang#1#2#3#4{% + \.uselang{#1}{#2}{#3}{#4}% + % just set this everytime, doesn't hurt + \setlanguagecode{o:#1}{\_cs{_lan:\_the#2}}% + \minim:uselanguagecallback{o:#1}% +} + + \_doc + If not detected, a few \"dummy" languages would be (in erroneous ways) + defined by minim: like \"nohyph" and \"undetermined". We define a few dummy + control sequences, to make minim not define them, since we define them + ourselves below. They are used in standard way, but their \"ISO codes" are weird: + + \begtt + \nohyphlang + \nolanglang + \uncodedlang + \undeterminedlang + \endtt + \_cod + +\_let\lang@nohyph=\_empty +\_let\lang@nolang=\_empty +\_let\lang@uncoded=\_empty +\_let\lang@undetermined=\_empty + +\_preplang nohyph nohyph und {} 11 +\_preplang nolang nolang und {} 11 +\_preplang uncoded uncoded und {} 11 +\_preplang undetermined undetermined und {} 11 + + \_doc + Now we actually load `minim-pdf`. + \_cod + +\_input minim-pdf + + \_doc + Users aren't supposed to define custom languages in \OpTeX/, forbid that. + \_cod + +\_def\_tmp{\errmessage{don't use this command with OpTeX}} +\_let\newnamedddialect=\_tmp +\_let\newnameddllanguage=\_tmp + + \_doc + Since a language may already be set (at least the default Knuth english), + then we need to tell minim about it, by reexecuting the language command + (like `\enlang`), thus calling into minim through the above mentioned hook. + \_cod + +% set the current language again to let minim know what it is +\_cs{\_cs{_lan:\_the\_language}lang} + + +% catcodes changes don't propage, since this file is loaded with \opinput +\_endnamespace +\_endcode diff --git a/Master/texmf-dist/tex/optex/pkg/minim.opm b/Master/texmf-dist/tex/optex/pkg/minim.opm new file mode 100644 index 00000000000..79298552d11 --- /dev/null +++ b/Master/texmf-dist/tex/optex/pkg/minim.opm @@ -0,0 +1,188 @@ +% This is used by OpTeX packages minim-mp, minim-pdf, see http://petr.olsak.net/optex +% minim.opm, Michal Vlasák <lahcim8@gmail.com>, 2022 +% see also https://github.com/vlasakm/optex-minim + +\_def\_optexminim_version{0.1} +\_codedecl \optexminim_loaded {Minim compatibility for \OpTeX/ (v\_optexminim_version)} + + \_doc + When we want to use minim with \OpTeX/, we need to accomodate for their + differences. Particularly in allocations. Because of Esger Renkema's + graciousness, minim has been modified in ways that make it easier to + integrate with \OpTeX/. So even when the two formats normally disagree on a + lot of core things (allocations, callbacks) they can end up working together. + + \OpTeX/ defines most allocation macros in `alloc.opm` and some Lua + allocation functions in `optex.lua`. Minim \"packages" are not standalone, + they all depend on core routines defined in `minim-alloc.tex` and + `minim-alloc.lua` respectively. Minim as a format preloads a stripped + version of `etex.src` so the Lua code makes some assumptions about that + (i.e. expects local allocators). + + Both \OpTeX/ and minim want to make it possible to register more functions + for a single callback, by chaining their calls and `callback.register()`ing + only a proxy function. While minim stays close to the `callback` interface + from \LuaTeX/, \OpTeX/ is a subset of the \LaTeX/ `luatexbase` interface. + But minim now can work on top of ltluatex by using its functions instead of + `callback.register()`, so we don't have to do anything to support it in + \OpTeX/! + + Firstly, because we only change what is defined by others, we actually need + a dummy macro for `\_codedecl`, to prevent loading this file more than once. + \_cod + +\_catcode`\@=11 +% dummy macro to signalize that we are loaded +\_let\optexminim_loaded=\empty + + \_doc + In general, there are four allocator types expected by minim: + + \begitems + * Knuth allocators from `plain.tex` (like `\newcount`). These are already + defined by \OpTeX/. Although minim itself sets the old `\allocationnumber` + counter, which is not even defined in \OpTeX/. + + * Global allocators from `etex.src` (like `\globcount`). These are not + defined by \OpTeX/, since they no longer make sense (\LuaTeX/ doesn't use + sparse arrays for registers). Minim defines them to be the classic Knuth + allocators if it doesn't find them on the TeX side, but expects them from + the Lua side. + + * Local allocators from `etex.src` (like `\loccount`). Concept of local + allocators is completely missing in \OpTeX/. The semantics of local + allocation in Lua is weird too, so we try to avoid these, since minim also + doesn't define their Lua variants. + + * \LuaTeX/ allocators from `ltluatex.tex` (like `\newattribute`). Subset of + these is in \OpTeX/ (only atributes, which are also allocatable in Lua, and + catcode tables). But minim tries to be compatible with \LaTeX/ and patches + its routines if it detects them. + \enditems + + For defining \TeX/ commands implemented in Lua, \OpTeX/ has + `define_lua_command`, which actually does the allocation and definition at + the same time, and allows to do so only from Lua end. + + Historically (in my opinion unfortunately) \LaTeX/ made the allocations of + these functions available from \TeX/ end, and the \"lua define" operation is + thus a two step process which involves synchronization with \TeX/. + + `minim-alloc` actually defines a `luadef` function which is like + `define_lua_command`, but is backed by the minim allocator. To make this + work, we just need to set the \LaTeX/ register to the index of last + allocated function, since it allocates at counter plus one. Then minim will + start where \OpTeX/ stopped, and we will later define `define_lua_command` + to be just minim's `luadef`. + + We tell the number of allocated function by going through the table of + actually used functions. This is not that robust, because while + `define_lua_command` allocates sequentially, the provided functions may be + `nil`, which breaks the code below. + \_cod + +\_newcount\allocationnumber + +% for synchronisation of allocated Lua functions +\_ea\_newcount\_csname e@alloc@luafunction@count\_endcsname + +\directlua{ + local function_table = lua.get_functions_table() + % minim allocates at count + 1 for "new" allocators, so this works + tex.setcount("global", "e@alloc@luafunction@count", \csstring\#function_table) +} + + \_doc + We also get PDF resources out of the way now. Minim is ready to use \OpTeX's + PDF resource management, but also has compatibility layer for PGF, which is + not needed in \OpTeX/. We prevent loading the problematic \TeX/ file. + \_cod + +\_let\minimpdfresourcesloaded=\_empty + + \_doc + The preparations are over. We load `minim-alloc.tex`. + \_cod + +\input minim-alloc + + \_doc + Both \LaTeX/ and the minim inspired catcode table allocators initialize the + catcode tables with `\initcatcodetable` (i.e. ini\TeX/ catcodes). \OpTeX/ + merely allocates the registers. \LuaTeX/ doesn't allow to activate + unitialized catcode table, therefore activation with either + `\initcatcodetable` or `\savecatcodetable` is necessary before use. To + ensure compatibility with foreign macros, we also issue `\initcatcodetable` + on allocation in the public version of `\newcatcodetable`. + \_cod + +\_def\newcatcodetable#1{\_newcatcodetable#1\_initcatcodetable#1} + + \_doc + By now, the Knuthian allocators are dealt with. \eTeX/ global and local + allocators are undefined, but the global ones are expected in minim's Lua + code with their hardcoded counter register numbers. This is unacceptable, + since in this range (`\count260` to `\count266`) \OpTeX/ has already made + allocations. Thus we need to replace these Lua functions with similar + definitions. For some, \OpTeX/ also has a different idea whether the counter + represent the last or next allocated register number, so we correct that as + well. + + We also don't forget to actually set `define_lua_command` to be minim's + `luadef`. + \_cod + +\directlua{ + local minimalloc = require("minim-alloc") + + define_lua_command = minimalloc.luadef + + % these are allocators already defined in OpTeX that we need to repair + local toreplace = { + "count", + "dimen", + "skip", + "muskip", + "box", + "toks", + "marks", + "attribute", + "catcodetable", + } + + for _, alloc in ipairs(toreplace) do + local cache = {} + local countername = string.format("_\_pcent salloc", alloc) + minimalloc["new_"..alloc] = function(id) + local n = cache[id] + if not n then + n = tex.getcount(countername) + 1 + tex.setcount("global", countername, n) + if id then + cache[id] = n + end + minimalloc.log( + "\_nbb\_pcent s\_pcent d : \_pcent s", alloc, n, id or "<unnamed>") + end + return n + end + end +} + + \_doc + We also need to do something about `minim-hooks.tex`, which hooks into + `\shipout`, but the default \OpTeX/ output routine (and perhaps also the + user ones) use `\_shipout`. + + Minim also adds to `\everypar`, but that is fine. + \_cod + +\_let\shipout\_shipout + +\input minim-hooks + +\_catcode`\:=11 +\_let\_shipout\minim:shipout:new + +% catcodes changes don't propage, since this file is loaded with \opinput +\_endcode diff --git a/Master/texmf-dist/tex/optex/pkg/plain-at.opm b/Master/texmf-dist/tex/optex/pkg/plain-at.opm index 3277d7b24ea..47495d2f2f4 100644 --- a/Master/texmf-dist/tex/optex/pkg/plain-at.opm +++ b/Master/texmf-dist/tex/optex/pkg/plain-at.opm @@ -2,6 +2,11 @@ \_codedecl \_undefined {Obscure @ names from plain TeX <2020-05-22>} +\_opwarning{plain-at.opm is obsolete, ignored. @-names defined in the format} + +\_endcode + +% Old version of plain-at.opm follows: \_setctable \_optexcatcodes % PlainTeX obscure names: \_catcode`\@=11 @@ -28,6 +33,7 @@ \_def\n@space{\_nulldelimiterspace\z@ \m@th} \_newdimen\p@renwd \p@renwd=8.75pt \_def\alloc@#1#2#3#4#5{\_allocator#5{\_csstring#2}#3} +\_catcode`\@=12 \_restorectable \_endcode @@ -41,3 +47,6 @@ can load this file in such cases. For example: \endtt \_endinput + +2022-02-15: marked obsolete +2020-12-20: released diff --git a/Master/texmf-dist/tex/optex/pkg/tikz.opm b/Master/texmf-dist/tex/optex/pkg/tikz.opm index da2657d5fcb..84743a18b68 100644 --- a/Master/texmf-dist/tex/optex/pkg/tikz.opm +++ b/Master/texmf-dist/tex/optex/pkg/tikz.opm @@ -1,17 +1,88 @@ % This is macro package used by OpTeX, see http://petr.olsak.net/optex -\_codedecl \tikzpicture {TikZ for OpTeX <2021-07-15>} +\_codedecl \tikzpicture {TikZ for OpTeX <2022-02-11>} +\_namespace{pgf} +\_catcode`\@=11 \_doc This package is \OpTeX/'s compatibility layer for PGF/TikZ. When users do `\load[tikz]` they expect `tikz.tex` to be loaded, but this file gets loaded instead. It does load `tikz.tex`, but also does fixups. - First we load TikZ itself. + We want to change some definitions in `pgfutil-plain.def` and + `pgfsys-luatex.def`. We need to do that in right times, so we manually + emulate some files from PGF to ensure we do things in the correct order. + \_cod + +%tikz.tex +% pgf.tex +% pgfrcs.tex +% pgfutil-common.tex +% pgfutil-common-lists.tex +% pgfutil-plain.tex +% pgfrcs.code.tex +% pgfcore.tex +% pgfsys.tex +% pgfsrcs.tex +% pgfsys.code.tex +% driver +% pgfcore.code.tex +% pgffor.tex +% pgfrcs.tex +% pgfkeys.code.tex +% pgffor.code.tex +% tikz.code.tex +\def\pgfrcsincluded{} +\input pgfutil-common.tex + + \_doc + We load macros from `pgfutil-plain.def` because they are most + similar to macros we actually need. But there are several differences. + We don't want to load the output routine hack realized by + `\input atbegshi.sty\relax \AtBeginShipout{...}` in `pgfutil-plain.def`. + This is the reason why we re-define `\input` temporarily. \_cod -\_input tikz.tex +\def\input#1\relax{} +\def\AtBeginShipout#1{} +\_input pgfutil-plain.def +\let\input=\_input +\let\AtBeginShipout=\_undefined +\let\end=\_end + + \_doc + More changes should be done for macros loaded from `pgfutil-plain.def`. + These changes follows. + \_cod + +% Writing to auxiliary files, customized + +\_let\pgfutil@aux@read@hook=\_relax +\_def\pgfutil@writetoaux#1{} + + +% Driver detection, customized + +\def\pgfsysdriver{pgfsys-luatex.def} + + +% Font stuff, \_typosize to fixed sizes used, math fonts are scaled too + +\def\pgfutil@font@tiny{\_typosize[5/]} +\def\pgfutil@font@scriptsize{\_typosize[7/]} +\def\pgfutil@font@footnotesize{\_typosize[8/]} +\def\pgfutil@font@small{\_typosize[9/]} +\def\pgfutil@font@normalsize{\_typosize[10/]} +\def\pgfutil@font@large{\_typosize[12/]} +\def\pgfutil@font@Large{\_typosize[14.4/]} +\def\pgfutil@font@huge{\_typosize[20.74/]} +\def\pgfutil@font@Huge{\_typosize[24.88/]} + +\def\pgfutil@font@normalfont{\_rm} +\def\pgfutil@font@itshape{\_it} +\def\pgfutil@font@bfseries{\_bf} +\def\pgfutil@selectfont{\_rm} \_doc PGF's `\pgfutil@everybye` hooks into `\end`, but normally \OpTeX/ uses the @@ -19,9 +90,34 @@ hopefully be preserved by all \OpTeX/ macro writers. \_cod -\_addto\_byehook{\_the\_cs{pgfutil@everybye}} +\_addto\_byehook{\_the\pgfutil@everybye} \_doc + Make PGF/TikZ use our PDF resource management. Our functions expect split + key and value. + \_cod + +\_def\.kvsplit#1{\_ea\.kvsplitA\_expanded{#1}\_end} +\_def\.kvsplitA#1/#2 #3\_end{{#2}{#3}} + +\_def\pgfutil@addpdfresource@extgs{\_addpageresource{ExtGState}\.kvsplit} +\_def\pgfutil@addpdfresource@colorspaces{\_addpageresource{ColorSpace}\.kvsplit} +\_def\pgfutil@addpdfresource@patterns{\_addpageresource{Pattern}\.kvsplit} +\_let\pgfutil@setuppdfresources=\_relax +\_let\pgf@sys@pdf@check@resources=\_relax +\_def\pgf@sys@pdf@possible@resources{\_pageresources} + +\_input pgfrcs.code.tex +\ProvidesPackageRCS{pgf.tex} +\_input pgfcore.tex +\usepgfmodule{shapes,plot} +\_input pgffor.tex +\_input tikz.code.tex + + \_doc + More changes should be done for macros loaded from `pgfsys-luatex.def`. + These changes follows. + There is a general disagreement about the use/meaning of `\hoffset` and `\voffset` -- \LaTeX/, the \LaTeX/ `crop` package\fnote{\url{https://www.ctan.org/pkg/crop}}, TikZ, and \OpTeX/ all @@ -34,6 +130,23 @@ $(0, 0)$). \_cod -\_sdef{pgf@sys@pdf@mark@pos@pgfpageorigin}{\pgfpointorigin} +\_def\pgf@sys@pdf@mark@pos@pgfpageorigin{\pgfpointorigin} +\_refdecl{% + \_def\.Xpgfsysmark#1#2#3{\_sdef{pgf@sys@pdf@mark@pos@#1}{\pgfqpoint{#2sp}{#3sp}}}% +} + +\_def\pgfsys@markposition#1{% + \_openref + \_savepos + \_edef\.tmp{#1}% + \_ea\_wref\_ea\.Xpgfsysmark\_ea{\_ea{\.tmp}{\_the\_lastxpos}{\_the\_lastypos}}% +} + +% don't worry about reseting catcodes - we are at the end of \opinput'ed file +\_endnamespace \_endcode + +History: +2022-03-05 resources management re-implemented +2021-07-15 released |