diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-24 09:16:53 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-24 09:16:53 +0900 |
commit | 844efbe3820e6c5b5a61c8a40abd5da1e91e6349 (patch) | |
tree | 1e387fa7bbf46d0ed985d8b2b68124d2e664787f /texmf-dist/tex/harftex/base/harf-luaotfload.lua | |
parent | e0ad882887b423e68512065b625c57995b312ec0 (diff) |
harf 1.0.0
Diffstat (limited to 'texmf-dist/tex/harftex/base/harf-luaotfload.lua')
-rw-r--r-- | texmf-dist/tex/harftex/base/harf-luaotfload.lua | 66 |
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 |