[latex3-commits] [git/LaTeX3-latex3-luaotfload] harf-dev: Plugin (a90e96d)
Marcel Fabian Krüger
tex at 2krueger.de
Tue Sep 17 13:55:03 CEST 2019
Repository : https://github.com/latex3/luaotfload
On branch : harf-dev
Link : https://github.com/latex3/luaotfload/commit/a90e96dfbed8397e274b1be43c2c3e8212a5d6b3
>---------------------------------------------------------------
commit a90e96dfbed8397e274b1be43c2c3e8212a5d6b3
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Tue Sep 17 04:44:44 2019 +0200
Plugin
>---------------------------------------------------------------
a90e96dfbed8397e274b1be43c2c3e8212a5d6b3
src/harf/harf-load.lua | 57 ++++++++++++++++++++++----------------------------
src/harf/harf-node.lua | 6 ++++--
2 files changed, 29 insertions(+), 34 deletions(-)
diff --git a/src/harf/harf-load.lua b/src/harf/harf-load.lua
index 8ac183b..5d4acae 100644
--- a/src/harf/harf-load.lua
+++ b/src/harf/harf-load.lua
@@ -10,20 +10,6 @@ local posttag = hb.Tag.new("post")
local glyftag = hb.Tag.new("glyf")
local function loadfont(spec)
--- @@ -296,6 +297,13 @@ local function scalefont(data, spec)
--- hscale = hscale,
--- vscale = vscale,
--- },
--- + shared = {
--- + processes = {
--- + function (head, font, _, direction)
--- + print('AAA', head, font, direction)
--- + end,
--- + },
--- + },
--- }
--- end
-
local path, sub = spec.resolved, spec.sub or 1
if not path then
return nil
@@ -179,7 +165,10 @@ local tlig = hb.texlig
local function scalefont(data, spec)
local size = spec.size
- local options = spec.features.raw
+ local features = spec.features.normal
+ features.mode = 'plug'
+ features.features = 'harf'
+ fonts.constructors.checkedfeatures("otf", features)
local hbface = data.face
local hbfont = data.font
local upem = data.upem
@@ -214,7 +203,7 @@ local function scalefont(data, spec)
-- Select font palette, we support `palette=index` option, and load the first
-- one otherwise.
- local paletteidx = tonumber(options.palette or options.colr) or 1
+ local paletteidx = tonumber(features.palette or features.colr) or 1
-- Load CPAL palette from the font.
local palette = nil
@@ -226,43 +215,43 @@ local function scalefont(data, spec)
end
local letterspace = 0
- if options.letterspace then
- letterspace = tonumber(options.letterspace) / 100 * upem
- elseif options.kernfactor then
- letterspace = tonumber(options.kernfactor) * upem
+ if features.letterspace then
+ letterspace = tonumber(features.letterspace) / 100 * upem
+ elseif features.kernfactor then
+ letterspace = tonumber(features.kernfactor) * upem
end
space = space + letterspace
local slantfactor = nil
- if options.slant then
- slantfactor = tonumber(options.slant) * 1000
+ if features.slant then
+ slantfactor = tonumber(features.slant) * 1000
end
local mode = nil
local width = nil
- if options.embolden then
+ if features.embolden then
mode = 2
-- The multiplication by 7200.0/7227 is to undo the opposite conversion
-- the engine is doing and make the final number written in the PDF file
-- match XeTeX’s.
- width = (size * tonumber(options.embolden) / 6553.6) * (7200.0/7227)
+ width = (size * tonumber(features.embolden) / 6553.6) * (7200.0/7227)
end
local hscale = upem
local extendfactor = nil
- if options.extend then
- extendfactor = tonumber(options.extend) * 1000
- hscale = hscale * tonumber(options.extend)
+ if features.extend then
+ extendfactor = tonumber(features.extend) * 1000
+ hscale = hscale * tonumber(features.extend)
end
local vscale = upem
local squeezefactor = nil
- if options.squeeze then
- squeezefactor = tonumber(options.squeeze) * 1000
- vscale = vscale * tonumber(options.squeeze)
+ if features.squeeze then
+ squeezefactor = tonumber(features.squeeze) * 1000
+ vscale = vscale * tonumber(features.squeeze)
end
- if options.texlig then
+ if features.tlig then
for char in next, characters do
local ligatures = tlig[char]
if ligatures then
@@ -271,7 +260,7 @@ local function scalefont(data, spec)
end
end
- return {
+ local tfmdata = {
name = spec.specification,
filename = spec.resolved,
designsize = size,
@@ -311,7 +300,11 @@ local function scalefont(data, spec)
vscale = vscale,
},
specification = spec,
+ shared = {},
+ properties = {},
}
+ tfmdata.shared.processes = fonts.handlers.otf.setfeatures(tfmdata, features)
+ return tfmdata
end
return function(spec)
diff --git a/src/harf/harf-node.lua b/src/harf/harf-node.lua
index d338422..f040c5a 100644
--- a/src/harf/harf-node.lua
+++ b/src/harf/harf-node.lua
@@ -833,7 +833,7 @@ process = function(head, direction)
return newhead or head
end
-local function process_nodes(head, groupcode, size, packtype, direction)
+local function process_nodes(head, font, _, direction)
local head = todirect(head)
-- Check if any fonts are loaded by us and then process the whole node list,
@@ -941,8 +941,10 @@ local function get_glyph_string(n)
return props and props[p_string] or nil
end
+fonts.handlers.otf.registerplugin('harf', process_nodes)
+
return {
- process = process_nodes,
+ -- process = process_nodes,
post_process = post_process_nodes,
cleanup = run_cleanup,
get_tounicode = get_tounicode,
More information about the latex3-commits
mailing list