summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/font-con.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/font-con.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/font-con.lua130
1 files changed, 64 insertions, 66 deletions
diff --git a/Master/texmf-dist/tex/context/base/font-con.lua b/Master/texmf-dist/tex/context/base/font-con.lua
index 92809968857..618bc8f2856 100644
--- a/Master/texmf-dist/tex/context/base/font-con.lua
+++ b/Master/texmf-dist/tex/context/base/font-con.lua
@@ -6,11 +6,8 @@ if not modules then modules = { } end modules ['font-con'] = {
license = "see context related readme files"
}
-
-- some names of table entries will be changed (no _)
-local utf = unicode.utf8
-
local next, tostring, rawget = next, tostring, rawget
local format, match, lower, gsub = string.format, string.match, string.lower, string.gsub
local utfbyte = utf.byte
@@ -29,15 +26,11 @@ local report_defining = logs.reporter("fonts","defining")
--ldx]]--
local fonts = fonts
-local constructors = { }
+local constructors = fonts.constructors or { }
fonts.constructors = constructors
-local handlers = { }
+local handlers = fonts.handlers or { } -- can have preloaded tables
fonts.handlers = handlers
-local specifiers = fonts.specifiers
-local contextsetups = specifiers.contextsetups
-local contextnumbers = specifiers.contextnumbers
-
local allocate = utilities.storage.allocate
local setmetatableindex = table.setmetatableindex
@@ -358,6 +351,10 @@ function constructors.scale(tfmdata,specification)
elseif forcedsize > 1000 then -- safeguard
scaledpoints = forcedsize
end
+ targetparameters.mathsize = mathsize -- context specific
+ targetparameters.textsize = textsize -- context specific
+ targetparameters.forcedsize = forcedsize -- context specific
+ targetparameters.extrafactor = extrafactor -- context specific
--
local tounicode = resources.tounicode
local defaultwidth = resources.defaultwidth or 0
@@ -418,6 +415,8 @@ function constructors.scale(tfmdata,specification)
target.psname = psname
target.name = name
--
+ -- inspect(properties)
+ --
properties.fontname = fontname
properties.fullname = fullname
properties.filename = filename
@@ -507,59 +506,51 @@ function constructors.scale(tfmdata,specification)
local scaledheight = defaultheight * vdelta
local scaleddepth = defaultdepth * vdelta
--
- if trace_defining then
- report_defining("scaling by (%s,%s): name '%s', fullname: '%s', filename: '%s'",
- hdelta,vdelta,name or "noname",fullname or "nofullname",filename or "nofilename")
- end
- --
local hasmath = (properties.hasmath or next(mathparameters)) and true
+ --
if hasmath then
- if trace_defining then
- report_defining("math enabled for: name '%s', fullname: '%s', filename: '%s'",
- name or "noname",fullname or "nofullname",filename or "nofilename")
- end
constructors.assignmathparameters(target,tfmdata) -- does scaling and whatever is needed
properties.hasmath = true
target.nomath = false
target.MathConstants = target.mathparameters
else
- if trace_defining then
- report_defining("math disabled for: name '%s', fullname: '%s', filename: '%s'",
- name or "noname",fullname or "nofullname",filename or "nofilename")
- end
properties.hasmath = false
target.nomath = true
target.mathparameters = nil -- nop
end
--
- local italickey = "italic"
+ local italickey = "italic"
+ local useitalics = true -- something context
--
-- some context specific trickery (this will move to a plugin)
--
if hasmath then
- if properties.mathitalics then
- italickey = "italic_correction"
- if trace_defining then
- report_defining("math italics disabled for: name '%s', fullname: '%s', filename: '%s'",
- name or "noname",fullname or "nofullname",filename or "nofilename")
- end
- end
+ -- the latest luatex can deal with it itself so we now disable this
+ -- mechanism here
+ --
+ -- if properties.mathitalics then
+ -- italickey = "italic_correction"
+ -- if trace_defining then
+ -- report_defining("math italics disabled for font %a, fullname %a, filename %a",name,fullname,filename)
+ -- end
+ -- end
autoitalicamount = false -- new
- else
- if properties.textitalics then
- italickey = "italic_correction"
- if trace_defining then
- report_defining("text italics disabled for: name '%s', fullname: '%s', filename: '%s'",
- name or "noname",fullname or "nofullname",filename or "nofilename")
- end
- if properties.delaytextitalics then
- autoitalicamount = false
- end
+ elseif properties.textitalics then
+ italickey = "italic_correction"
+ useitalics = false
+ if properties.delaytextitalics then
+ autoitalicamount = false
end
end
--
-- end of context specific trickery
--
+ if trace_defining then
+ report_defining("defining tfm, name %a, fullname %a, filename %a, hscale %a, vscale %a, math %a, italics %a",
+ name,fullname,filename,hdelta,vdelta,
+ hasmath and "enabled" or "disabled",useitalics and "enabled" or "disabled")
+ end
+ --
constructors.beforecopyingcharacters(target,tfmdata)
--
local sharedkerns = { }
@@ -641,9 +632,6 @@ function constructors.scale(tfmdata,specification)
if touni then
chr.tounicode = touni
end
- -- if trace_scaling then
- -- report_defining("t=%s, u=%s, i=%s, n=%s c=%s",k,chr.tounicode or "",index or 0,description.name or '-',description.class or '-')
- -- end
if hasquality then
-- we could move these calculations elsewhere (saves calculations)
local ve = character.expansion_factor
@@ -682,9 +670,6 @@ function constructors.scale(tfmdata,specification)
local vn = character.next
if vn then
chr.next = vn
- -- if character.vert_variants or character.horiz_variants then
- -- report_defining("glyph U+%05X has combination of next, vert_variants and horiz_variants",index)
- -- end
else
local vv = character.vert_variants
if vv then
@@ -977,7 +962,11 @@ hashmethods.normal = function(list)
local s = { }
local n = 0
for k, v in next, list do
- if k ~= "number" and k ~= "features" then -- I need to figure this out, features
+ if not k then
+ -- no need to add to hash
+ elseif k == "number" or k == "features" then
+ -- no need to add to hash (maybe we need a skip list)
+ else
n = n + 1
s[n] = k
end
@@ -1034,7 +1023,7 @@ function constructors.setname(tfmdata,specification) -- todo: get specification
if specname then
tfmdata.properties.name = specname
if trace_defining then
- report_otf("overloaded fontname: '%s'",specname)
+ report_otf("overloaded fontname %a",specname)
end
end
end
@@ -1048,10 +1037,10 @@ function constructors.checkedfilename(data)
askedfilename = resolvers.resolve(askedfilename) -- no shortcut
foundfilename = resolvers.findbinfile(askedfilename,"") or ""
if foundfilename == "" then
- report_defining("source file '%s' is not found",askedfilename)
+ report_defining("source file %a is not found",askedfilename)
foundfilename = resolvers.findbinfile(file.basename(askedfilename),"") or ""
if foundfilename ~= "" then
- report_defining("using source file '%s' (cache mismatch)",foundfilename)
+ report_defining("using source file %a due to cache mismatch",foundfilename)
end
end
end
@@ -1069,7 +1058,7 @@ setmetatableindex(formats, function(t,k)
t[k] = l
return l
end
- return rawget(t,file.extname(l))
+ return rawget(t,file.suffix(l))
end)
local locations = { }
@@ -1077,7 +1066,7 @@ local locations = { }
local function setindeed(mode,target,group,name,action,position)
local t = target[mode]
if not t then
- report_defining("fatal error in setting feature '%s', group '%s', mode '%s'",name or "?",group or "?",mode)
+ report_defining("fatal error in setting feature %a, group %a, mode %a",name,group,mode)
os.exit()
elseif position then
-- todo: remove existing
@@ -1097,12 +1086,12 @@ end
local function set(group,name,target,source)
target = target[group]
if not target then
- report_defining("fatal target error in setting feature '%s', group '%s'",name or "?",group or "?")
+ report_defining("fatal target error in setting feature %a, group %a",name,group)
os.exit()
end
local source = source[group]
if not source then
- report_defining("fatal source error in setting feature '%s', group '%s'",name or "?",group or "?")
+ report_defining("fatal source error in setting feature %a, group %a",name,group)
os.exit()
end
local node = source.node
@@ -1166,19 +1155,31 @@ function constructors.getfeatureaction(what,where,mode,name)
end
end
-function constructors.newfeatures(what)
- local features = handlers[what].features
+function constructors.newhandler(what) -- could be a metatable newindex
+ local handler = handlers[what]
+ if not handler then
+ handler = { }
+ handlers[what] = handler
+ end
+ return handler
+end
+
+function constructors.newfeatures(what) -- could be a metatable newindex
+ local handler = handlers[what]
+ local features = handler.features
if not features then
- local tables = handlers[what].tables -- can be preloaded
+ local tables = handler.tables -- can be preloaded
+ local statistics = handler.statistics -- can be preloaded
features = allocate {
defaults = { },
descriptions = tables and tables.features or { },
+ used = statistics and statistics.usedfeatures or { },
initializers = { base = { }, node = { } },
processors = { base = { }, node = { } },
manipulators = { base = { }, node = { } },
}
features.register = function(specification) return register(features,specification) end
- handlers[what].features = features -- will also become hidden
+ handler.features = features -- will also become hidden
end
return features
end
@@ -1234,8 +1235,8 @@ function constructors.initializefeatures(what,tfmdata,features,trace,report)
else
local action = step.action
if trace then
- report("initializing feature %s to %s for mode %s for font %s",feature,
- tostring(value),mode or 'unknown', tfmdata.properties.fullname or 'unknown')
+ report("initializing feature %a to %a for mode %a for font %a",feature,
+ value,mode,tfmdata.properties.fullname)
end
action(tfmdata,value,features) -- can set mode (e.g. goodies) so it can trigger a restart
if mode ~= properties.mode or mode ~= features.mode then
@@ -1285,8 +1286,7 @@ function constructors.collectprocessors(what,tfmdata,features,trace,report)
if features[feature] then
local action = step.action
if trace then
- report("installing feature processor %s for mode %s for font %s",feature,
- mode or 'unknown', tfmdata.properties.fullname or 'unknown')
+ report("installing feature processor %a for mode %a for font %a",feature,mode,tfmdata.properties.fullname)
end
if action then
nofprocesses = nofprocesses + 1
@@ -1295,8 +1295,7 @@ function constructors.collectprocessors(what,tfmdata,features,trace,report)
end
end
elseif trace then
- report("no feature processors for mode %s for font %s",
- mode or 'unknown', tfmdata.properties.fullname or 'unknown')
+ report("no feature processors for mode %a for font %a",mode,tfmdata.properties.fullname)
end
end
return processes
@@ -1319,8 +1318,7 @@ function constructors.applymanipulators(what,tfmdata,features,trace,report)
if value then
local action = step.action
if trace then
- report("applying feature manipulator %s for mode %s for font %s",feature,
- mode or 'unknown', tfmdata.properties.fullname or 'unknown')
+ report("applying feature manipulator %a for mode %a for font %a",feature,mode,tfmdata.properties.fullname)
end
if action then
action(tfmdata,feature,value)