summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/font-ext.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/font-ext.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/font-ext.lua76
1 files changed, 44 insertions, 32 deletions
diff --git a/Master/texmf-dist/tex/context/base/font-ext.lua b/Master/texmf-dist/tex/context/base/font-ext.lua
index 331ffbdfa91..89d5927d40b 100644
--- a/Master/texmf-dist/tex/context/base/font-ext.lua
+++ b/Master/texmf-dist/tex/context/base/font-ext.lua
@@ -6,11 +6,12 @@ if not modules then modules = { } end modules ['font-ext'] = {
license = "see context related readme files"
}
-local utf = unicode.utf8
local next, type, byte = next, type, string.byte
local gmatch, concat, format = string.gmatch, table.concat, string.format
local utfchar = utf.char
-local getparameters = utilities.parsers.getparameters
+
+local commands, context = commands, context
+local fonts, utilities = fonts, utilities
local trace_protrusion = false trackers.register("fonts.protrusion", function(v) trace_protrusion = v end)
local trace_expansion = false trackers.register("fonts.expansion", function(v) trace_expansion = v end)
@@ -26,17 +27,19 @@ will depend of the font format. Here we define the few that are kind
of neutral.</p>
--ldx]]--
-local fonts = fonts
-local fontdata = fonts.hashes.identifiers
+local handlers = fonts.handlers
+local hashes = fonts.hashes
+local otf = handlers.otf
-local otffeatures = fonts.constructors.newfeatures("otf")
-local registerotffeature = otffeatures.register
+local registerotffeature = handlers.otf.features.register
+local registerafmfeature = handlers.afm.features.register
-local afmfeatures = fonts.constructors.newfeatures("afm")
-local registerafmfeature = afmfeatures.register
+local fontdata = hashes.identifiers
local allocate = utilities.storage.allocate
local settings_to_array = utilities.parsers.settings_to_array
+local getparameters = utilities.parsers.getparameters
+
local setmetatableindex = table.setmetatableindex
-- -- -- -- -- --
@@ -62,14 +65,15 @@ end
-- expansion (hz)
-- -- -- -- -- --
-fonts.expansions = allocate()
-local expansions = fonts.expansions
+local expansions = fonts.expansions or allocate()
-expansions.classes = allocate()
-local classes = expansions.classes
+fonts.expansions = expansions
-expansions.vectors = allocate()
-local vectors = expansions.vectors
+local classes = expansions.classes or allocate()
+local vectors = expansions.vectors or allocate()
+
+expansions.classes = classes
+expansions.vectors = vectors
-- beware, pdftex itself uses percentages * 10
@@ -107,7 +111,7 @@ local function initializeexpansion(tfmdata,value)
local step = class.step or 0
local factor = class.factor or 1
if trace_expansion then
- report_expansions("setting class %s, vector: %s, factor: %s, stretch: %s, shrink: %s, step: %s",
+ report_expansions("setting class %a, vector %a, factor %a, stretch %a, shrink %a, step %a",
value,class.vector,factor,stretch,shrink,step)
end
tfmdata.parameters.expansion = {
@@ -140,10 +144,10 @@ local function initializeexpansion(tfmdata,value)
end
end
elseif trace_expansion then
- report_expansions("unknown vector '%s' in class '%s",class.vector,value)
+ report_expansions("unknown vector %a in class %a",class.vector,value)
end
elseif trace_expansion then
- report_expansions("unknown class '%s'",value)
+ report_expansions("unknown class %a",value)
end
end
end
@@ -345,14 +349,14 @@ local function map_opbd_onto_protrusion(tfmdata,value,opbd)
local data = lookuphash[lookup]
if data then
if trace_protrusion then
- report_protrusions("setting left using lfbd lookup '%s'",lookup)
+ report_protrusions("setting left using lfbd lookup %a",lookup)
end
for k, v in next, data do
-- local p = - v[3] / descriptions[k].width-- or 1 ~= 0 too but the same
local p = - (v[1] / 1000) * factor * left
characters[k].left_protruding = p
if trace_protrusion then
- report_protrusions("lfbd -> %s -> U+%05X (%s) -> %0.03f (%s)",lookup,k,utfchar(k),p,concat(v," "))
+ report_protrusions("lfbd -> %s -> %C -> %0.03f (% t)",lookup,k,p,v)
end
end
done = true
@@ -368,14 +372,14 @@ local function map_opbd_onto_protrusion(tfmdata,value,opbd)
local data = lookuphash[lookup]
if data then
if trace_protrusion then
- report_protrusions("setting right using rtbd lookup '%s'",lookup)
+ report_protrusions("setting right using rtbd lookup %a",lookup)
end
for k, v in next, data do
-- local p = v[3] / descriptions[k].width -- or 3
local p = (v[1] / 1000) * factor * right
characters[k].right_protruding = p
if trace_protrusion then
- report_protrusions("rtbd -> %s -> U+%05X (%s) -> %0.03f (%s)",lookup,k,utfchar(k),p,concat(v," "))
+ report_protrusions("rtbd -> %s -> %C -> %0.03f (% t)",lookup,k,p,v)
end
end
end
@@ -383,9 +387,15 @@ local function map_opbd_onto_protrusion(tfmdata,value,opbd)
end
end
end
- tfmdata.parameters.protrusion {
- auto = true
- }
+ local parameters = tfmdata.parameters
+ local protrusion = tfmdata.protrusion
+ if not protrusion then
+ parameters.protrusion = {
+ auto = true
+ }
+ else
+ protrusion.auto = true
+ end
end
-- The opbd test is just there because it was discussed on the
@@ -407,7 +417,7 @@ local function initializeprotrusion(tfmdata,value)
local left = class.left or 1
local right = class.right or 1
if trace_protrusion then
- report_protrusions("setting class %s, vector: %s, factor: %s, left: %s, right: %s",
+ report_protrusions("setting class %a, vector %a, factor %a, left %a, right %a",
value,class.vector,factor,left,right)
end
local data = characters.data
@@ -448,10 +458,10 @@ local function initializeprotrusion(tfmdata,value)
end
end
elseif trace_protrusion then
- report_protrusions("unknown vector '%s' in class '%s",class.vector,value)
+ report_protrusions("unknown vector %a in class %a",class.vector,value)
end
elseif trace_protrusion then
- report_protrusions("unknown class '%s'",value)
+ report_protrusions("unknown class %a",value)
end
end
end
@@ -880,8 +890,8 @@ local new_glyph = nodes.pool.glyph
local hpack_node = node.hpack
function fonts.helpers.addprivate(tfmdata,name,characterdata)
- local properties = tfmdata.properties
- local privates = properties.privates
+ local properties = tfmdata.properties
+ local privates = properties.privates
local lastprivate = properties.lastprivate
if lastprivate then
lastprivate = lastprivate + 1
@@ -892,7 +902,9 @@ function fonts.helpers.addprivate(tfmdata,name,characterdata)
privates = { }
properties.privates = privates
end
- privates[name] = lastprivate
+ if name then
+ privates[name] = lastprivate
+ end
properties.lastprivate = lastprivate
tfmdata.characters[lastprivate] = characterdata
if properties.finalized then
@@ -903,7 +915,7 @@ end
function fonts.helpers.getprivatenode(tfmdata,name)
local properties = tfmdata.properties
- local privates = properties and properties.privates
+ local privates = properties and properties.privates
if privates then
local p = privates[name]
if p then
@@ -925,7 +937,7 @@ end
function fonts.helpers.hasprivate(tfmdata,name)
local properties = tfmdata.properties
- local privates = properties and properties.privates
+ local privates = properties and properties.privates
return privates and privates[name] or false
end