[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Adjust font dimensions (6a4f977)

Marcel Fabian Krüger tex at 2krueger.de
Sun Feb 23 04:38:56 CET 2020


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

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

commit 6a4f9770e20012758696f175b9a556accd40f330
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Sun Feb 23 04:37:53 2020 +0100

    Adjust font dimensions


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

6a4f9770e20012758696f175b9a556accd40f330
 src/luaotfload-harf-plug.lua |  3 ++-
 src/luaotfload-szss.lua      | 52 +++++++++++++++++++++++++++++++++++---------
 testfiles-harf/features.tpf  | 10 ++++-----
 3 files changed, 49 insertions(+), 16 deletions(-)

diff --git a/src/luaotfload-harf-plug.lua b/src/luaotfload-harf-plug.lua
index cd79986..5f79af2 100644
--- a/src/luaotfload-harf-plug.lua
+++ b/src/luaotfload-harf-plug.lua
@@ -622,6 +622,7 @@ local function tonodes(head, node, run, glyphs)
   local space = fontdata.parameters.space
   local characters = fontdata.characters
   local hbdata = fontdata.hb
+  local hfactor = (fontdata.extend or 1000) / 1000
   local palette = hbdata.palette
   local hbshared = hbdata.shared
   local hbface = hbshared.face
@@ -832,7 +833,7 @@ local function tonodes(head, node, run, glyphs)
             setprop(node, endactual_p, true)
           end
           local x_advance = glyph.x_advance
-          local width = fontglyph.width
+          local width = fontglyph.width * hfactor
           if width ~= x_advance then
             -- The engine always uses the glyph width from the font, so we need
             -- to insert a kern node if the x advance is different.
diff --git a/src/luaotfload-szss.lua b/src/luaotfload-szss.lua
index 9546822..e0a23a5 100644
--- a/src/luaotfload-szss.lua
+++ b/src/luaotfload-szss.lua
@@ -83,32 +83,48 @@ otfregister {
 -- harf-only features (for node they are implemented in the fontloader
 
 otfregister {
-  name = 'slant',
-  description = 'Fake slant',
+  name = 'extend',
+  description = 'Fake extend',
   default = false,
   manipulators = {
-    plug = function(tfmdata, _, value, ...)
+    plug = function(tfmdata, _, value)
       value = tonumber(value)
       if not value then
-        error[[Invalid slant value]]
+        error[[Invalid extend value]]
+      end
+      tfmdata.extend = value * 1000
+      tfmdata.hb.hscale = tfmdata.units_per_em * value
+      local parameters = tfmdata.parameters
+      parameters.slant = parameters.slant * value
+      parameters.space = parameters.space * value
+      parameters.space_stretch = parameters.space_stretch * value
+      parameters.space_shrink = parameters.space_shrink * value
+      parameters.quad = parameters.quad * value
+      parameters.extra_space = parameters.extra_space * value
+      local done = {}
+      for _, char in next, tfmdata.characters do
+        if char.width and not done[char] then
+          char.width = char.width * value
+          done[char] = true
+        end
       end
-      tfmdata.slant = value * 1000
     end,
   },
 }
 
 otfregister {
-  name = 'extend',
-  description = 'Fake bold',
+  name = 'slant',
+  description = 'Fake slant',
   default = false,
   manipulators = {
     plug = function(tfmdata, _, value)
       value = tonumber(value)
       if not value then
-        error[[Invalid extend value]]
+        error[[Invalid slant value]]
       end
-      tfmdata.extend = value * 1000
-      tfmdata.hb.hscale = tfmdata.units_per_em * value
+      tfmdata.slant = value * 1000
+      local parameters = tfmdata.parameters
+      parameters.slant = parameters.slant + value * 65536
     end,
   },
 }
@@ -125,6 +141,22 @@ otfregister {
       end
       tfmdata.squeeze = value * 1000
       tfmdata.hb.vscale = tfmdata.units_per_em * value
+      local parameters = tfmdata.parameters
+      parameters.slant = parameters.slant / value
+      parameters.x_height = parameters.x_height * value
+      parameters[8] = parameters[8] * value
+      local done = {}
+      for _, char in next, tfmdata.characters do
+        if not done[char] then
+          if char.height then
+            char.height = char.height * value
+          end
+          if char.depth then
+            char.depth = char.depth * value
+          end
+          done[char] = true
+        end
+      end
     end,
   },
 }
diff --git a/testfiles-harf/features.tpf b/testfiles-harf/features.tpf
index c69e958..a2aca3f 100644
--- a/testfiles-harf/features.tpf
+++ b/testfiles-harf/features.tpf
@@ -5,15 +5,15 @@
 stream
 BT
 /F26 9.96264 Tf
-1 0 0 1 148.712 707.125 Tm [<001C0023>-28<002B>]TJ
+1 0 0 1 148.712 706.717 Tm [<001C0023>-28<002B>]TJ
 /F26 9.96264 Tf
-1 0 1 1 167.253 707.125 Tm [<002F00320037>]TJ
+1 0 1 1 167.253 706.717 Tm [<002F00320037>]TJ
 /F26 9.96264 Tf
-1.1 0 0 1 183.582 707.125 Tm [<003B003F>1<0042>]TJ
+1.1 0 0 1 183.582 706.717 Tm [<003B003F>1<0042>]TJ
 /F26 9.96264 Tf
-1 0 0 1.5 201.823 707.125 Tm [<004400460048>]TJ
+1 0 0 1.5 201.823 706.717 Tm [<004400460048>]TJ
 /F26 9.96264 Tf
-2 0 1 0.5 216.219 707.125 Tm [<004B004D0051>]TJ
+2 0 1 0.5 216.219 706.717 Tm [<004B004D0051>]TJ
 /F25 9.96264 Tf
 1 0 0 1 303.133 139.255 Tm [<0052>]TJ
 ET





More information about the latex3-commits mailing list.