From 56bd1f5b8377f54b4af39a114362a7762d27f13c Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 7 May 2020 03:01:09 +0000 Subject: CTAN sync 202005070301 --- macros/luatex/optex/base/hyphen-lan.opm | 203 ++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 macros/luatex/optex/base/hyphen-lan.opm (limited to 'macros/luatex/optex/base/hyphen-lan.opm') diff --git a/macros/luatex/optex/base/hyphen-lan.opm b/macros/luatex/optex/base/hyphen-lan.opm new file mode 100644 index 0000000000..76feb2296d --- /dev/null +++ b/macros/luatex/optex/base/hyphen-lan.opm @@ -0,0 +1,203 @@ +%% This is part of OpTeX project, see http://petr.olsak.net/optex + +\_codedecl \langlist {Initialization of hypenation patterns <2020-03-10>} % preloaded in format + + \_doc ----------------------------- + The means a shortcut of language name (mostly by ISO 639-1). + The following control sequences are used for language switching: + \begitems + * `\_lan:` expands to `` of the language. + The number is internal number of languages used as a value of + `\language` register. + * `\_ulan:` expands to `` too. This is transformation + from long name of language (lowercase letters) to . + * `\_Patt` (for example `\_csPatt`) is the language `` declared by `\chardef`. + * `\lang` + (for example \`\enlang`, \`\cslang`, \`\sklang`, \`\delang`, \`\pllang`) + is language selector. It exists in two states + \begitems + * Initialization state: when `\lang` is used first then it + must load the patterns into memory using Lua code. If it is done then + the `\lang` re-defines itself to processing state. + * Processing state: it only sets `\language=\_Patt`, i.e it + selects the hyphenation patterns. It does a little more + language-dependent work, as mentioned below. + \enditems + * `\_langspecific:` is processed by `\lang` and it + should include language-specific macros declared by user or macro designer. + \enditems + The USenglish patters are preloaded first: + \_cod ----------------------------- + +\_chardef\_enPatt=0 +\_def\_pattlist{\_enPatt=0} +\_def\_langlist{en(USenglish)} +\_sdef{_lan:0}{en} +\_sdef{_ulan:usenglish}{en} +\_def\_enlang{\_uselang{en}\_enPatt23} % \lefthyph=2 \righthyph=3 +\_def\enlang{\_enlang} +\_sdef{_langspecific:en}{\_nonfrenchspacing} + +\_lefthyphenmin=2 \_righthyphenmin=3 % disallow x- or -xx breaks +\_input hyphen % en(USenglish) patterns from TeX82 + + \_doc ----------------------------- + \`\preplang` ` ` + prepares the\nl `\lang` to its initialization state. Roughly + speaking, it does: + \begtt \catcode`\<=13 + \chardef\_Patt = + \def\_lan: {} + \def\_ulan: {} + \def\_lang {% + \_loadpattrs % loads patterns using Lua code + \gdef\_lang {\_uselang{}\_Patt } + \_lang % runs itself in processing state + } + \def\lang {\_lang} % public version \lang + \endtt + You can see that `\lang` runs \`\_loadpattrs` ` ` + in initialization state and \^`\_uselang` in processing state. + \_cod ----------------------------- + +\_def\_preplang #1 #2 #3#4 #5 {% + \_chardef#3=#4 + \_sdef{_lan:#4}{#1}\_lowercase{\_sdef{_ulan:#2}}{#1}% + \_def\_next{\_ea\_noexpand\_csname _#1lang\_endcsname} + \_ea\_edef \_csname _#1lang\_endcsname {% + \_lowercase{\_noexpand\_loadpattrs #2} #4 % loads patterns + \_gdef\_next{\_noexpand\_uselang{#1}#3#5}% re-defines itself + \_next % runs itself in processing state + } + \_addto\_langlist{ #1(#2)}% + \_sdef{#1lang}{\_csname _#1lang\_endcsname}% unprefixed \lang +} +\_def\_loadpattrs#1 #2 {% + \_directlua{ + require("luatex-hyphen") + luatexhyphen.loadlanguage("#1",#2) + }% +} + + \_doc ----------------------------- + \`\_uselang``{}\_Patt `\nl + sets `\language`, `\lefthyphenmin`, `\righthyphenmin` and runs + `\frenchspacing`. This default language-dependent settings + should be re-declared by `\_langspecific:` which is run + finally (it is `\relax` by default, only `\_langspecific:en` runs + \^`\nonfrenchspacing`). + \_cod ----------------------------- + +\_def\_uselang#1#2#3#4{\_language=#2\_lefthyphenmin=#3\_righthyphenmin=#4\_relax + \_frenchspacing % \nonfrenchspacing can be set in \cs{_langspecific:lan} + \_cs{_langspecific:#1}% +} + \_doc ----------------------------- + The \`\uselanguage` `{}` is defined here + (for compatibility with e-plain users). + \_cod ----------------------------- + +\_def\_uselanguage#1{\_lowercase{\_cs{_\_cs{_ulan:#1}lang}}} +\_public \uselanguage ; + + \_doc ----------------------------- + The numbers for languages are declared as fixed constants (no + auto-generated). This concept is inspired from CSplain. + There are typical numbers of languages in CSplain: 5=Czech in IL2, + 15=Czech in T1 and 115=Czech in Unicode. We keep these constants + but we load only Unicode patterns (greater than 100), of course. + \_cod ----------------------------- + +\_preplang enus USenglishmax \_enusPatt 100 23 +\_preplang engb UKenglish \_engbPatt 101 23 +\_preplang it Italian \_itPatt 102 22 +\_preplang ia Interlingua \_iaPatt 103 22 +\_preplang id Indonesian \_idPatt 104 22 + +\_preplang cs Czech \_csPatt 115 23 +\_preplang sk Slovak \_skPatt 116 23 +\_preplang de nGerman \_dePatt 121 22 +\_preplang fr French \_frPatt 122 22 +\_preplang pl Polish \_plPatt 123 22 +\_preplang cy Welsh \_cyPatt 124 23 +\_preplang da Danish \_daPatt 125 22 +\_preplang es Spanish \_esPatt 126 22 +\_preplang sl Slovenian \_slPatt 128 22 +\_preplang fi Finnish \_fiPatt 129 22 +\_preplang hy Hungarian \_huPatt 130 22 +\_preplang tr Turkish \_trPatt 131 22 +\_preplang et Estoniak \_etPatt 132 23 +\_preplang eu Basque \_euPatt 133 22 +\_preplang ga Irish \_gaPatt 134 23 +\_preplang nb Bokmal \_nbPatt 135 22 +\_preplang nn Nynorsk \_nnPatt 136 22 +\_preplang nl Dutch \_nlPatt 137 22 +\_preplang pt Portuguese \_ptPatt 138 23 +\_preplang ro Romanian \_roPatt 139 22 +\_preplang hr Croatian \_hrPatt 140 22 +\_preplang zh Pinyin \_zhPatt 141 11 +\_preplang is Icelandic \_isPatt 142 22 +\_preplang hsb Uppersorbian \_hsbPatt 143 22 +\_preplang af Afrikaans \_afPatt 144 12 +\_preplang gl Galician \_glPatt 145 22 +\_preplang kmr Kurmanji \_kmrPatt 146 22 +\_preplang tk Turkmen \_tkPatt 147 22 +\_preplang la Latin \_laPatt 148 22 +\_preplang lac classicLatin \_lacPatt 149 22 +\_preplang lal liturgicalLatin \_lalPatt 150 22 +\_preplang elm monoGreek \_elmPatt 201 11 +\_preplang elp Greek \_elpPatt 202 11 +\_preplang grc ancientGreek \_grcPatt 203 11 +\_preplang ca Catalan \_caPatt 204 22 +\_preplang cop Coptic \_copPatt 205 11 +\_preplang mn Mongolian \_mnPatt 206 22 +\_preplang sa Sanskrit \_saPatt 207 13 +\_preplang ru Russian \_ruPatt 208 22 +\_preplang uk Ukrainian \_ukPatt 209 22 +\_preplang hy Armenian \_hyPatt 210 12 +\_preplang as Assamese \_asPatt 211 11 +\_preplang hi Hindi \_hiPatt 212 11 +\_preplang kn Kannada \_knPatt 213 11 +\_preplang lv Latvian \_lvPatt 215 22 +\_preplang lt Lithuanian \_ltPatt 216 22 +\_preplang ml Malayalam \_mlPatt 217 11 +\_preplang mr Marathi \_mrPatt 218 11 +\_preplang or Oriya \_orPatt 219 11 +\_preplang pa Panjabi \_paPatt 220 11 +\_preplang ta Tamil \_taPatt 221 11 +\_preplang te Telugu \_tePatt 222 11 + + \_doc ----------------------------- + The \`\langlist` includes names of all languages which are ready to load + and use their hyphenation patterns. This list is printed to terminal and + to log at ini\TeX/ state here. It can be used when processing document too. + \_cod ----------------------------- + +\_message{Language hyph.patterns ready to load: \_langlist. + Use \_string\lang to initialize language, + \_string\cslang\_space for example} + +\_public \langlist ; + +\_endcode % --------------------------------------------- + + +Maybe, you need to do more language specific actions than only to swich +hyphenation patterns. For example you need to load a specific font with a +specific script used in selected language, you can define a macros for +quotation marks depending on the language etc. + +The example shows how to declare such language specific things. + +\begtt +\def\langset #1 #2{\sdef{_langspecific:#1}{#2}} + +\langset fr {... declare French quotation marks} +\langset de {... declare German quotation marks} +\langset gr {... switch to Greek fonts family} +... etc. +\endtt + +Note that you need not to set language specific phrases (like `\today`) +by this code. Another concept is used for such tasks. See the +section~\ref[langphrases] for more details. -- cgit v1.2.3