[latex3-commits] [git/LaTeX3-latex3-luaotfload] harf-dev: Cleanup (1455a40)
Marcel Fabian Krüger
tex at 2krueger.de
Tue Sep 17 16:15:12 CEST 2019
Repository : https://github.com/latex3/luaotfload
On branch : harf-dev
Link : https://github.com/latex3/luaotfload/commit/1455a407ad10c04742ce48797a0be7ff740d1a03
>---------------------------------------------------------------
commit 1455a407ad10c04742ce48797a0be7ff740d1a03
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Tue Sep 17 02:55:28 2019 +0200
Cleanup
>---------------------------------------------------------------
1455a407ad10c04742ce48797a0be7ff740d1a03
src/harf/harf-load.lua | 27 +++++++++++++++++++++------
src/harf/harf-luaotfload.lua | 32 +++++++++-----------------------
src/harf/harf-node.lua | 15 ++++++---------
3 files changed, 36 insertions(+), 38 deletions(-)
diff --git a/src/harf/harf-load.lua b/src/harf/harf-load.lua
index a4b799f..8ac183b 100644
--- a/src/harf/harf-load.lua
+++ b/src/harf/harf-load.lua
@@ -10,18 +10,32 @@ local posttag = hb.Tag.new("post")
local glyftag = hb.Tag.new("glyf")
local function loadfont(spec)
- local path, index = spec.path, spec.index
+-- @@ -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
end
- local key = string.format("%s:%d", path, index)
+ local key = string.format("%s:%d", path, sub)
local data = hbfonts[key]
if data then
return data
end
- local hbface = hb.Face.new(path, index)
+ local hbface = hb.Face.new(path, sub - 1)
local tags = hbface and hbface:get_table_tags()
-- If the face has no table tags then it isn’t a valid SFNT font that
-- HarfBuzz can handle.
@@ -165,7 +179,7 @@ local tlig = hb.texlig
local function scalefont(data, spec)
local size = spec.size
- local options = spec.options
+ local options = spec.features.raw
local hbface = data.face
local hbfont = data.font
local upem = data.upem
@@ -200,7 +214,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 1
+ local paletteidx = tonumber(options.palette or options.colr) or 1
-- Load CPAL palette from the font.
local palette = nil
@@ -259,7 +273,7 @@ local function scalefont(data, spec)
return {
name = spec.specification,
- filename = spec.path,
+ filename = spec.resolved,
designsize = size,
psname = sanitize(data.psname),
fullname = data.fullname,
@@ -296,6 +310,7 @@ local function scalefont(data, spec)
hscale = hscale,
vscale = vscale,
},
+ specification = spec,
}
end
diff --git a/src/harf/harf-luaotfload.lua b/src/harf/harf-luaotfload.lua
index d3d52b8..0e1696c 100644
--- a/src/harf/harf-luaotfload.lua
+++ b/src/harf/harf-luaotfload.lua
@@ -26,41 +26,27 @@ end
-- load fonts when explicitly requested. Fonts we load will be shaped by the
-- callbacks we register below.
fonts.readers.harf = function(spec)
- local features = {}
- local options = {}
- local rawfeatures = spec.features and spec.features.raw or {}
-
- -- Rewrite luaotfload specification to look like what we expect.
- local specification = {
- features = features,
- options = options,
- path = spec.resolved or spec.name,
- index = spec.sub and spec.sub - 1 or 0,
- size = spec.size,
- specification = spec.specification,
- }
+ local rawfeatures = spec.features.raw
+ local hb_features = {}
+ spec.hb_features = hb_features
+ if rawfeatures.language then
+ spec.language = harf.Language.new(rawfeatures.language)
+ end
for key, val in next, rawfeatures do
- if key == "language" then val = harf.Language.new(val) end
- if key == "colr" then key = "palette" end
- if key == "tlig" then key = "texlig" end
if key:len() == 4 then
-- 4-letter options are likely font features, but not always, so we do
-- some checks below. We put non feature options in the `options` dict.
if val == true or val == false then
val = (val and '+' or '-')..key
- features[#features + 1] = harf.Feature.new(val)
+ hb_features[#hb_features + 1] = harf.Feature.new(val)
elseif tonumber(val) then
val = '+'..key..'='..tonumber(val) - 1
- features[#features + 1] = harf.Feature.new(val)
- else
- options[key] = val
+ hb_features[#hb_features + 1] = harf.Feature.new(val)
end
- else
- options[key] = val
end
end
- return define_font(specification)
+ return define_font(spec)
end
local GSUBtag = harf.Tag.new("GSUB")
diff --git a/src/harf/harf-node.lua b/src/harf/harf-node.lua
index 87384fa..b1d838f 100644
--- a/src/harf/harf-node.lua
+++ b/src/harf/harf-node.lua
@@ -219,9 +219,9 @@ local function itemize(head, direction)
local fontdata = currfontid and font.getfont(currfontid)
local hbdata = fontdata and fontdata.hb
- local spec = hbdata and hbdata.spec
- local options = spec and spec.options
- local texlig = options and options.texlig
+ local spec = fontdata and fontdata.specification
+ local options = spec and spec.features.raw
+ local texlig = options and options.tlig
if texlig then
local replacement = trep[code]
if replacement then
@@ -253,9 +253,6 @@ local function itemize(head, direction)
-- If script is not resolved yet, and the font has a "script" option, use
-- it.
if (script == common_s or script == inherited_s) and hbdata then
- local spec = hbdata.spec
- local features = spec.features
- local options = spec.options
script = options.script and hb.Script.new(options.script) or script
end
@@ -407,8 +404,8 @@ shape = function(run)
local hbdata = fontdata.hb
local palette = hbdata.palette
local spec = hbdata.spec
- local features = spec.features
- local options = spec.options
+ local features = spec.hb_features
+ local options = spec.features.raw
local hbshared = hbdata.shared
local hbfont = hbshared.font
local hbface = hbshared.face
@@ -825,7 +822,7 @@ local function shape_run(head, current, run)
-- shaping.
local fontid = run.font
local fontdata = font.getfont(fontid)
- local options = fontdata.hb.spec.options
+ local options = fontdata.specification.features.raw
local color = options and options.color and hex_to_rgba(options.color)
local glyphs = shape(run)
More information about the latex3-commits
mailing list