summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/font-otj.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/font-otj.lua62
1 files changed, 51 insertions, 11 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua b/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua
index 2e7878d3dfd..bb02044dca6 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['font-otj'] = {
version = 1.001,
+ optimize = true,
comment = "companion to font-lib.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -110,7 +111,7 @@ local properties = nodes.properties.data
local fontkern = nuts.pool and nuts.pool.fontkern -- context
local italickern = nuts.pool and nuts.pool.italickern -- context
-local useitalickerns = false
+local useitalickerns = false -- context only
directives.register("fonts.injections.useitalics", function(v)
if v then
@@ -119,7 +120,7 @@ directives.register("fonts.injections.useitalics", function(v)
useitalickerns = v
end)
-do if not fontkern then -- generic
+if not fontkern then -- generic
local thekern = nuts.new("kern",0) -- fontkern
local setkern = nuts.setkern
@@ -131,9 +132,9 @@ do if not fontkern then -- generic
return n
end
-end end
+end
-do if not italickern then -- generic
+if not italickern then -- generic
local thekern = nuts.new("kern",3) -- italiccorrection
local setkern = nuts.setkern
@@ -145,7 +146,7 @@ do if not italickern then -- generic
return n
end
-end end
+end
function injections.installnewkern() end -- obsolete
@@ -664,7 +665,15 @@ local function inject_kerns_only(head,where)
-- left|glyph|right
local leftkern = i.leftkern
if leftkern and leftkern ~= 0 then
- head = insert_node_before(head,current,fontkern(leftkern))
+ if prev and getid(prev) == glue_code then
+ if useitalickerns then
+ head = insert_node_before(head,current,italickern(leftkern))
+ else
+ setwidth(prev, getwidth(prev) + leftkern)
+ end
+ else
+ head = insert_node_before(head,current,fontkern(leftkern))
+ end
end
end
if prevdisc then
@@ -819,12 +828,26 @@ local function inject_positions_only(head,where)
if rightkern and leftkern == -rightkern then
setoffsets(current,leftkern,false)
rightkern = 0
+ elseif prev and getid(prev) == glue_code then
+ if useitalickerns then
+ head = insert_node_before(head,current,italickern(leftkern))
+ else
+ setwidth(prev, getwidth(prev) + leftkern)
+ end
else
head = insert_node_before(head,current,fontkern(leftkern))
end
end
if rightkern and rightkern ~= 0 then
- insert_node_after(head,current,fontkern(rightkern))
+ if next and getid(next) == glue_code then
+ if useitalickerns then
+ insert_node_after(head,current,italickern(rightkern))
+ else
+ setwidth(next, getwidth(next) + rightkern)
+ end
+ else
+ insert_node_after(head,current,fontkern(rightkern))
+ end
end
else
local i = p.emptyinjections
@@ -1270,12 +1293,26 @@ local function inject_everything(head,where)
if rightkern and leftkern == -rightkern then
setoffsets(current,leftkern,false)
rightkern = 0
+ elseif prev and getid(prev) == glue_code then
+ if useitalickerns then
+ head = insert_node_before(head,current,italickern(leftkern))
+ else
+ setwidth(prev, getwidth(prev) + leftkern)
+ end
else
head = insert_node_before(head,current,fontkern(leftkern))
end
end
if rightkern and rightkern ~= 0 then
- insert_node_after(head,current,fontkern(rightkern))
+ if next and getid(next) == glue_code then
+ if useitalickerns then
+ insert_node_after(head,current,italickern(rightkern))
+ else
+ setwidth(next, getwidth(next) + rightkern)
+ end
+ else
+ insert_node_after(head,current,fontkern(rightkern))
+ end
end
end
else
@@ -1518,7 +1555,7 @@ local function inject_everything(head,where)
end
--
if keepregisteredcounts then
- keepregisteredcounts = false
+ keepregisteredcounts = false
else
nofregisteredkerns = 0
nofregisteredpositions = 0
@@ -1707,16 +1744,18 @@ local function injectspaces(head)
if useitalickerns then
local new = rightkern * factor
if trace_spaces then
- report_spaces("%C [%p + %p]",nextchar,old,new)
+ report_spaces("[%p + %p] %C",old,new,nextchar)
end
insert_node_after(head,n,italickern(new))
else
local new = old + rightkern * factor
if trace_spaces then
- report_spaces("[%p -> %p] %C",nextchar,old,new)
+ report_spaces("[%p -> %p] %C",old,new,nextchar)
end
setwidth(n,new)
end
+ else
+ -- message
end
rightkern = false
end
@@ -1753,3 +1792,4 @@ function injections.handler(head,where)
return head
end
end
+