blob-ini.mkiv /size: 1783 b    last modification: 2021-10-28 13:50
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\totalofstring  {\the\hdofstring}
39
40\let\heightanddepthofstring\totalofstring
41\let\htdpofstring          \hdofstring
42
43\let\hd\htdp % if yes then move this
44
45% this one takes anything that can be typeset
46
47\unexpanded\def\setwidthof#1\to#2%
48  {\bgroup
49   \setbox\scratchbox\hbox{#1}%
50   \expanded{\egroup\def\noexpand#2{\the\wd\scratchbox}}}
51
52\protect \endinput
53
54% \starttext
55%
56% \startluacode
57%     local b = blobs.new()
58%     blobs.append(b,"Hello    world.\n Here we are.\n\n And Again!")
59%     blobs.pack(b)
60%     blobs.write(b)
61% \stopluacode
62%
63% \stoptext
64