blob-ini.mkiv /size: 1770 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=blob-ini,
3
%D version=2010.04.06,
4
%D title=\CONTEXT\ \LUA\ Typesetting,
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
\writestatus
{
loading
}{
ConTeXt
Lua
Typesetting
/
Initialization
}
15 16
%D This is a prelude to typesetting at the \LUA\ end. The code
17
%D is already quite old but will only get nice when we are further
18
%D down the road (close to version 1.00 of \LUATEX). Typesetting in
19
%D pure \LUA\ sometimes makes sense.
20 21
\registerctxluafile
{
node
-
typ
}{}
% experimental
22
\registerctxluafile
{
blob
-
ini
}{}
23 24
%D For the moment here:
25 26
\unprotect
27 28
% this one takes simple (utf) strings
29 30
\def
\wdofstring
#
1
{
\dimexpr
\clf_strwd
{
#
1
}
\scaledpoint
\relax
}
31
\def
\htofstring
#
1
{
\dimexpr
\clf_strht
{
#
1
}
\scaledpoint
\relax
}
32
\def
\dpofstring
#
1
{
\dimexpr
\clf_strdp
{
#
1
}
\scaledpoint
\relax
}
33
\def
\hdofstring
#
1
{
\dimexpr
\clf_strhd
{
#
1
}
\scaledpoint
\relax
}
34 35
\def
\widthofstring
{
\the
\wdofstring
}
36
\def
\heightofstring
{
\the
\htofstring
}
37
\def
\depthofstring
{
\the
\dpofstring
}
38
\def
\heightanddepthofstring
{
\the
\hdofstring
}
39 40
\let
\htdpofstring
\hdofstring
41 42
\let
\hd
\htdp
% if yes then move this
43 44
% this one takes anything that can be typeset
45 46
\unexpanded
\def
\setwidthof
#
1
\to
#
2
%
47
{
\bgroup
48
\setbox
\scratchbox
\hbox
{
#
1
}
%
49
\expanded
{
\egroup
\def\noexpand
#
2
{
\the\wd
\scratchbox
}}}
50 51
\protect
\endinput
52 53
% \starttext
54
%
55
% \startluacode
56
% local b = blobs.new()
57
% blobs.append(b,"Hello world.\n Here we are.\n\n And Again!")
58
% blobs.pack(b)
59
% blobs.write(b)
60
% \stopluacode
61
%
62
% \stoptext
63