summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-04-20 07:40:31 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2016-04-20 07:40:31 +0200
commit1c93f97f4bce1b399e90f65657e95ef13434128c (patch)
treec0bb9705e1276e548a19ef656749d890d78860f6 /src
parentc35210aaaf992793bd111a0bd90e28630c7d2101 (diff)
parente14f3c50eedcd2652125177db0deacd8079cc048 (diff)
downloadluaotfload-1c93f97f4bce1b399e90f65657e95ef13434128c.tar.gz
Merge pull request #335 from phi-gamma/master
format and feature handling, fixes for 2.7
Diffstat (limited to 'src')
-rw-r--r--src/luaotfload-auxiliary.lua10
-rw-r--r--src/luaotfload-features.lua172
-rw-r--r--src/luaotfload-loaders.lua12
-rw-r--r--src/luaotfload-main.lua2
4 files changed, 39 insertions, 157 deletions
diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua
index 35f8f2b..3d300e7 100644
--- a/src/luaotfload-auxiliary.lua
+++ b/src/luaotfload-auxiliary.lua
@@ -42,7 +42,15 @@ local luaotfload_callbacks = { }
--- https://github.com/khaledhosny/luaotfload/issues/54
local rewrite_fontname = function (tfmdata, specification)
- tfmdata.name = [["]] .. specification .. [["]]
+ local format = tfmdata.format or tfmdata.properties.format
+ if format ~= "type1" then
+ if stringfind (specification, " ") then
+ tfmdata.name = stringformat ("%q", specification)
+ else
+ --- other specs should parse just fine
+ tfmdata.name = specification
+ end
+ end
end
local rewriting = false
diff --git a/src/luaotfload-features.lua b/src/luaotfload-features.lua
index 79f1416..5e9bf7b 100644
--- a/src/luaotfload-features.lua
+++ b/src/luaotfload-features.lua
@@ -1322,146 +1322,6 @@ local noflags = { false, false, false, false }
local tohash = table.tohash
-local function ancient_addfeature (data, feature, specifications)
- local descriptions = data.descriptions
- local resources = data.resources
- local lookups = resources.lookups
- local gsubfeatures = resources.features.gsub
- if gsubfeatures and gsubfeatures[feature] then
- -- already present
- else
- local sequences = resources.sequences
- local fontfeatures = resources.features
- local unicodes = resources.unicodes
- local lookuptypes = resources.lookuptypes
- local splitter = lpeg.splitter(" ",unicodes)
- local done = 0
- local skip = 0
- if not specifications[1] then
- -- so we accept a one entry specification
- specifications = { specifications }
- end
- -- subtables are tables themselves but we also accept flattened singular subtables
- for s=1,#specifications do
- local specification = specifications[s]
- local valid = specification.valid
- if not valid or valid(data,specification,feature) then
- local initialize = specification.initialize
- if initialize then
- -- when false is returned we initialize only once
- specification.initialize = initialize(specification) and initialize or nil
- end
- local askedfeatures = specification.features or everywhere
- local subtables = specification.subtables or { specification.data } or { }
- local featuretype = types[specification.type or "substitution"]
- local featureflags = specification.flags or noflags
- local featureorder = specification.order or { feature }
- local added = false
- local featurename = stringformat("ctx_%s_%s",feature,s)
- local st = { }
- for t=1,#subtables do
- local list = subtables[t]
- local full = stringformat("%s_%s",featurename,t)
- st[t] = full
- if featuretype == "gsub_ligature" then
- lookuptypes[full] = "ligature"
- for code, ligature in next, list do
- local unicode = tonumber(code) or unicodes[code]
- local description = descriptions[unicode]
- if description then
- local slookups = description.slookups
- if type(ligature) == "string" then
- ligature = { lpegmatch(splitter,ligature) }
- end
- local present = true
- for i=1,#ligature do
- if not descriptions[ligature[i]] then
- present = false
- break
- end
- end
- if present then
- if slookups then
- slookups[full] = ligature
- else
- description.slookups = { [full] = ligature }
- end
- done, added = done + 1, true
- else
- skip = skip + 1
- end
- end
- end
- elseif featuretype == "gsub_single" then
- lookuptypes[full] = "substitution"
- for code, replacement in next, list do
- local unicode = tonumber(code) or unicodes[code]
- local description = descriptions[unicode]
- if description then
- local slookups = description.slookups
- replacement = tonumber(replacement) or unicodes[replacement]
- if descriptions[replacement] then
- if slookups then
- slookups[full] = replacement
- else
- description.slookups = { [full] = replacement }
- end
- done, added = done + 1, true
- end
- end
- end
- end
- end
- if added then
- -- script = { lang1, lang2, lang3 } or script = { lang1 = true, ... }
- for k, v in next, askedfeatures do
- if v[1] then
- askedfeatures[k] = tabletohash(v)
- end
- end
- local sequence = {
- chain = 0,
- features = { [feature] = askedfeatures },
- flags = featureflags,
- name = featurename,
- order = featureorder,
- subtables = st,
- type = featuretype,
- }
- if specification.prepend then
- insert(sequences,1,sequence)
- else
- insert(sequences,sequence)
- end
- -- register in metadata (merge as there can be a few)
- if not gsubfeatures then
- gsubfeatures = { }
- fontfeatures.gsub = gsubfeatures
- end
- local k = gsubfeatures[feature]
- if not k then
- k = { }
- gsubfeatures[feature] = k
- end
- for script, languages in next, askedfeatures do
- local kk = k[script]
- if not kk then
- kk = { }
- k[script] = kk
- end
- for language, value in next, languages do
- kk[language] = value
- end
- end
- end
- end
- end
- if trace_loading then
- report_otf("registering feature %a, affected glyphs %a, skipped glyphs %a",feature,done,skip)
- end
- end
-end
-
local function current_addfeature(data,feature,specifications)
local descriptions = data.descriptions
local resources = data.resources
@@ -1856,19 +1716,29 @@ end
otf.addfeature = add_otf_feature
local install_extra_features = function (data, filename, raw)
+ local metadata = data and data.metadata
+ if not metadata then
+ logreport ("both", 4, "features",
+ "no metadata received from font “%s”; not \z
+ installing extra features.", filename)
+ return
+ end
+ local format = data.format
+ if not format then
+ logreport ("both", 4, "features",
+ "no format info for font “%s”/“%s”; not \z
+ installing extra features.",
+ fontname, filename)
+ return
+ end
for feature, specification in next, extrafeatures do
- local fontname
- local subfont
- local metadata = data.metadata
- if metadata then
- fontname = tostring (data.metadata.fontname)
- subfont = tonumber (metadata.subfontindex)
- end
if not fontname then fontname = "<unknown>" end
if not subfont then subfont = -1 end
+ local fontname = tostring (data.metadata.fontname) or "<unknown>"
+ local subfont = tonumber (metadata.subfontindex) or -1
logreport ("both", 3, "features",
"register synthetic feature “%s” for %s font “%s”(%d)",
- feature, data.format, fontname, subfont)
+ feature, format, fontname, subfont)
otf.features.register { name = feature, description = specification[2] }
otf.enhancers.addfeature (data, feature, specification[1])
end
@@ -1887,11 +1757,7 @@ return {
end
otf = fonts.handlers.otf
-
- --- hack for backwards compat with TL2014 loader
- otf.enhancers.addfeature = otf.version < 2.8 and ancient_addfeature
- or current_addfeature
-
+ otf.enhancers.addfeature = current_addfeature
otf.enhancers.register ("check extra features",
install_extra_features)
diff --git a/src/luaotfload-loaders.lua b/src/luaotfload-loaders.lua
index fb01821..d3828aa 100644
--- a/src/luaotfload-loaders.lua
+++ b/src/luaotfload-loaders.lua
@@ -41,6 +41,14 @@ local eval_reader = function (specification)
return eval ()
end
+local unsupported_reader = function (format)
+ return function (specification)
+ logreport ("both", 0, "loaders",
+ "font format “%s” unsupported; cannot load %s.",
+ format, tostring (specification.name))
+ end
+end
+
local install_formats = function ()
local fonts = fonts
if not fonts then return false end
@@ -72,8 +80,8 @@ local install_formats = function ()
return aux ("evl", eval_reader)
and aux ("lua", lua_reader)
- and aux ("pfa", function (spec) return readers.opentype (spec, "pfa", "type1") end)
- and aux ("pfb", function (spec) return readers.opentype (spec, "pfb", "type1") end)
+ and aux ("pfa", unsupported_reader "pfa")
+ and aux ("pfb", unsupported_reader "pfb")
and aux ("ofm", readers.tfm)
end
diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua
index 3f1f602..92c1ff1 100644
--- a/src/luaotfload-main.lua
+++ b/src/luaotfload-main.lua
@@ -13,7 +13,7 @@ local luaotfload = luaotfload
luaotfload.log = luaotfload.log or { }
luaotfload.version = "2.7"
luaotfload.loaders = { }
-luaotfload.min_luatex_version = 95 --- i. e. 0.80
+luaotfload.min_luatex_version = 95 --- i. e. 0.95
luaotfload.fontloader_package = "reference" --- default: from current Context
local authors = "\z