scrp-ini.mkxl /size: 3939 b    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=scrp-ini,
3%D        version=2009.02.06,
4%D          title=\CONTEXT\ Script Macros,
5%D       subtitle=Initialization,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14%D The script handler has been upgraded mid June 2020 so there might be issues as I
15%D didn't test everything (yet). It should all be a bit more efficient now in
16%D \LUAMETATEX, although not spectacular. We use no attributes in \LUAMETATEX\ and
17%D only one in \LUATEX\ now.
18%D
19%D A glyph can have (an dget) all kind of properties. Except from the state, these
20%D are assigned within \TEX's grouping model!
21%D
22%D \startitemize
23%D \startitem font \stopitem
24%D \startitem character \stopitem
25%D \startitem language (4 properties packed in an unsigned integer) \stopitem
26%D \startitem data (used for dynamics) \stopitem
27%D \startitem script (used for special script processing) \stopitem
28%D \startitem state (used for analyzing, related to font features) \stopitem
29%D \stopitemize
30%D
31%D Additional properties are set via node list handlers. The state is stored in the
32%D glyph, but additional properties are stored in a node's property table. In the
33%D future the state might get used for something else, in which case we will stire
34%D the state in the property table too. On the other hand, we can now (if we want)
35%D influence the state at the\TEX\ end (not that we do that yet).
36
37%D Todo: as in bidi mode we need a way to globally keep the setting.
38
39\registerctxluafile{scrp-ini}{autosuffix}
40\registerctxluafile{scrp-cjk}{}
41\registerctxluafile{scrp-eth}{}
42\registerctxluafile{scrp-tha}{}
43\registerctxluafile{scrp-tib}{}
44
45\definesystemattribute[script][public,pickup]
46
47%D Since scripts need specific \LUA\ code we use hard coded attribute values, but we
48%D might have more tricks at some time, so we use a proper define macro too.
49
50\unprotect
51
52\installcorenamespace{script}
53
54\installcommandhandler \??script {script} \??script
55
56\aliased\let\setupscripts\setupscript % be nice
57
58% presets are global and are currently defined in lua
59
60% \appendtoks
61%     \frozen\instance\protected\edefcsname\currentscript\endcsname{\setscript[\currentscript]}%
62% \to \everydefinescript
63
64\permanent\protected\def\setlocalscript[#1]%
65  {\cdef\currentscript{#1}%
66   \clf_setscript{\currentscript}{\scriptparameter\c!method}{\scriptparameter\c!preset}}
67
68\permanent\protected\def\setglobalscript[#1]%
69  {\setlocalscript[#1]%
70   \pickupscriptattribute} % pagebuilder
71
72\aliased\let\setscript\setlocalscript
73
74\permanent\protected\def\resetscript
75  {\clf_resetscript}
76
77\permanent\protected\def\startscript[#1]%
78  {\begingroup
79   \setlocalscript[#1]}
80
81\permanent\protected\def\stopscript
82  {\endgroup}
83
84% \setscript[hangul] \startscript[hangul]
85
86\definescript [hangul]   [\c!method=hangul]
87\definescript [hanzi]    [\c!method=hanzi]
88\definescript [nihongo]  [\c!method=nihongo]
89\definescript [ethiopic] [\c!method=ethiopic]
90\definescript [thai]     [\c!method=thai]
91\definescript [tibetan]  [\c!method=tibetan]
92
93\definescript [latin]    [\c!method=]        %  resets the attribute (also currentscript)
94
95\definescript [test]     [\c!method=test]
96
97% a new trick (at some point we will predefine more scripts and consider a link with the above)
98
99\appendtoks
100    \ifempty\currentscript
101        \ifcstok{\scriptparameter\s!features}\v!auto
102            \enableautofontscript
103        \else
104            \disableautofontscript
105        \fi
106    \fi
107\to \everysetupscript
108
109\permanent\protected\def\enableautofontscript {\clf_enableautofontscript } % can be public implementor
110\permanent\protected\def\disableautofontscript{\clf_disableautofontscript} % can be public implementor
111
112\definefontfeature[latn][script=latn]
113\definefontfeature[grek][script=grek]
114
115\protect \endinput
116