summaryrefslogtreecommitdiff
path: root/tex/context/base/l-dimen.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2011-01-31 18:40:12 +0200
committerMarius <mariausol@gmail.com>2011-01-31 18:40:12 +0200
commit8f0a9674137499392552a70d470f614f0eb98b6c (patch)
tree6d67600678dc90e269c2800f9609e78f307254a1 /tex/context/base/l-dimen.lua
parentcf65f174d2b790545f27134a5d41d39c942a1d5b (diff)
downloadcontext-8f0a9674137499392552a70d470f614f0eb98b6c.tar.gz
beta 2011.01.31 16:59
Diffstat (limited to 'tex/context/base/l-dimen.lua')
-rw-r--r--tex/context/base/l-dimen.lua23
1 files changed, 18 insertions, 5 deletions
diff --git a/tex/context/base/l-dimen.lua b/tex/context/base/l-dimen.lua
index 0d77d13d3..1c557bc49 100644
--- a/tex/context/base/l-dimen.lua
+++ b/tex/context/base/l-dimen.lua
@@ -169,7 +169,7 @@ local unit = P("pt") + P("cm") + P("mm") + P("sp") + P("bp") + P("in") +
local validdimen = amount * unit
-lpeg.patterns.validdimen = pattern
+lpeg.patterns.validdimen = validdimen
--[[ldx--
<p>This converter accepts calls like:</p>
@@ -329,9 +329,11 @@ function dimensions.texify() -- todo: %
if fti and fc then
dimenfactors["ex"] = function() return fti[fc()].ex_height end
dimenfactors["em"] = function() return fti[fc()].quad end
+ -- dimenfactors["%"] = function() return tex.dimen.hsize/100 end
else
- dimenfactors["ex"] = 1/65536* 4 -- 4pt
- dimenfactors["em"] = 1/65536*10 -- 10pt
+ dimenfactors["ex"] = 1/65536* 4 -- 4pt
+ dimenfactors["em"] = 1/65536*10 -- 10pt
+ -- dimenfactors["%"] = 1/65536* 4 -- 400pt/100
end
end
@@ -392,7 +394,7 @@ function dimen(a)
end
end
-function string.todimen(str)
+function string.todimen(str) -- maybe use tex.sp when available
if type(str) == "number" then
return str
else
@@ -400,7 +402,7 @@ function string.todimen(str)
if not k then
local value, unit = lpegmatch(dimenpair,str)
if value and unit then
- k = value/unit
+ k = value/unit -- to be considered: round
else
k = 0
end
@@ -411,6 +413,17 @@ function string.todimen(str)
end
end
+--~ local known = { }
+
+--~ function string.todimen(str) -- maybe use tex.sp
+--~ local k = known[str]
+--~ if not k then
+--~ k = tex.sp(str)
+--~ known[str] = k
+--~ end
+--~ return k
+--~ end
+
stringtodimen = string.todimen -- local variable defined earlier
function number.toscaled(d)