scrp-ini.mkiv /size: 4076 b    last modification: 2021-10-28 13:50
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}{}
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\let\setupscripts\setupscript % be nice
57
58% presets are global and are currently defined in lua
59
60% \appendtoks
61%     \setuevalue\currentscript{\setscript[\currentscript]}%
62% \to \everydefinescript
63
64% \ctxlua{inspect(scripts.handlers.hangul.datasets)}
65
66\unexpanded\def\scripts_basics_set
67  {\clf_setscript{\currentscript}{\scriptparameter\c!method}{\scriptparameter\c!preset}}
68
69\unexpanded\def\setglobalscript[#1]%
70  {\edef\currentscript{#1}%
71   \scripts_basics_set
72   \pickupscriptattribute}
73
74\unexpanded\def\setlocalscript[#1]%
75  {\edef\currentscript{#1}%
76   \scripts_basics_set}
77
78\let\setscript\setlocalscript
79
80\unexpanded\def\resetscript
81  {\clf_resetscript}
82
83\unexpanded\def\startscript[#1]%
84  {\begingroup
85   \edef\currentscript{#1}%
86   \scripts_basics_set}
87
88\unexpanded\def\stopscript
89  {\endgroup}
90
91% % todo:
92%
93% \unexpanded\def\setscriptsplitterlist
94%   {\dodoubleargument\scripts_basics_set_splitter_list}
95%
96% \def\scripts_basics_set_splitter_list[#1][#2]%
97%   {\ctxcommand{setscriptsplitterlist("#1","#2")}
98
99% \setscript[hangul] \startscript[hangul]
100
101\definescript [hangul]   [\c!method=hangul]
102\definescript [hanzi]    [\c!method=hanzi]
103\definescript [nihongo]  [\c!method=nihongo]
104\definescript [ethiopic] [\c!method=ethiopic]
105\definescript [thai]     [\c!method=thai]
106\definescript [tibetan]  [\c!method=tibetan]
107
108\definescript [latin]    [\c!method=]        %  resets the attribute (also currentscript)
109
110\definescript [test]     [\c!method=test]
111
112% a new trick (at some point we will predefine more scripts and consider a link with the above)
113
114\appendtoks
115    \ifx\currentscript\empty
116        \doifelse{\scriptparameter\s!features}\v!auto\enableautofontscript\disableautofontscript
117    \fi
118\to \everysetupscript
119
120\unexpanded\def\enableautofontscript {\clf_enableautofontscript }
121\unexpanded\def\disableautofontscript{\clf_disableautofontscript}
122
123\definefontfeature[latn][script=latn]
124\definefontfeature[grek][script=grek]
125
126\protect \endinput
127