[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Fix fallback for fonts without space glyph (a4f3e26)

Marcel Fabian Krüger tex at 2krueger.de
Wed May 12 17:48:24 CEST 2021


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

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

commit a4f3e269942d37f92cd03792bf9cd2b8a09fd7f8
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Wed May 12 17:48:05 2021 +0200

    Fix fallback for fonts without space glyph
    
    Fixes #186.


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

a4f3e269942d37f92cd03792bf9cd2b8a09fd7f8
 src/luaotfload-harf-define.lua | 20 ++++++++++++--------
 src/luaotfload-harf-plug.lua   |  2 +-
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/luaotfload-harf-define.lua b/src/luaotfload-harf-define.lua
index 8855440..1a338aa 100644
--- a/src/luaotfload-harf-define.lua
+++ b/src/luaotfload-harf-define.lua
@@ -71,7 +71,7 @@ local get_designsize do
 end
 
 local containers = luaotfload.fontloader.containers
-local hbcacheversion = 1.1
+local hbcacheversion = 1.2
 local facecache = containers.define("fonts", "hb", hbcacheversion, true)
 
 local function loadfont(spec)
@@ -119,7 +119,8 @@ local function loadfont(spec)
     local descender = fontextents and fontextents.descender or upem * .2
 
     local gid = hbfont:get_nominal_glyph(0x0020)
-    local space = gid and hbfont:get_glyph_h_advance(gid) or upem / 2
+    local real_space = hbfont:get_glyph_h_advance(gid or 0)
+    local tex_space = gid and real_space or upem / 2
 
     local slant = 0
     if haspost then
@@ -214,7 +215,8 @@ local function loadfont(spec)
       gid_offset = 0x120000,
       upem = upem,
       fonttype = fonttype,
-      space = space,
+      real_space = real_space,
+      tex_space = tex_space,
       xheight = xheight,
       capheight = capheight,
       slant = slant,
@@ -260,7 +262,8 @@ local function scalefont(data, spec)
   local hbface = data.face
   local hbfont = data.font
   local upem = data.upem
-  local space = data.space
+  local tex_space = data.tex_space
+  local real_space = data.real_space
   local gid_offset = data.gid_offset
 
   if size < 0 then
@@ -321,15 +324,16 @@ local function scalefont(data, spec)
     characters = characters,
     parameters = {
       slant = data.slant,
-      space = space * scale,
-      space_stretch = space * scale / 2,
-      space_shrink = space * scale / 3,
+      space = tex_space * scale,
+      space_stretch = tex_space * scale / 2,
+      space_shrink = tex_space * scale / 3,
       x_height = data.xheight * scale,
       quad = size,
-      extra_space = space * scale / 3,
+      extra_space = tex_space * scale / 3,
       [8] = data.capheight * scale, -- for XeTeX compatibility.
     },
     hb = {
+      space = (real_space * scale + .5) // 1,
       scale = scale,
       palette = palette,
       shared = data,
diff --git a/src/luaotfload-harf-plug.lua b/src/luaotfload-harf-plug.lua
index 6fe518a..d949be2 100644
--- a/src/luaotfload-harf-plug.lua
+++ b/src/luaotfload-harf-plug.lua
@@ -737,7 +737,6 @@ local function tonodes(head, node, run, glyphs)
   local dir = run.dir
   local fontid = run.font
   local fontdata = font.getfont(fontid)
-  local space = fontdata.parameters.space
   local characters = fontdata.characters
   local hbdata = fontdata.hb
   local hfactor = (fontdata.extend or 1000) / 1000
@@ -752,6 +751,7 @@ local function tonodes(head, node, run, glyphs)
   local lastprops
 
   local scale = hbdata.scale
+  local space = hbdata.space
 
   local haspng = hbshared.haspng
   local fonttype = hbshared.fonttype





More information about the latex3-commits mailing list.