From 24a3ecb19d3ca204ac4432e8f2f0b2bf53954b05 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 24 Apr 2013 18:58:02 +0200 Subject: catch irregular ``file:`` lookups we now index base names and extensionless base names of font files as well so as to work around quirks of the Xetex compatibility layer. this will probably get removed after the syntax parser is redone. --- luaotfload-features.lua | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'luaotfload-features.lua') diff --git a/luaotfload-features.lua b/luaotfload-features.lua index 0121ede..3c5aa8c 100644 --- a/luaotfload-features.lua +++ b/luaotfload-features.lua @@ -37,6 +37,12 @@ local stringfind = string.find local stringexplode = string.explode local stringis_empty = string.is_empty +--[[doc-- +Apparently, these “modifiers” are another measure of emulating \XETEX, +cf. “About \XETEX”, by Jonathan Kew, 2005; and + “The \XETEX Reference Guide”, by Will Robertson, 2011. +--doc]]-- + local supported = { b = "bold", i = "italic", @@ -123,7 +129,7 @@ defaults.tibt = defaults.khmr defaults.lao = defaults.thai -local function set_default_features(script) +local set_default_features = function (script) local features local script = script or "dflt" report("log", 0, "load font", @@ -171,9 +177,13 @@ local options = P(":") * spaces * (P(";")^0 * option)^0 local pattern = (filename + fontname) * subvalue^0 * stylespec^0 * options^0 local function colonized(specification) -- xetex mode + --print"~~~~~~~~~~~~~~~~~~~~~~~~" + --print(specification.specification) feature_list = { } lpeg.match(pattern,specification.specification) set_default_features(feature_list.script) + --inspect(feature_list) + --os.exit() if feature_list.style then specification.style = feature_list.style feature_list.style = nil @@ -206,27 +216,31 @@ local function colonized(specification) -- xetex mode -- if no mode is set, use our default feature_list.mode = fonts.mode end + --inspect(feature_list) specification.features.normal = fonts.handlers.otf.features.normalize(feature_list) + --inspect(specification.features.normal) return specification end fonts.definers.registersplit(":",colonized,"cryptic") fonts.definers.registersplit("", colonized,"more cryptic") -- catches \font\text=[names] -function fonts.definers.applypostprocessors(tfmdata) - local postprocessors = tfmdata.postprocessors - if postprocessors then - for i=1,#postprocessors do - local extrahash = postprocessors[i](tfmdata) -- after scaling etc - if type(extrahash) == "string" and extrahash ~= "" then - -- e.g. a reencoding needs this - extrahash = string.gsub(lower(extrahash),"[^a-z]","-") - tfmdata.properties.fullname = format("%s-%s",tfmdata.properties.fullname,extrahash) - end - end - end - return tfmdata -end +--- TODO below section is literally the same in luatex-fonts-def +--- why is it here? +--function fonts.definers.applypostprocessors(tfmdata) +-- local postprocessors = tfmdata.postprocessors +-- if postprocessors then +-- for i=1,#postprocessors do +-- local extrahash = postprocessors[i](tfmdata) -- after scaling etc +-- if type(extrahash) == "string" and extrahash ~= "" then +-- -- e.g. a reencoding needs this +-- extrahash = string.gsub(lower(extrahash),"[^a-z]","-") +-- tfmdata.properties.fullname = format("%s-%s",tfmdata.properties.fullname,extrahash) +-- end +-- end +-- end +-- return tfmdata +--end ---[[ end included font-ltx.lua ]] --[[doc-- -- cgit v1.2.3 From 743c725a3c4e515cdb591a04dc5396c5e9e1de42 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 24 Apr 2013 23:17:41 +0200 Subject: =?UTF-8?q?default=20to=20=E2=80=9Cnode=E2=80=9D=20mode=20processo?= =?UTF-8?q?r=20again?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luaotfload-features.lua | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'luaotfload-features.lua') diff --git a/luaotfload-features.lua b/luaotfload-features.lua index 3c5aa8c..78f8256 100644 --- a/luaotfload-features.lua +++ b/luaotfload-features.lua @@ -111,6 +111,8 @@ local defaults = { }, } +local global_defaults = { mode = "node" } + defaults.beng = defaults.deva defaults.guru = defaults.deva defaults.gujr = defaults.deva @@ -129,22 +131,36 @@ defaults.tibt = defaults.khmr defaults.lao = defaults.thai -local set_default_features = function (script) - local features - local script = script or "dflt" +--- (string, string) dict -> (string, string) dict +local set_default_features = function (speclist) + local script = speclist.script or "dflt" + report("log", 0, "load font", "auto-selecting default features for script: %s", script) - if defaults[script] then - features = defaults[script] - else - features = defaults["dflt"] + + local requested = defaults[script] + if not requested then + report("log", 0, "load font", + "no defaults for script “%s”, falling back to “dflt”", + script) + requested = defaults.dflt end - for _,v in next, features do - if feature_list[v] ~= false then - feature_list[v] = true + + for i=1, #requested do + local feat = requested[i] + if speclist[feat] ~= false then + speclist[feat] = true end end + + for feat, state in next, global_defaults do + --- This is primarily intended for setting node + --- mode unless “base” is requested, as stated + --- in the manual. + if not speclist[feat] then speclist[feat] = state end + end + return speclist end local function issome () feature_list.lookup = 'name' end @@ -177,13 +193,9 @@ local options = P(":") * spaces * (P(";")^0 * option)^0 local pattern = (filename + fontname) * subvalue^0 * stylespec^0 * options^0 local function colonized(specification) -- xetex mode - --print"~~~~~~~~~~~~~~~~~~~~~~~~" - --print(specification.specification) feature_list = { } lpeg.match(pattern,specification.specification) - set_default_features(feature_list.script) - --inspect(feature_list) - --os.exit() + feature_list = set_default_features(feature_list) if feature_list.style then specification.style = feature_list.style feature_list.style = nil @@ -216,9 +228,7 @@ local function colonized(specification) -- xetex mode -- if no mode is set, use our default feature_list.mode = fonts.mode end - --inspect(feature_list) specification.features.normal = fonts.handlers.otf.features.normalize(feature_list) - --inspect(specification.features.normal) return specification end -- cgit v1.2.3