[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Import suggested fontloader fix from HH (008b218)

Marcel Fabian Krüger tex at 2krueger.de
Tue Mar 22 19:14:18 CET 2022


Repository : https://github.com/latex3/luaotfload
On branch  : dev
Link       : https://github.com/latex3/luaotfload/commit/008b218fe9ee0c2a8b4daaf32e0cf31ace225e3a

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

commit 008b218fe9ee0c2a8b4daaf32e0cf31ace225e3a
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Tue Mar 22 19:14:18 2022 +0100

    Import suggested fontloader fix from HH


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

008b218fe9ee0c2a8b4daaf32e0cf31ace225e3a
 build.lua                                   |   2 +-
 src/auto/luaotfload-status.lua              |  10 +-
 src/fontloader/misc/fontloader-font-ttf.lua | 235 ++++++++++++++++------------
 testfiles/aaaaa-luakern.tlg                 |   2 +-
 4 files changed, 141 insertions(+), 108 deletions(-)

diff --git a/build.lua b/build.lua
index 512e082..10aeff9 100644
--- a/build.lua
+++ b/build.lua
@@ -1,7 +1,7 @@
 
 packageversion= "3.22-dev"
 packagedate   = "2022-03-18"
-fontloaderdate= "2022-02-24"
+fontloaderdate= "2022-03-22"
 packagedesc   = ""
 
 module   = "luaotfload"
diff --git a/src/auto/luaotfload-status.lua b/src/auto/luaotfload-status.lua
index 604ba81..3159f5f 100644
--- a/src/auto/luaotfload-status.lua
+++ b/src/auto/luaotfload-status.lua
@@ -1,6 +1,6 @@
 return {
  ["hashes"]={
-  { "fontloader-2022-02-24.lua", "4dc8ce07471f8af7aa98d835df654768" },
+  { "fontloader-2022-03-22.lua", "de922cd18768e46f2831a03133c50a89" },
   { "fontloader-util-fil.lua", "d0accf4180201efd567816a25ad5e037" },
   { "fontloader-util-str.lua", "f4a9dd15c3e40cd3915749ac13837c95" },
   { "fontloader-l-unicode.lua", "f368874f11f3c525de5864fd413e4b24" },
@@ -44,7 +44,7 @@ return {
   { "fontloader-font-ott.lua", "3f67b1b1d40bbc222681d8db4aff0f42" },
   { "fontloader-font-oti.lua", "309a75f9c14b77d87e94eba827dc4e71" },
   { "fontloader-font-dsp.lua", "7616dae672693fd8ec0f1892358019a2" },
-  { "fontloader-font-ttf.lua", "feba1fdc80160343b24f89ef978e53cb" },
+  { "fontloader-font-ttf.lua", "a3ff07150b3535fd32f68748d53fcd36" },
   { "fontloader-font-cff.lua", "e38c1a40e1d1d577cdf7920fa50d0654" },
   { "fontloader-font-otr.lua", "91f70c1216e60227e1437b6c8dcd8647" },
   { "fontloader-font-vfc.lua", "a81c29eda98cd62cbebdb6c93544b50d" },
@@ -92,8 +92,8 @@ return {
  ["notes"]={
   ["committer"]="Marcel Fabian Krüger <tex at 2krueger.de>",
   ["description"]="v3.22-dev/2022-03-18",
-  ["loader"]="fontloader-2022-02-24.lua",
-  ["revision"]="f3b4cee7b284e3e9d780315400166c53a4579f55",
-  ["timestamp"]="2022-03-18 14:09:12 +0100",
+  ["loader"]="fontloader-2022-03-22.lua",
+  ["revision"]="5663c544650e9795fbf179f1e876cfbf1b34d8a9",
+  ["timestamp"]="2022-03-22 19:10:08 +0100",
  },
 }
diff --git a/src/fontloader/misc/fontloader-font-ttf.lua b/src/fontloader/misc/fontloader-font-ttf.lua
index a2658d5..d1a3972 100644
--- a/src/fontloader/misc/fontloader-font-ttf.lua
+++ b/src/fontloader/misc/fontloader-font-ttf.lua
@@ -247,115 +247,148 @@ local function applyaxis(glyph,shape,deltas,dowidth)
                         -- Not the most efficient solution but we seldom do this. We
                         -- actually need to avoid the extra points here but I'll deal
                         -- with that when needed.
-                        local function find(i)
-                            local prv = cnt
-                            for j=1,cnt do
-                                local nxt = dpoints[j]
-                                if nxt == i then
-                                    return false, j, false
-                                elseif nxt > i then
-                                    return prv, false, j
-                                end
-                                prv = j
-                            end
-                            return prv, false, 1
-                        end
-                        -- We need the first and last points untouched so we first
-                        -- collect data.
-                        for i=1,nofpoints do
-                            local d1, d2, d3 = find(i)
-                            local p2 = points[i]
-                            if d2 then
-                                xv[i] = xvalues[d2]
-                                yv[i] = yvalues[d2]
-                            else
-                                local n1 = dpoints[d1]
-                                local n3 = dpoints[d3]
-                                -- Some day I need to figure out these extra points but
-                                -- I'll wait till the standard is more clear and fonts
-                                -- become better (ntg-context: fraunces.ttf > abcdef).
-                                if n1 > nofpoints then
-                                    n1 = nofpoints
-                                end
-                                if n3 > nofpoints then
-                                    n3 = nofpoints
-                                end
-                                --
-                                local p1 = points[n1]
-                                local p3 = points[n3]
-                                local p1x = p1[1]
-                                local p2x = p2[1]
-                                local p3x = p3[1]
-                                local p1y = p1[2]
-                                local p2y = p2[2]
-                                local p3y = p3[2]
-                                local x1 = xvalues[d1]
-                                local y1 = yvalues[d1]
-                                local x3 = xvalues[d3]
-                                local y3 = yvalues[d3]
-                                --
-                                local fx
-                                local fy
-                                --
-                                if p1x == p3x then
-                                    if x1 == x3 then
-                                        fx = x1
-                                    else
-                                        fx = 0
-                                    end
-                                elseif p2x <= min(p1x,p3x) then
-                                    if p1x < p3x then
-                                        fx = x1
-                                    else
-                                        fx = x3
-                                    end
-                                elseif p2x >= max(p1x,p3x) then
-                                    if p1x > p3x then
-                                        fx = x1
-                                    else
-                                        fx = x3
+                        local contours    = shape.contours
+                        local nofcontours = #contours
+                        local first       = 1
+                        local firstindex  = 1
+                        for contour=1,nofcontours do
+                            local last = contours[contour]
+                            if last >= first then
+                                local lastindex = cnt
+                                if firstindex < cnt then
+                                    for currentindex=firstindex,cnt do
+                                        local found = dpoints[currentindex]
+                                        if found <= first then
+                                            firstindex = currentindex
+                                        end
+                                        if found == last then
+                                            lastindex = currentindex
+                                            break;
+                                        elseif found > last then
+                                            break
+                                        end
                                     end
-                                else
-                                    fx = (p2x - p1x)/(p3x - p1x)
-                                    fx = (1 - fx) * x1 + fx * x3
                                 end
-                                --
-                                if p1y == p3y then
-                                    if y1 == y3 then
-                                        fy = y1
-                                    else
-                                        fy = 0
-                                    end
-                                elseif p2y <= min(p1y,p3y) then
-                                    if p1y < p3y then
-                                        fy = y1
-                                    else
-                                        fy = y3
+                                -- print("unicode: ",glyph.unicode or "?")
+                                -- print("contour: ",first,contour,last)
+                                -- print("index  : ",firstindex,lastindex,cnt)
+                                -- print("points : ",dpoints[firstindex],dpoints[lastindex])
+                                local function find(i)
+                                    local prv = lastindex
+                                    for j=firstindex,lastindex do
+                                        local nxt = dpoints[j]
+                                        if nxt == i then
+                                            return false, j, false
+                                        elseif nxt > i then
+                                            return prv, false, j
+                                        end
+                                        prv = j
                                     end
-                                elseif p2y >= max(p1y,p3y) then
-                                    if p1y > p3y then
-                                        fy = y1
+                                    return prv, false, firstindex
+                                end
+                                -- We need the first and last points untouched so we first
+                                -- collect data.
+                                for point=first,last do
+                                    local d1, d2, d3 = find(point)
+                                    local p2 = points[point]
+                                    if d2 then
+                                        xv[point] = xvalues[d2]
+                                        yv[point] = yvalues[d2]
                                     else
-                                        fy = y3
+                                        local n1 = dpoints[d1]
+                                        local n3 = dpoints[d3]
+                                        -- Some day I need to figure out these extra points but
+                                        -- I'll wait till the standard is more clear and fonts
+                                        -- become better (ntg-context: fraunces.ttf > abcdef).
+                                        if n1 > nofpoints then
+                                            n1 = nofpoints
+                                        end
+                                        if n3 > nofpoints then
+                                            n3 = nofpoints
+                                        end
+                                        --
+                                        local p1 = points[n1]
+                                        local p3 = points[n3]
+                                        local p1x = p1[1]
+                                        local p2x = p2[1]
+                                        local p3x = p3[1]
+                                        local p1y = p1[2]
+                                        local p2y = p2[2]
+                                        local p3y = p3[2]
+                                        local x1 = xvalues[d1]
+                                        local y1 = yvalues[d1]
+                                        local x3 = xvalues[d3]
+                                        local y3 = yvalues[d3]
+                                        --
+                                        local fx
+                                        local fy
+                                        --
+                                        if p1x == p3x then
+                                            if x1 == x3 then
+                                                fx = x1
+                                            else
+                                                fx = 0
+                                            end
+                                        elseif p2x <= min(p1x,p3x) then
+                                            if p1x < p3x then
+                                                fx = x1
+                                            else
+                                                fx = x3
+                                            end
+                                        elseif p2x >= max(p1x,p3x) then
+                                            if p1x > p3x then
+                                                fx = x1
+                                            else
+                                                fx = x3
+                                            end
+                                        else
+                                            fx = (p2x - p1x)/(p3x - p1x)
+                                            fx = (1 - fx) * x1 + fx * x3
+                                        end
+                                        --
+                                        if p1y == p3y then
+                                            if y1 == y3 then
+                                                fy = y1
+                                            else
+                                                fy = 0
+                                            end
+                                        elseif p2y <= min(p1y,p3y) then
+                                            if p1y < p3y then
+                                                fy = y1
+                                            else
+                                                fy = y3
+                                            end
+                                        elseif p2y >= max(p1y,p3y) then
+                                            if p1y > p3y then
+                                                fy = y1
+                                            else
+                                                fy = y3
+                                            end
+                                        else
+                                            fy = (p2y - p1y)/(p3y - p1y)
+                                            fy = (1 - fy) * y1 + fy * y3
+                                        end
+                                     -- -- maybe:
+                                     -- if p1y ~= p3y then
+                                     --     fy = (p2y - p1y)/(p3y - p1y)
+                                     --     fy = (1 - fy) * y1 + fy * y3
+                                     -- elseif abs(p1y-p2y) < abs(p3y-p2y) then
+                                     --     fy = y1
+                                     -- else
+                                     --     fy = y3
+                                     -- end
+                                        --
+                                        xv[point] = fx
+                                        yv[point] = fy
                                     end
-                                else
-                                    fy = (p2y - p1y)/(p3y - p1y)
-                                    fy = (1 - fy) * y1 + fy * y3
                                 end
-                             -- -- maybe:
-                             -- if p1y ~= p3y then
-                             --     fy = (p2y - p1y)/(p3y - p1y)
-                             --     fy = (1 - fy) * y1 + fy * y3
-                             -- elseif abs(p1y-p2y) < abs(p3y-p2y) then
-                             --     fy = y1
-                             -- else
-                             --     fy = y3
-                             -- end
-                                --
-                                xv[i] = fx
-                                yv[i] = fy
+                                if lastindex < cnt then
+                                    firstindex = lastindex + 1
+                                end
                             end
+                            first = last + 1
                         end
+
                         for i=1,nofpoints do
                             local pi = points[i]
                             local fx = xv[i]
diff --git a/testfiles/aaaaa-luakern.tlg b/testfiles/aaaaa-luakern.tlg
index 3a4cd04..2328f87 100644
--- a/testfiles/aaaaa-luakern.tlg
+++ b/testfiles/aaaaa-luakern.tlg
@@ -1,6 +1,6 @@
 This is a generated file for the l3build validation system.
 Don't change this file in any respect.
-3.22-dev with fontloaderxxx2022xxx02xxx24.lua
+3.22-dev with fontloaderxxx2022xxx03xxx22.lua
 Completed box being shipped out [1]
 \vbox(633.0+0.0)x407.0, direction TLT
 .\glue 16.0





More information about the latex3-commits mailing list.