summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-06-22 07:34:29 -0700
committerPhilipp Gesang <phg42.2a@gmail.com>2013-06-22 07:34:29 -0700
commit1caf2aa7b019b687e9b97e3a7a2d6ab55070f577 (patch)
tree8e8cc079a4b9b235df95344a30873de969f497fa
parent5aa54f3169985d0457b3517f49da961a51b2f1cc (diff)
parentbd0a8039e89b9403b58ac5a9827a333276a6fbf6 (diff)
downloadluaotfload-1caf2aa7b019b687e9b97e3a7a2d6ab55070f577.tar.gz
Merge pull request #99 from phi-gamma/master
fixes
-rw-r--r--luaotfload-auxiliary.lua2
-rw-r--r--luaotfload-database.lua88
-rw-r--r--luaotfload-extralibs.lua12
-rwxr-xr-xmkcharacters7
4 files changed, 77 insertions, 32 deletions
diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua
index 0dfabe6..8fc8477 100644
--- a/luaotfload-auxiliary.lua
+++ b/luaotfload-auxiliary.lua
@@ -358,7 +358,7 @@ do
local index = function (t, k)
if chardata == nil then
log("Loading character metadata from %s.", chardef)
- chardata = dofile(kpse.find_file("luaotfload-characters.lua", "lua"))
+ chardata = dofile(kpse.find_file(chardef, "lua"))
if chardata == nil then
warning("Could not load %s; continuing with empty character table.",
chardef)
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index 8106898..4c45d21 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -34,6 +34,7 @@ local ioopen = io.open
local kpseexpand_path = kpse.expand_path
local kpseexpand_var = kpse.expand_var
local kpselookup = kpse.lookup
+local kpsefind_file = kpse.find_file
local kpsereadable_file = kpse.readable_file
local lfsisdir = lfs.isdir
local lfsisfile = lfs.isfile
@@ -325,12 +326,14 @@ end
local style_synonyms = { set = { } }
do
+ --- read this: http://blogs.adobe.com/typblography/2008/05/indesign_font_conflicts.html
+ --- tl;dr: font style synonyms are unreliable.
style_synonyms.list = {
- regular = { "normal", "roman",
- "plain", "book",
- "medium", },
+ regular = { "normal", "roman",
+ "plain", "book", },
bold = { "demi", "demibold",
- "semibold", "boldregular",},
+ "semibold", "boldregular",
+ "medium" },
italic = { "regularitalic", "normalitalic",
"oblique", "slanted", },
bolditalic = { "boldoblique", "boldslanted",
@@ -425,6 +428,52 @@ crude_file_lookup = function (filename)
end
--[[doc--
+Existence of the resolved file name is verified differently depending
+on whether the index entry has a texmf flag set.
+--doc]]--
+
+local get_font_file = function (fullnames, entry)
+ local basename = entry.basename
+ if entry.texmf == true then
+ if kpselookup(basename) then
+ return true, basename, entry.subfont
+ end
+ else
+ local fullname = fullnames[entry.index]
+ if lfsisfile(fullname) then
+ return true, basename, entry.subfont
+ end
+ end
+ return false
+end
+
+--[[doc--
+We need to verify if the result of a cached lookup actually exists in
+the texmf or filesystem.
+--doc]]--
+
+local verify_font_file = function (basename)
+ local filenames = names.data.filenames
+ local idx = filenames.base[basename]
+ if not idx then
+ return false
+ end
+
+ --- firstly, check filesystem
+ local fullname = filenames.full[idx]
+ if fullname and lfsisfile(fullname) then
+ return true
+ end
+
+ --- secondly, locate via kpathsea
+ if kpsefind_file(basename) then
+ return true
+ end
+
+ return false
+end
+
+--[[doc--
Lookups can be quite costly, more so the less specific they are.
Even if we find a matching font eventually, the next time the
user compiles Eir document E will have to stand through the delay
@@ -496,9 +545,16 @@ resolve_cached = function (_, _, specification)
--- case 1) cache positive ----------------------------------------
if found then --- replay fields from cache hit
report("info", 4, "cache", "found!")
- return found[1], found[2], true
+ local basename = found[1]
+ --- check the presence of the file in case it’s been removed
+ local success = verify_font_file(basename)
+ if success == true then
+ return basename, found[2], true
+ end
+ report("both", 4, "cache", "cached file not found; resolving again")
+ else
+ report("both", 4, "cache", "not cached; resolving")
end
- report("both", 4, "cache", "not cached; resolving")
--- case 2) cache negative ----------------------------------------
--- first we resolve normally ...
@@ -542,26 +598,6 @@ local add_to_match = function (
end
--[[doc--
-Existence of the resolved file name is verified differently depending
-on whether the index entry has a texmf flag set.
---doc]]--
-
-local get_font_file = function (fullnames, entry)
- local basename = entry.basename
- if entry.texmf == true then
- if kpselookup(basename) then
- return true, basename, entry.subfont
- end
- else
- local fullname = fullnames[entry.index]
- if lfsisfile(fullname) then
- return true, basename, entry.subfont
- end
- end
- return false
-end
-
---[[doc--
Luatex-fonts, the font-loader package luaotfload imports, comes with
basic file location facilities (see luatex-fonts-syn.lua).
diff --git a/luaotfload-extralibs.lua b/luaotfload-extralibs.lua
index 90dbf09..3204229 100644
--- a/luaotfload-extralibs.lua
+++ b/luaotfload-extralibs.lua
@@ -176,9 +176,15 @@ if not chardata then
if k == true then
return chardata[currentfont()]
else
- local characters = identifiers[k].characters
- t[k] = characters
- return characters
+ local tfmdata = identifiers[k]
+ if not tfmdata then --- unsafe
+ tfmdata = font.fonts[k]
+ end
+ if tfmdata then
+ local characters = tfmdata.characters
+ t[k] = characters
+ return characters
+ end
end
end)
fonthashes.characters = chardata
diff --git a/mkcharacters b/mkcharacters
index a627ea9..a1c4204 100755
--- a/mkcharacters
+++ b/mkcharacters
@@ -5,7 +5,7 @@
-- DESCRIPTION: import parts of char-def.lua
-- REQUIREMENTS: lua, ConTeXt, the lualibs package
-- AUTHOR: Philipp Gesang (Phg), <phg42.2a@gmail.com>
--- VERSION: 1.0
+-- VERSION: 1.1
-- CREATED: 2013-05-17 12:41:39+0200
-----------------------------------------------------------------------
-- we create a stripped-down version of char-def.lua
@@ -16,7 +16,10 @@
-----------------------------------------------------------------------
local charfile = "./luaotfload-characters.lua"
local chardef = "~phg/base/char-def.lua"
-local import = { "direction", "mirror", } --> πολυγλωσσία/uax9
+local import = {
+ "direction", "mirror", --> πολυγλωσσία/uax9
+ "category", --> https://gist.github.com/phi-gamma/5812290
+}
-----------------------------------------------------------------------
-- includes