diff options
Diffstat (limited to 'tex/context/base/mkxl/typo-shp.lmt')
-rw-r--r-- | tex/context/base/mkxl/typo-shp.lmt | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/tex/context/base/mkxl/typo-shp.lmt b/tex/context/base/mkxl/typo-shp.lmt new file mode 100644 index 000000000..27cafe1bd --- /dev/null +++ b/tex/context/base/mkxl/typo-shp.lmt @@ -0,0 +1,117 @@ +if not modules then modules = { } end modules ['meta-imp-txt'] = { + version = 1.001, + comment = "companion to meta-imp-txt.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files", +} + +local setmetatableindex = table.setmetatableindex +local settings_to_array = utilities.parsers.settings_to_array + +local texset = tex.set +local texgetcount = tex.getcount + +local expandmacro = token.expand_macro + +local implement = interfaces.implement + +local scan = mp.scan +local scannumeric = scan.numeric +local scaninteger = scan.integer +local scanboolean = scan.boolean +local scanstring = scan.string + +local bpfactor = number.dimenfactors.bp + +local context = context + +local parshapes = { } +local properties = { } + +metapost.registerscript("setparshapeproperty", function() + local k = scanstring() + if k == "line" then + local entry = properties.shape[scannumeric()] + local indent = scannumeric() / bpfactor + local width = scannumeric() / bpfactor + entry[1] = indent + entry[2] = width + elseif k == "lines" then + properties.lines = scaninteger() + properties.shape = setmetatableindex(function(t,k) + local v = { 0, properties.width or 0 } + t[k] = v + return v + end) + elseif k == "first" then + properties[k] = scanboolean() + elseif k == "inspect" then + inspect(properties) + else + properties[k] = scannumeric() / bpfactor + end +end) + +implement { + name = "setparagraphmetashape", + public = true, + protected = true, + arguments = { "optional", "optional" }, -- array + actions = function(list,options) + if list and list ~= "" then + list = settings_to_array(list) -- array + options = settings_to_array(options) -- array + if #list > 0 then + parshapes = { } + properties = { } + for i=1,#list do + properties = { } + parshapes[i] = properties + expandmacro("spac_shapes_calculate","{"..list[i].."}") + end + local t, n = { }, 0 + for i=1,#parshapes do + local p = parshapes[i] + local s = p.shape + if s then + for i=1,(p.lines or #s) do + n = n + 1 + t[n] = s[i] + end + end + end + if n > 0 then + for i=1,#options do + t[options[i]] = true + end + texset("parshape",t) + end + end + end + end +} + +-- implement { +-- name = "resetparagraphmetashape", +-- public = true, +-- protected = true, +-- actions = function(list) +-- parshapes = { } +-- properties = { } +-- end +-- } + +implement { + name = "getshapeparameter", + public = true, + arguments = "string", + actions = function(name) + local index = texgetcount("shapetextindex") + local value = parshapes[index][name] + if type(value) == "boolean" then + value = value and 1 or 0 + end + context(value) + end +} |