scrp-ini.mkiv /size: 4057 b    last modification: 2020-07-01 14:35
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
\ifcase
\contextlmtxmode
46
\definesystemattribute
[
script
][
public
,
pickup
]
47
\fi
48 49
%D Since scripts need specific \LUA\ code we use hard coded attribute values, but we
50
%D might have more tricks at some time, so we use a proper define macro too.
51 52
\unprotect
53 54
\installcorenamespace
{
script
}
55 56
\installcommandhandler
\??script
{
script
}
\??script
57 58
\let
\setupscripts\setupscript
% be nice
59 60
% presets are global and are currently defined in lua
61 62
\appendtoks
63
\setuevalue
\currentscript
{
\setscript
[
\currentscript
]
}
%
64
\to
\everydefinescript
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] \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