| 1 |
% This is macro package used by OpTeX, see http://petr.olsak.net/optex |
| 2 |
% minim-pdf.opm, Michal Vlasák <[email protected]>, 2022 |
| 3 |
% see also https://github.com/vlasakm/optex-minim |
| 4 |
|
| 5 |
\_codedecl \nohyphlang {Minim-PDF for \OpTeX/} |
| 6 |
\_namespace{minimpdf} |
| 7 |
|
| 8 |
\_doc |
| 9 |
Before loading `minim-pdf` we do a few preparations. Most importantly |
| 10 |
adjusting core of minim, which is done in `minim.opm`. |
| 11 |
\_cod |
| 12 |
|
| 13 |
\_load[minim] |
| 14 |
|
| 15 |
\_catcode`\@=11 |
| 16 |
\_catcode`\:=11 |
| 17 |
|
| 18 |
\_doc |
| 19 |
Minim hooks into language mechanism with standard \eTeX/ |
| 20 |
`\uselanguage@hook`. It can then translate language names (e.g |
| 21 |
\"SwissGerman") into BCP 47 language identifiers (e.g. \"de-ch-1901", the |
| 22 |
naming scheme of the `hyph-utf8` package) which are then embedded into |
| 23 |
tagged PDFs. For simplicity, we use what \OpTeX/ calls \"lang-tag" (e.g. |
| 24 |
\"de") which may not be precise enough (i.e. the right thing for Swiss |
| 25 |
German would be \"de-ch") and may even be wrong(?). |
| 26 |
|
| 27 |
When e.g. `\gswlang` (Swiss German) is used, `\uselang{gsw}\_gswPatt<...>` |
| 28 |
is called in \OpTeX/. We use the fact, the there is mapping from language |
| 29 |
register numbers (`\_gswPatt`) to \"lang-tag"s (\"de"). To avoid confusion |
| 30 |
with any other language mappings, we prefix what we give to minim with `o:`. |
| 31 |
|
| 32 |
We also don't incorporate the \eTeX/ `\uselanguage@hook`, but call minim's |
| 33 |
callback directly, maybe it will cause less trouble with other packages |
| 34 |
(since we don't pass standard names to the callback) and also gives a better |
| 35 |
idea of what happens. |
| 36 |
\_cod |
| 37 |
|
| 38 |
\_let\.uselang=\_uselang |
| 39 |
\_def\_uselang#1#2#3#4{% |
| 40 |
\.uselang{#1}{#2}{#3}{#4}% |
| 41 |
% just set this everytime, doesn't hurt |
| 42 |
\setlanguagecode{o:#1}{\_cs{_lan:\_the#2}}% |
| 43 |
\minim:uselanguagecallback{o:#1}% |
| 44 |
} |
| 45 |
|
| 46 |
\_doc |
| 47 |
If not detected, a few \"dummy" languages would be (in erroneous ways) |
| 48 |
defined by minim: like \"nohyph" and \"undetermined". We define a few dummy |
| 49 |
control sequences, to make minim not define them, since we define them |
| 50 |
ourselves below. They are used in standard way, but their \"ISO codes" are weird: |
| 51 |
|
| 52 |
\begtt |
| 53 |
\nohyphlang |
| 54 |
\nolanglang |
| 55 |
\uncodedlang |
| 56 |
\undeterminedlang |
| 57 |
\endtt |
| 58 |
\_cod |
| 59 |
|
| 60 |
\_let\lang@nohyph=\_empty |
| 61 |
\_let\lang@nolang=\_empty |
| 62 |
\_let\lang@uncoded=\_empty |
| 63 |
\_let\lang@undetermined=\_empty |
| 64 |
|
| 65 |
\_preplang nohyph nohyph und {} 11 |
| 66 |
\_preplang nolang nolang und {} 11 |
| 67 |
\_preplang uncoded uncoded und {} 11 |
| 68 |
\_preplang undetermined undetermined und {} 11 |
| 69 |
|
| 70 |
\_doc |
| 71 |
Now we actually load `minim-pdf`. |
| 72 |
\_cod |
| 73 |
|
| 74 |
\_input minim-pdf |
| 75 |
|
| 76 |
\_doc |
| 77 |
Users aren't supposed to define custom languages in \OpTeX/, forbid that. |
| 78 |
\_cod |
| 79 |
|
| 80 |
\_def\_tmp{\errmessage{don't use this command with OpTeX}} |
| 81 |
\_let\newnamedddialect=\_tmp |
| 82 |
\_let\newnameddllanguage=\_tmp |
| 83 |
|
| 84 |
\_doc |
| 85 |
Since a language may already be set (at least the default Knuth english), |
| 86 |
then we need to tell minim about it, by reexecuting the language command |
| 87 |
(like `\enlang`), thus calling into minim through the above mentioned hook. |
| 88 |
\_cod |
| 89 |
|
| 90 |
% set the current language again to let minim know what it is |
| 91 |
\_cs{\_cs{_lan:\_the\_language}lang} |
| 92 |
|
| 93 |
|
| 94 |
% catcodes changes don't propagate, since this file is loaded with \opinput |
| 95 |
\_endnamespace |
| 96 |
\_endcode |