Skip to content

Commit

Permalink
Fix multiple ItemVariationData subtable CFF2 fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
zauguin committed Jan 5, 2021
1 parent 11868f3 commit 18e81f3
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 53 deletions.
54 changes: 28 additions & 26 deletions src/auto/fontloader-2020-12-30.lua
Expand Up @@ -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={}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/fontloader/misc/fontloader-font-cff.lua
Expand Up @@ -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 = { }
Expand Down Expand Up @@ -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
Expand Down
48 changes: 23 additions & 25 deletions src/fontloader/misc/fontloader-font-dsp.lua
Expand Up @@ -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
Expand Down

0 comments on commit 18e81f3

Please sign in to comment.