summaryrefslogtreecommitdiff
path: root/tex/context/base/node-typ.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2009-09-21 17:39:00 +0200
committerHans Hagen <pragma@wxs.nl>2009-09-21 17:39:00 +0200
commitd237f3e4386c910e8960a9ec6cba2e7f59d1268a (patch)
tree14086ffb61006758a55d47b684b850465233fe1c /tex/context/base/node-typ.lua
parent0c00e8e4486fe1cc526eee6df2e4b9b3ab0ba519 (diff)
downloadcontext-d237f3e4386c910e8960a9ec6cba2e7f59d1268a.tar.gz
beta 2009.09.21 17:39
Diffstat (limited to 'tex/context/base/node-typ.lua')
-rw-r--r--tex/context/base/node-typ.lua51
1 files changed, 51 insertions, 0 deletions
diff --git a/tex/context/base/node-typ.lua b/tex/context/base/node-typ.lua
new file mode 100644
index 000000000..2562378d1
--- /dev/null
+++ b/tex/context/base/node-typ.lua
@@ -0,0 +1,51 @@
+if not modules then modules = { } end modules ['node-typ'] = {
+ version = 1.001,
+ comment = "companion to node-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local utfvalues = string.utfvalues
+
+local newglyph = nodes.glyph
+local newglue = nodes.glue
+
+local hpack, vpack = node.hpack, node.vpack
+
+typesetting = typesetting or { }
+
+local function tonodes(str,fontid,spacing)
+ local head, prev = nil, nil
+ for s in utfvalues(str) do
+ local next
+ if spacing and s == 32 then
+ next = newglue(spacing or 64*1024*10)
+ else
+ next = newglyph(fontid or 1,s)
+ end
+ if not head then
+ head = next
+ else
+ prev.next = next
+ next.prev = prev
+ end
+ prev = next
+ end
+ return head
+end
+
+typesetting.tonodes = tonodes
+
+function typesetting.hpack(str,fontid,spacing)
+ return hpack(tonodes(str,fontid,spacing))
+end
+
+function typesetting.vpack(str,fontid,spacing)
+ -- vpack is just a hack, and a proper implentation is on the agenda
+ -- as it needs more info etc than currently available
+ return vpack(tonodes(str,fontid,spacing))
+end
+
+--~ node.write(typesetting.hpack("Hello World!"))
+--~ node.write(typesetting.hpack("Hello World!",1,100*1024*10))