[latex3-commits] [git/LaTeX3-latex3-luaotfload] fix-cff2: Fix multiple ItemVariationData subtable CFF2 fonts (18e81f3)

Marcel Fabian Krüger tex at 2krueger.de
Tue Jan 5 17:35:08 CET 2021


Repository : https://github.com/latex3/luaotfload
On branch  : fix-cff2
Link       : https://github.com/latex3/luaotfload/commit/18e81f37f5c4526aa1d2992ab52c11d8d348428a

>---------------------------------------------------------------

commit 18e81f37f5c4526aa1d2992ab52c11d8d348428a
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Tue Jan 5 12:10:55 2021 +0100

    Fix multiple ItemVariationData subtable CFF2 fonts


>---------------------------------------------------------------

18e81f37f5c4526aa1d2992ab52c11d8d348428a
 src/auto/fontloader-2020-12-30.lua          | 54 +++++++++++++++--------------
 src/fontloader/misc/fontloader-font-cff.lua |  8 +++--
 src/fontloader/misc/fontloader-font-dsp.lua | 48 ++++++++++++-------------
 3 files changed, 57 insertions(+), 53 deletions(-)

diff --git a/src/auto/fontloader-2020-12-30.lua b/src/auto/fontloader-2020-12-30.lua
index 835eca6..ec84903 100644
--- a/src/auto/fontloader-2020-12-30.lua
+++ b/src/auto/fontloader-2020-12-30.lua
@@ -10540,7 +10540,7 @@ do
  local reginit=false
  local function updateregions(n) 
   if regions then
-   local current=regions[n] or regions[1]
+   local current=regions[n+1] or regions[1]
    nofregions=#current
    if axis and n~=reginit then
     factors={}
@@ -11109,7 +11109,11 @@ do
   popped=3
   seacs={}
   if regions then
-   regions={ regions } 
+   regions={}
+   local deltas=data.deltas
+   for i=1,#deltas do
+    regions[i]=deltas[i].regions
+   end
    axis=data.factors or false
   end
  end
@@ -13096,30 +13100,28 @@ local function readvariationdata(f,storeoffset,factors)
   end
   regions[i]=t
  end
- if factors then
-  for i=1,nofdeltadata do
-   setposition(f,storeoffset+deltadata[i])
-   local nofdeltasets=readushort(f)
-   local nofshorts=readushort(f)
-   local nofregions=readushort(f)
-   local usedregions={}
-   local deltas={}
-   for i=1,nofregions do
-    usedregions[i]=regions[readushort(f)+1]
-   end
-   for i=1,nofdeltasets do
-    local t=readintegertable(f,nofshorts,short)
-    for i=nofshorts+1,nofregions do
-     t[i]=readinteger(f)
-    end
-    deltas[i]=t
-   end
-   deltadata[i]={
-    regions=usedregions,
-    deltas=deltas,
-    scales=factors and getscales(usedregions,factors) or nil,
-   }
-  end
+ for i=1,nofdeltadata do
+  setposition(f,storeoffset+deltadata[i])
+  local nofdeltasets=readushort(f)
+  local nofshorts=readushort(f)
+  local nofregions=readushort(f)
+  local usedregions={}
+  local deltas={}
+  for i=1,nofregions do
+   usedregions[i]=regions[readushort(f)+1]
+  end
+  for i=1,nofdeltasets do
+   local t=readintegertable(f,nofshorts,short)
+   for i=nofshorts+1,nofregions do
+    t[i]=readinteger(f)
+   end
+   deltas[i]=t
+  end
+  deltadata[i]={
+   regions=usedregions,
+   deltas=deltas,
+   scales=factors and getscales(usedregions,factors) or nil,
+  }
  end
  setposition(f,position)
  return regions,deltadata
diff --git a/src/fontloader/misc/fontloader-font-cff.lua b/src/fontloader/misc/fontloader-font-cff.lua
index b7d4539..112acab 100644
--- a/src/fontloader/misc/fontloader-font-cff.lua
+++ b/src/fontloader/misc/fontloader-font-cff.lua
@@ -1431,7 +1431,7 @@ do
 
     local function updateregions(n) -- n + 1
         if regions then
-            local current = regions[n] or regions[1]
+            local current = regions[n + 1] or regions[1]
             nofregions = #current
             if axis and n ~= reginit then
                 factors = { }
@@ -2155,7 +2155,11 @@ do
         popped   = 3
         seacs    = { }
         if regions then
-            regions = { regions } -- needs checking
+            regions = { }
+            local deltas = data.deltas
+            for i = 1, #deltas do
+                regions[i] = deltas[i].regions
+            end
             axis = data.factors or false
         end
     end
diff --git a/src/fontloader/misc/fontloader-font-dsp.lua b/src/fontloader/misc/fontloader-font-dsp.lua
index 91ee83b..12ab521 100644
--- a/src/fontloader/misc/fontloader-font-dsp.lua
+++ b/src/fontloader/misc/fontloader-font-dsp.lua
@@ -503,31 +503,29 @@ local function readvariationdata(f,storeoffset,factors) -- store
         regions[i] = t
     end
     -- deltas
-    if factors then
-        for i=1,nofdeltadata do
-            setposition(f,storeoffset+deltadata[i])
-            local nofdeltasets = readushort(f)
-            local nofshorts    = readushort(f)
-            local nofregions   = readushort(f)
-            local usedregions  = { }
-            local deltas       = { }
-            for i=1,nofregions do
-                usedregions[i] = regions[readushort(f)+1]
-            end
-            -- we could test before and save a for
-            for i=1,nofdeltasets do
-                local t = readintegertable(f,nofshorts,short)
-                for i=nofshorts+1,nofregions do
-                    t[i] = readinteger(f)
-                end
-                deltas[i] = t
-            end
-            deltadata[i] = {
-                regions = usedregions,
-                deltas  = deltas,
-                scales  = factors and getscales(usedregions,factors) or nil,
-            }
-        end
+    for i=1,nofdeltadata do
+        setposition(f,storeoffset+deltadata[i])
+        local nofdeltasets = readushort(f)
+        local nofshorts    = readushort(f)
+        local nofregions   = readushort(f)
+        local usedregions  = { }
+        local deltas       = { }
+        for i=1,nofregions do
+            usedregions[i] = regions[readushort(f)+1]
+        end
+        -- we could test before and save a for
+        for i=1,nofdeltasets do
+            local t = readintegertable(f,nofshorts,short)
+            for i=nofshorts+1,nofregions do
+                t[i] = readinteger(f)
+            end
+            deltas[i] = t
+        end
+        deltadata[i] = {
+            regions = usedregions,
+            deltas  = deltas,
+            scales  = factors and getscales(usedregions,factors) or nil,
+        }
     end
     setposition(f,position)
     return regions, deltadata





More information about the latex3-commits mailing list.