summaryrefslogtreecommitdiff
path: root/luaotfload-auxiliary.lua
diff options
context:
space:
mode:
authorElie Roux <elie.roux@telecom-bretagne.eu>2013-05-15 09:02:32 -0700
committerElie Roux <elie.roux@telecom-bretagne.eu>2013-05-15 09:02:32 -0700
commit087a990dc8581be3a2980034e70f874d52f9577b (patch)
tree5a7d38a8e5cf55cceb6dd51becf102950819beb4 /luaotfload-auxiliary.lua
parent8a67b384a597b9af16ea915fe7e323d4328cdd3e (diff)
parent52f6ea217175fd1a39e6f80ea7a0f98fbf1364f6 (diff)
downloadluaotfload-087a990dc8581be3a2980034e70f874d52f9577b.tar.gz
Merge pull request #75 from phi-gamma/master
address feature request #74
Diffstat (limited to 'luaotfload-auxiliary.lua')
-rw-r--r--luaotfload-auxiliary.lua88
1 files changed, 64 insertions, 24 deletions
diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua
index a41520c..dde5686 100644
--- a/luaotfload-auxiliary.lua
+++ b/luaotfload-auxiliary.lua
@@ -76,16 +76,18 @@ local add_fontdata_fallbacks = function (fontdata)
metadata = { ascent = metadata.ascent },
}
--- for microtype and fontspec
- local fake_features = { } -- wrong: table.copy(resources.features)
+ --local fake_features = { }
+ local fake_features = table.copy(resources.features)
setmetatable(fake_features, { __index = function (tab, idx)
- warning("some package (probably fontspec) is outdated")
- warning(
- "attempt to index " ..
- "tfmdata.shared.otfdata.luatex.features (%s)",
- idx)
- --os.exit(1)
- return nil --- empty anyways
- end})
+ warning("some package (probably fontspec) is outdated")
+ warning(
+ "attempt to index " ..
+ "tfmdata.shared.otfdata.luatex.features (%s)",
+ idx)
+ --os.exit(1)
+ return tab[idx]
+ end,
+ })
fontdata.shared.otfdata.luatex = {
unicodes = resources.unicodes,
features = fake_features,
@@ -479,27 +481,65 @@ aux.sprint_math_dimension = sprint_math_dimension
--- extra database functions
-----------------------------------------------------------------------
+local namesresolve = fonts.names.resolve
+local namesscan_dir = fonts.names.scan_dir
+
--- migrated from luaotfload-database.lua
--- https://github.com/lualatex/luaotfload/pull/61#issuecomment-17776975
---- string -> (int, int)
+--- string -> (int * int)
local scan_external_dir = function (dir)
- local old_names, new_names = names.data
- if not old_names then
- old_names = load_names()
- end
- new_names = tablecopy(old_names)
- local n_scanned, n_new = fonts.names.scan_dir(dir, old_names,
- new_names)
- --- FIXME
- --- This doesn’t seem right. If a db update is triggered after this
- --- point, then the added fonts will be saved along with it --
- --- which is not as “temporarily” as it should be. (This should be
- --- addressed during a refactoring of names_resolve().)
- names.data = new_names
- return n_scanned, n_new
+ local old_names, new_names = names.data
+ if not old_names then
+ old_names = load_names()
+ end
+ new_names = tablecopy(old_names)
+ local n_scanned, n_new = scan_dir(dir, old_names, new_names)
+ --- FIXME
+ --- This doesn’t seem right. If a db update is triggered after this
+ --- point, then the added fonts will be saved along with it --
+ --- which is not as “temporarily” as it should be. (This should be
+ --- addressed during a refactoring of names_resolve().)
+ names.data = new_names
+ return n_scanned, n_new
end
aux.scan_external_dir = scan_external_dir
+--- https://github.com/lualatex/luaotfload/issues/74
+--- string -> (string * int)
+local resolve_fontname = function (name)
+ local foundname, subfont, success = namesresolve(nil, nil, {
+ name = name,
+ lookup = "name",
+ optsize = 0,
+ specification = "name:" .. name,
+ })
+ if success then
+ return foundname, subfont
+ end
+ return false, false
+end
+
+aux.resolve_fontname = resolve_fontname
+
+--- string list -> (string * int)
+local resolve_fontlist
+resolve_fontlist = function (names, n)
+ if not n then
+ return resolve_fontlist(names, 1)
+ end
+ local this = names[n]
+ if this then
+ local foundname, subfont = resolve_fontname(this)
+ if foundname then
+ return foundname, subfont
+ end
+ return resolve_fontlist(names, n+1)
+ end
+ return false, false
+end
+
+aux.resolve_fontlist = resolve_fontlist
+
-- vim:tw=71:sw=2:ts=2:expandtab