summaryrefslogtreecommitdiff
path: root/tex/context/base/node-typ.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2010-07-04 15:32:09 +0300
committerMarius <mariausol@gmail.com>2010-07-04 15:32:09 +0300
commit85b7bc695629926641c7cb752fd478adfdf374f3 (patch)
tree80293f5aaa7b95a500a78392c39688d8ee7a32fc /tex/context/base/node-typ.lua
downloadcontext-85b7bc695629926641c7cb752fd478adfdf374f3.tar.gz
stable 2010-05-24 13:10
Diffstat (limited to 'tex/context/base/node-typ.lua')
-rw-r--r--tex/context/base/node-typ.lua53
1 files changed, 53 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..5ab6b6975
--- /dev/null
+++ b/tex/context/base/node-typ.lua
@@ -0,0 +1,53 @@
+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"
+}
+
+-- this will be replaced by blob-ini cum suis so typesetting will go away
+
+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) -- don't use this
+ 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))