From f7bfb1deb04d4ad101dbabf4d635d33cd98aa0a1 Mon Sep 17 00:00:00 2001
From: Hans Hagen <pragma@wxs.nl>
Date: Mon, 17 Jul 2017 01:36:30 +0200
Subject: 2017-07-17 00:26:00

---
 doc/context/documents/general/qrcs/setup-cs.pdf    | Bin 845154 -> 845141 bytes
 doc/context/documents/general/qrcs/setup-de.pdf    | Bin 843043 -> 843046 bytes
 doc/context/documents/general/qrcs/setup-en.pdf    | Bin 848082 -> 848080 bytes
 doc/context/documents/general/qrcs/setup-fr.pdf    | Bin 841718 -> 841716 bytes
 doc/context/documents/general/qrcs/setup-it.pdf    | Bin 843460 -> 843454 bytes
 doc/context/documents/general/qrcs/setup-nl.pdf    | Bin 840162 -> 840152 bytes
 doc/context/documents/general/qrcs/setup-ro.pdf    | Bin 840226 -> 840220 bytes
 .../general/manuals/luatex/luatex-fonts.tex        |  14 +++++-
 tex/context/base/mkii/cont-new.mkii                |   2 +-
 tex/context/base/mkii/context.mkii                 |   2 +-
 tex/context/base/mkiv/cont-new.mkiv                |   2 +-
 tex/context/base/mkiv/context.mkiv                 |   2 +-
 tex/context/base/mkiv/font-ext.lua                 |   2 +
 tex/context/base/mkiv/font-otc.lua                 |   9 +++-
 tex/context/base/mkiv/font-oup.lua                 |  50 +++++++++++----------
 tex/context/base/mkiv/font-pre.mkiv                |   1 +
 tex/context/base/mkiv/status-files.pdf             | Bin 25727 -> 25716 bytes
 tex/context/base/mkiv/status-lua.pdf               | Bin 426070 -> 426097 bytes
 tex/context/interface/mkiv/i-context.pdf           | Bin 848082 -> 848080 bytes
 tex/context/interface/mkiv/i-readme.pdf            | Bin 60775 -> 60774 bytes
 tex/generic/context/luatex/luatex-fonts-merged.lua |  49 +++++++++++---------
 21 files changed, 82 insertions(+), 51 deletions(-)

diff --git a/doc/context/documents/general/qrcs/setup-cs.pdf b/doc/context/documents/general/qrcs/setup-cs.pdf
index b0efe5166..af319574c 100644
Binary files a/doc/context/documents/general/qrcs/setup-cs.pdf and b/doc/context/documents/general/qrcs/setup-cs.pdf differ
diff --git a/doc/context/documents/general/qrcs/setup-de.pdf b/doc/context/documents/general/qrcs/setup-de.pdf
index 1b8051948..5bda40d3f 100644
Binary files a/doc/context/documents/general/qrcs/setup-de.pdf and b/doc/context/documents/general/qrcs/setup-de.pdf differ
diff --git a/doc/context/documents/general/qrcs/setup-en.pdf b/doc/context/documents/general/qrcs/setup-en.pdf
index f2b57f4a7..2cc4b4461 100644
Binary files a/doc/context/documents/general/qrcs/setup-en.pdf and b/doc/context/documents/general/qrcs/setup-en.pdf differ
diff --git a/doc/context/documents/general/qrcs/setup-fr.pdf b/doc/context/documents/general/qrcs/setup-fr.pdf
index 068a60857..c406ad762 100644
Binary files a/doc/context/documents/general/qrcs/setup-fr.pdf and b/doc/context/documents/general/qrcs/setup-fr.pdf differ
diff --git a/doc/context/documents/general/qrcs/setup-it.pdf b/doc/context/documents/general/qrcs/setup-it.pdf
index 3164026fa..a91d4f1a9 100644
Binary files a/doc/context/documents/general/qrcs/setup-it.pdf and b/doc/context/documents/general/qrcs/setup-it.pdf differ
diff --git a/doc/context/documents/general/qrcs/setup-nl.pdf b/doc/context/documents/general/qrcs/setup-nl.pdf
index 6c49f5ffc..324def4de 100644
Binary files a/doc/context/documents/general/qrcs/setup-nl.pdf and b/doc/context/documents/general/qrcs/setup-nl.pdf differ
diff --git a/doc/context/documents/general/qrcs/setup-ro.pdf b/doc/context/documents/general/qrcs/setup-ro.pdf
index 888ba4e29..4aea060b3 100644
Binary files a/doc/context/documents/general/qrcs/setup-ro.pdf and b/doc/context/documents/general/qrcs/setup-ro.pdf differ
diff --git a/doc/context/sources/general/manuals/luatex/luatex-fonts.tex b/doc/context/sources/general/manuals/luatex/luatex-fonts.tex
index 44d913cea..76e7bd108 100644
--- a/doc/context/sources/general/manuals/luatex/luatex-fonts.tex
+++ b/doc/context/sources/general/manuals/luatex/luatex-fonts.tex
@@ -94,6 +94,17 @@ font in \type {font.fonts}. It is the actual expansion factor (a value between
 \type {-shrink} and \type {stretch}, with step \type {step}) of a font that was
 automatically generated by the font expansion algorithm.
 
+Because we store the actual state of expansion with each glyph and don't have
+special font instances, we can change some font related parameters before lines
+are constructed, like:
+
+\starttyping
+font.setexpansion(font.current(),100,100,20)
+\stoptyping
+
+This is mostly meant for experiments (or an optimizing routing written in \LUA)
+so there is no primitive.
+
 The key \type {attributes} can be used to set font attributes in the \PDF\ file.
 The key \type {used} is set by the engine when a font is actively in use, this
 makes sure that the font's definition is written to the output file (\DVI\ or
@@ -472,7 +483,8 @@ parameters to that command. The allowed commands and their arguments are:
 \NC right   \NC 1   \NC number    \NC move right on the page\NC\NR
 \NC special \NC 1   \NC string    \NC output a \type {\special} command\NC\NR
 \NC pdf     \NC 2   \NC 2 strings \NC output a \PDF\ literal, the first string is one of \type {origin},
-                                      \type {page}, \type {direct} or \type {raw}\NC\NR
+                                      \type {page}, \type {direct} or \type {raw}; if you have one string
+                                      only \type {origin} is assumed \NC\NR
 \NC lua     \NC 1   \NC string    \NC execute a \LUA\ script (at \type {\latelua} time)\NC\NR
 \NC image   \NC 1   \NC image     \NC output an image (the argument can be either an \type
                                       {<image>} variable or an \type {image_spec} table)\NC\NR
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii
index ef89a2e2b..9c02951b9 100644
--- a/tex/context/base/mkii/cont-new.mkii
+++ b/tex/context/base/mkii/cont-new.mkii
@@ -11,7 +11,7 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\newcontextversion{2017.07.16 12:08}
+\newcontextversion{2017.07.17 00:20}
 
 %D This file is loaded at runtime, thereby providing an
 %D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii
index c8c537e1f..b6ffca4a5 100644
--- a/tex/context/base/mkii/context.mkii
+++ b/tex/context/base/mkii/context.mkii
@@ -20,7 +20,7 @@
 %D your styles an modules.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2017.07.16 12:08}
+\edef\contextversion{2017.07.17 00:20}
 
 %D For those who want to use this:
 
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index 73554a80f..94b08824b 100644
--- a/tex/context/base/mkiv/cont-new.mkiv
+++ b/tex/context/base/mkiv/cont-new.mkiv
@@ -11,7 +11,7 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\newcontextversion{2017.07.16 12:08}
+\newcontextversion{2017.07.17 00:20}
 
 %D This file is loaded at runtime, thereby providing an excellent place for
 %D hacks, patches, extensions and new features.
diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv
index e20b29168..802d4fa29 100644
--- a/tex/context/base/mkiv/context.mkiv
+++ b/tex/context/base/mkiv/context.mkiv
@@ -41,7 +41,7 @@
 %D up and the dependencies are more consistent.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2017.07.16 12:08}
+\edef\contextversion{2017.07.17 00:20}
 \edef\contextkind   {beta}
 
 %D For those who want to use this:
diff --git a/tex/context/base/mkiv/font-ext.lua b/tex/context/base/mkiv/font-ext.lua
index d008cf235..8e0971ca6 100644
--- a/tex/context/base/mkiv/font-ext.lua
+++ b/tex/context/base/mkiv/font-ext.lua
@@ -747,6 +747,8 @@ local push  = { "push" }
 local pop   = { "pop" }
 local gray  = { "pdf", "origin", ".75 g" }
 local black = { "pdf", "origin", "0 g"   }
+-- local gray  = { "pdf", ".75 g" }
+-- local black = { "pdf", "0 g"   }
 
 local downcache = { } -- handy for huge cjk fonts
 local rulecache = { } -- handy for huge cjk fonts
diff --git a/tex/context/base/mkiv/font-otc.lua b/tex/context/base/mkiv/font-otc.lua
index b7c296809..4a26820f3 100644
--- a/tex/context/base/mkiv/font-otc.lua
+++ b/tex/context/base/mkiv/font-otc.lua
@@ -405,7 +405,7 @@ local function addfeature(data,feature,specifications)
         return coverage
     end
 
-    local prepare_single = prepare_pair
+    local prepare_single = prepare_pair -- we could have a better test on the spec
 
     local function prepare_chain(list,featuretype,sublookups)
         -- todo: coveractions
@@ -604,6 +604,7 @@ local function addfeature(data,feature,specifications)
             local steps         = { }
             local sublookups    = specification.lookups
             local category      = nil
+            --
             if sublookups then
                 local s = { }
                 for i=1,#sublookups do
@@ -640,6 +641,9 @@ local function addfeature(data,feature,specifications)
                             steps[nofsteps] = register(coverage,featuretype,format,feature,nofsteps,descriptions,resources)
                         end
                     end
+                    --
+                    setmetatableindex(steps,fonts.helpers.mergesteps) -- speedup
+                    --
                     s[i] = {
                         [stepkey] = steps,
                         nofsteps  = nofsteps,
@@ -699,6 +703,9 @@ local function addfeature(data,feature,specifications)
                         askedfeatures[k] = tohash(v)
                     end
                 end
+                --
+                setmetatableindex(steps,fonts.helpers.mergesteps) -- speedup
+                --
                 if featureflags[1] then featureflags[1] = "mark" end
                 if featureflags[2] then featureflags[2] = "ligature" end
                 if featureflags[3] then featureflags[3] = "base" end
diff --git a/tex/context/base/mkiv/font-oup.lua b/tex/context/base/mkiv/font-oup.lua
index 9f4ded5b5..6084d1941 100644
--- a/tex/context/base/mkiv/font-oup.lua
+++ b/tex/context/base/mkiv/font-oup.lua
@@ -1376,7 +1376,7 @@ function readers.pack(data)
                                         step.coverage = pack_normal(c)
                                     else
                                         for g1, d1 in next, c do
-                                            if d1 ~= true then
+                                            if d1 and d1 ~= true then
                                                 c[g1] = pack_indexed(d1)
                                             end
                                         end
@@ -2383,6 +2383,32 @@ function readers.compact(data)
     end
 end
 
+local function mergesteps(t,k)
+    if k == "merged" then
+        local merged = { }
+        for i=1,#t do
+            local step     = t[i]
+            local coverage = step.coverage
+            for k in next, coverage do
+                local m = merged[k]
+                if m then
+                    m[2] = i
+                 -- m[#m+1] = step
+                else
+                    merged[k] = { i, i }
+                 -- merged[k] = { step }
+                end
+            end
+        end
+        t.merged = merged
+        return merged
+    end
+end
+
+if fonts.helpers then
+    fonts.helpers.mergesteps = mergesteps
+end
+
 function readers.expand(data)
     if not data or data.expanded then
         return
@@ -2429,28 +2455,6 @@ function readers.expand(data)
     -- about 15% on arabtype .. then moving the a test also saves a bit (even when
     -- often a is not set at all so that one is a bit debatable
 
-    local function mergesteps(t,k)
-        if k == "merged" then
-            local merged = { }
-            for i=1,#t do
-                local step     = t[i]
-                local coverage = step.coverage
-                for k in next, coverage do
-                    local m = merged[k]
-                    if m then
-                        m[2] = i
-                     -- m[#m+1] = step
-                    else
-                        merged[k] = { i, i }
-                     -- merged[k] = { step }
-                    end
-                end
-            end
-            t.merged = merged
-            return merged
-        end
-    end
-
     local function expandlookups(sequences)
         if sequences then
             -- we also need to do sublookups
diff --git a/tex/context/base/mkiv/font-pre.mkiv b/tex/context/base/mkiv/font-pre.mkiv
index ead98e391..d9e367a2b 100644
--- a/tex/context/base/mkiv/font-pre.mkiv
+++ b/tex/context/base/mkiv/font-pre.mkiv
@@ -736,6 +736,7 @@
 \definefontfeature[f:oldstyle] [onum=yes]
 \definefontfeature[f:tabular]  [tnum=yes]
 \definefontfeature[f:superiors][sups=yes]
+\definefontfeature[f:inferiors][subs=yes]
 \definefontfeature[f:fractions][frac=yes]
 \definefontfeature[f:kern]     [kern=yes]
 \definefontfeature[f:kerns]    [kern=yes]
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 46f3be41e..a233248a0 100644
Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index d29dcd024..52156f07e 100644
Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ
diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf
index f2b57f4a7..2cc4b4461 100644
Binary files a/tex/context/interface/mkiv/i-context.pdf and b/tex/context/interface/mkiv/i-context.pdf differ
diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf
index 4d3ea3867..90c08a129 100644
Binary files a/tex/context/interface/mkiv/i-readme.pdf and b/tex/context/interface/mkiv/i-readme.pdf differ
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 1557ce22d..a8a7889ca 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
 -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua
 -- parent file : c:/data/develop/context/sources/luatex-fonts.lua
--- merge date  : 07/16/17 12:08:43
+-- merge date  : 07/17/17 00:20:46
 
 do -- begin closure to overcome local limits and interference
 
@@ -18508,7 +18508,7 @@ function readers.pack(data)
                     step.coverage=pack_normal(c)
                   else
                     for g1,d1 in next,c do
-                      if d1~=true then
+                      if d1 and d1~=true then
                         c[g1]=pack_indexed(d1)
                       end
                     end
@@ -19376,6 +19376,28 @@ function readers.compact(data)
     report("%i steps of %i steps turned from pairs into kerns",kerned,allsteps)
   end
 end
+local function mergesteps(t,k)
+  if k=="merged" then
+    local merged={}
+    for i=1,#t do
+      local step=t[i]
+      local coverage=step.coverage
+      for k in next,coverage do
+        local m=merged[k]
+        if m then
+          m[2]=i
+        else
+          merged[k]={ i,i }
+        end
+      end
+    end
+    t.merged=merged
+    return merged
+  end
+end
+if fonts.helpers then
+  fonts.helpers.mergesteps=mergesteps
+end
 function readers.expand(data)
   if not data or data.expanded then
     return
@@ -19414,25 +19436,6 @@ function readers.expand(data)
       end
     end
   end
-  local function mergesteps(t,k)
-    if k=="merged" then
-      local merged={}
-      for i=1,#t do
-        local step=t[i]
-        local coverage=step.coverage
-        for k in next,coverage do
-          local m=merged[k]
-          if m then
-            m[2]=i
-          else
-            merged[k]={ i,i }
-          end
-        end
-      end
-      t.merged=merged
-      return merged
-    end
-  end
   local function expandlookups(sequences)
     if sequences then
       for i=1,#sequences do
@@ -29107,7 +29110,7 @@ local function addfeature(data,feature,specifications)
     end
     return coverage
   end
-  local prepare_single=prepare_pair
+  local prepare_single=prepare_pair 
   local function prepare_chain(list,featuretype,sublookups)
     local rules=list.rules
     local coverage={}
@@ -29332,6 +29335,7 @@ local function addfeature(data,feature,specifications)
               steps[nofsteps]=register(coverage,featuretype,format,feature,nofsteps,descriptions,resources)
             end
           end
+          setmetatableindex(steps,fonts.helpers.mergesteps)
           s[i]={
             [stepkey]=steps,
             nofsteps=nofsteps,
@@ -29390,6 +29394,7 @@ local function addfeature(data,feature,specifications)
             askedfeatures[k]=tohash(v)
           end
         end
+        setmetatableindex(steps,fonts.helpers.mergesteps)
         if featureflags[1] then featureflags[1]="mark" end
         if featureflags[2] then featureflags[2]="ligature" end
         if featureflags[3] then featureflags[3]="base" end
-- 
cgit v1.2.3