summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/font-dsp.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-04-13 15:51:39 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2018-04-13 15:51:39 +0200
commit25fcad7435f56cdce2658336909f4da6a65589c0 (patch)
treec23d5d04a7e86c7ddc2ebeca06d3de63ebdc806e /tex/context/base/mkiv/font-dsp.lua
parent1e5d7f41ddede5e6400a2a7762032823d3545df4 (diff)
downloadcontext-25fcad7435f56cdce2658336909f4da6a65589c0.tar.gz
2018-04-13 15:02:00
Diffstat (limited to 'tex/context/base/mkiv/font-dsp.lua')
-rw-r--r--tex/context/base/mkiv/font-dsp.lua34
1 files changed, 10 insertions, 24 deletions
diff --git a/tex/context/base/mkiv/font-dsp.lua b/tex/context/base/mkiv/font-dsp.lua
index 02e5a7df6..77b2b7ff0 100644
--- a/tex/context/base/mkiv/font-dsp.lua
+++ b/tex/context/base/mkiv/font-dsp.lua
@@ -68,7 +68,7 @@ local reversed = table.reversed
local sort = table.sort
local insert = table.insert
local round = math.round
-local lpegmatch = lpeg.match
+local settings_to_hash_colon_too = table.settings_to_hash_colon_too
local setmetatableindex = table.setmetatableindex
local formatters = string.formatters
@@ -300,30 +300,16 @@ end)
-- wght:400,wdth:100,ital:1
--- local names = table.setmetatableindex ( {
--- weight = "wght",
--- width = "wdth",
--- italic = "ital",
--- }, "self")
-
--- todo: spaces in name but not before :
-
-local pattern = lpeg.Cf (
- lpeg.Ct("") *
- lpeg.Cg (
- --(lpeg.R("az")^1/names) * lpeg.S(" :") *
- lpeg.C((lpeg.R("az","09")+lpeg.P(" "))^1) * lpeg.S(" :=") *
- (lpeg.patterns.number/tonumber) * lpeg.S(" ,")^0
- )^1, rawset
-)
+local function axistofactors(str)
+ local t = settings_to_hash_colon_too(str)
+ for k, v in next, t do
+ t[k] = tonumber(v) or v -- this also normalizes numbers itself
+ end
+ return t
+end
local hash = table.setmetatableindex(function(t,k)
- local v = lpegmatch(pattern,k)
- local t = { }
- for k, v in sortedhash(v) do
- t[#t+1] = k .. "=" .. v
- end
- v = concat(t,",")
+ local v = sequenced(axistofactors(k),",")
t[k] = v
return v
end)
@@ -341,7 +327,7 @@ function helpers.normalizedaxis(str)
end
local function axistofactors(str)
- return lpegmatch(pattern,str)
+ return settings_to_hash_colon_too(str)
end
-- contradicting spec ... (signs) so i'll check it and fix it once we have