summaryrefslogtreecommitdiff
path: root/texmf-dist/tex/harftex/base/harf-luaotfload.lua
diff options
context:
space:
mode:
Diffstat (limited to 'texmf-dist/tex/harftex/base/harf-luaotfload.lua')
-rw-r--r--texmf-dist/tex/harftex/base/harf-luaotfload.lua66
1 files changed, 13 insertions, 53 deletions
diff --git a/texmf-dist/tex/harftex/base/harf-luaotfload.lua b/texmf-dist/tex/harftex/base/harf-luaotfload.lua
index 8a373275..10099c68 100644
--- a/texmf-dist/tex/harftex/base/harf-luaotfload.lua
+++ b/texmf-dist/tex/harftex/base/harf-luaotfload.lua
@@ -1,26 +1,19 @@
+local module = {
+ name = "harf-luaotfload",
+ description = "Harf luaotfload integration",
+ version = "0.4.2",
+ date = "2019-09-07",
+ license = "GPL v2.0"
+}
+luatexbase.provides_module(module)
+
if not pcall(require, "luaharfbuzz") then
luatexbase.module_error("harf", "'luaharfbuzz' module is required.")
end
local harf = require("harf")
-local define_font = harf.callbacks.define_font
-
--- Change luaotfload’s default of preferring system fonts.
-fonts.names.set_location_precedence {
- "local", "texmf", "system"
-}
-
-local callback_warning = true
-if callback_warning then
- local callbacks = callback.list()
- if callbacks["get_glyph_string"] == nil then
- luatexbase.module_warning("harf",
- "'get_glyph_string' callback is missing, " ..
- "log messages might show garbage.")
- end
- callback_warning = false
-end
+local define_font = harf.callbacks.define_font
local readers = {
opentype = fonts.readers.opentype,
@@ -30,46 +23,13 @@ local readers = {
}
local function harf_reader(spec)
- local features = {}
- local options = {}
- local rawfeatures = spec.features and spec.features.raw or {}
-
- local mode = rawfeatures.mode
+ local features = spec.features and spec.features.raw
+ local mode = features and features.mode
if mode and mode ~= "harf" then
return readers[spec.forced](spec)
end
- -- 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,
- }
-
- 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)
- elseif tonumber(val) then
- val = '+'..key..'='..tonumber(val) - 1
- features[#features + 1] = harf.Feature.new(val)
- else
- options[key] = val
- end
- else
- options[key] = val
- end
- end
- return define_font(specification)
+ return define_font(spec)
end
-- Register font readers. We override the default ones to always use HarfBuzz