summaryrefslogtreecommitdiff
path: root/tex/context/base/font-gds.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/font-gds.lua')
-rw-r--r--tex/context/base/font-gds.lua59
1 files changed, 30 insertions, 29 deletions
diff --git a/tex/context/base/font-gds.lua b/tex/context/base/font-gds.lua
index b4b073433..3b87e4c77 100644
--- a/tex/context/base/font-gds.lua
+++ b/tex/context/base/font-gds.lua
@@ -8,39 +8,44 @@ if not modules then modules = { } end modules ['font-gds'] = {
-- depends on ctx
-local type, next, tonumber = type, next, tonumber
+local type, next = type, next
local gmatch, format, lower, find, splitup = string.gmatch, string.format, string.lower, string.find, string.splitup
local texsp = tex.sp
local fonts, nodes, attributes, node = fonts, nodes, attributes, node
-local trace_goodies = false trackers.register("fonts.goodies", function(v) trace_goodies = v end)
+local trace_goodies = false
+
+trackers.register("fonts.goodies", function(v) trace_goodies = v end)
+
local report_goodies = logs.reporter("fonts","goodies")
local allocate = utilities.storage.allocate
local otf = fonts.handlers.otf
-local afm = fonts.handlers.afm
-local tfm = fonts.handlers.tfm
+local addotffeature = otf.enhancers.addfeature
+
+local otffeatures = fonts.constructors.newfeatures("otf")
+local registerotffeature = otffeatures.register
+
+local afmfeatures = fonts.constructors.newfeatures("afm")
+local registerafmfeature = afmfeatures.register
-local registerotffeature = otf.features.register
-local registerafmfeature = afm.features.register
-local registertfmfeature = tfm.features.register
+local tfmfeatures = fonts.constructors.newfeatures("tfm")
+local registertfmfeature = tfmfeatures.register
-local fontgoodies = fonts.goodies or { }
+local fontgoodies = { }
fonts.goodies = fontgoodies
-local typefaces = fonts.typefaces or allocate()
+local typefaces = allocate()
fonts.typefaces = typefaces
-local data = fontgoodies.data or allocate()
-fontgoodies.data = data
+local data = allocate()
+fontgoodies.data = fontgoodies.data
-local list = fontgoodies.list or { }
+local list = { }
fontgoodies.list = list -- no allocate as we want to see what is there
-local addotffeature = otf.enhancers.addfeature
-
function fontgoodies.report(what,trace,goodies)
if trace_goodies or trace then
local whatever = goodies[what]
@@ -136,7 +141,7 @@ end
-- fonts.features.flattened = flattenedfeatures
-local function prepare_features(goodies,name,set)
+function fontgoodies.prepare_features(goodies,name,set)
if set then
local ff = flattenedfeatures(set)
local fullname = goodies.name .. "::" .. name
@@ -149,8 +154,6 @@ local function prepare_features(goodies,name,set)
end
end
-fontgoodies.prepare_features = prepare_features
-
local function initialize(goodies,tfmdata)
local featuresets = goodies.featuresets
local goodiesname = goodies.name
@@ -159,7 +162,7 @@ local function initialize(goodies,tfmdata)
report_goodies("checking featuresets in '%s'",goodies.name)
end
for name, set in next, featuresets do
- prepare_features(goodies,name,set)
+ fontgoodies.prepare_features(goodies,name,set)
end
end
end
@@ -174,7 +177,7 @@ local function setfeatureset(tfmdata,set,features)
for i=1,#goodies do
-- last one wins
local g = goodies[i]
- what = g.featuresets and g.featuresets[set] or what
+ what = (g.featuresets and g.featuresets[set]) or what
end
if what then
for feature, value in next, what do
@@ -190,13 +193,12 @@ end
-- postprocessors (we could hash processor and share code)
function fontgoodies.registerpostprocessor(tfmdata,f,prepend)
- local postprocessors = tfmdata.postprocessors
- if not postprocessors then
+ if not tfmdata.postprocessors then
tfmdata.postprocessors = { f }
elseif prepend then
- table.insert(postprocessors,f,1)
+ table.insert(tfmdata.postprocessors,f,1)
else
- table.insert(postprocessors,f)
+ table.insert(tfmdata.postprocessors,f)
end
end
@@ -234,9 +236,9 @@ end
-- colorschemes
-local colorschemes = fontgoodies.colorschemes or allocate { }
+local colorschemes = { }
fontgoodies.colorschemes = colorschemes
-colorschemes.data = colorschemes.data or { }
+colorschemes.data = { }
local function setcolorscheme(tfmdata,scheme)
if type(scheme) == "string" then
@@ -247,7 +249,7 @@ local function setcolorscheme(tfmdata,scheme)
for i=1,#goodies do
-- last one counts
local g = goodies[i]
- what = g.colorschemes and g.colorschemes[scheme] or what
+ what = (g.colorschemes and g.colorschemes[scheme]) or what
end
if type(what) == "table" then
-- this is font bound but we can share them if needed
@@ -603,10 +605,9 @@ end
fontgoodies.register("compositions", initialize)
-local designsizes = fontgoodies.designsizes or allocate()
+local designsizes = { }
fontgoodies.designsizes = designsizes
-
-local designdata = designsizes.data or allocate()
+local designdata = allocate()
designsizes.data = designdata
local function initialize(goodies) -- design sizes are registered global