diff options
author | Hans Hagen <pragma@wxs.nl> | 2020-03-28 15:51:51 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2020-03-28 15:51:51 +0100 |
commit | dd8e1bab358884db6ba3f2373f515fbcc991e5ee (patch) | |
tree | dc8e018098300a0b77cb1a0aa3d2d3c1947ccb41 /tex/context/base/mkiv/font-otj.lua | |
parent | d9aa299de0f736f75f90b98ab284e5bc73515949 (diff) | |
download | context-dd8e1bab358884db6ba3f2373f515fbcc991e5ee.tar.gz |
2020-03-28 14:35:00
Diffstat (limited to 'tex/context/base/mkiv/font-otj.lua')
-rw-r--r-- | tex/context/base/mkiv/font-otj.lua | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/tex/context/base/mkiv/font-otj.lua b/tex/context/base/mkiv/font-otj.lua index 2e7878d3d..bb333755d 100644 --- a/tex/context/base/mkiv/font-otj.lua +++ b/tex/context/base/mkiv/font-otj.lua @@ -110,7 +110,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 +119,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 +131,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 +145,7 @@ do if not italickern then -- generic return n end -end end +end function injections.installnewkern() end -- obsolete @@ -664,7 +664,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 +827,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 +1292,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 @@ -1707,16 +1743,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 +1791,4 @@ function injections.handler(head,where) return head end end + |