From f10aeb6e760a349986570489b838ae6384291107 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Fri, 19 Apr 2013 10:31:44 +0200 Subject: Finishing to fix reference loop --- otfl-font-nms.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'otfl-font-nms.lua') diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index c987c3a..ee9fa33 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -888,7 +888,9 @@ read_fonts_conf = function (path, results, passed_paths) read_fonts_conf(include, results, passed_paths) elseif lfs.isdir(include) then for _,f in next, dirglob(filejoin(include, "*.conf")) do - read_fonts_conf(f, results, passed_paths) + if not passed_paths_set[f] then + read_fonts_conf(f, results, passed_paths) + end end end end -- cgit v1.2.3 From 488d7fd86850691244709064777bc22113262701 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sat, 20 Apr 2013 14:31:15 +0200 Subject: Adding a little TODO for file lookup --- otfl-font-nms.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'otfl-font-nms.lua') diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index ee9fa33..b62f5ec 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -243,6 +243,9 @@ font database created by the mkluatexfontdb script. --- successful lookup as this cannot be inferred from the other --- values. --- +--- TODO: this function is used also with the file lookup, it could be optimized +--- a lot for this case. +--- resolve = function (_,_,specification) -- the 1st two parameters are used by ConTeXt local name = sanitize_string(specification.name) local style = sanitize_string(specification.style) or "regular" -- cgit v1.2.3 From 0d3168d8b69d8eed835ff137cb24b6f83c2a28f6 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sat, 20 Apr 2013 16:19:46 +0200 Subject: As a matter of fact, there was nothing to optimize... --- otfl-font-nms.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'otfl-font-nms.lua') diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index b62f5ec..e8ad626 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -243,8 +243,6 @@ font database created by the mkluatexfontdb script. --- successful lookup as this cannot be inferred from the other --- values. --- ---- TODO: this function is used also with the file lookup, it could be optimized ---- a lot for this case. --- resolve = function (_,_,specification) -- the 1st two parameters are used by ConTeXt local name = sanitize_string(specification.name) -- cgit v1.2.3 From 14b3ba09e583caaa7e31ab7bfabc4871cbb206fd Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sun, 21 Apr 2013 15:17:58 +0200 Subject: Using caches.* functions from ConTeXt (fixes Issue #5) --- otfl-font-nms.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'otfl-font-nms.lua') diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index e8ad626..3ee6ee4 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -53,14 +53,25 @@ fonts = fonts or { } fonts.names = fonts.names or { } local names = fonts.names -local names_dir = "luatex-cache/generic/names" + names.version = 2.2 names.data = nil names.path = { basename = "otfl-names.lua", - dir = filejoin(kpse.expand_var("$TEXMFVAR"), names_dir), + dir = "", + path = "", } +-- We use the cache.* of ConTeXt (see luat-basics-gen), we can +-- use it safely (all checks and directory creations are already done). It +-- uses TEXMFCACHE or TEXMFVAR as starting points. +local writable_path = caches.getwritablepath("names","") +if not writable_path then + error("Impossible to find a suitable writeable cache...") +end +names.path.dir = writable_path +names.path.path = filejoin(writable_path, names.path.basename) + ---- --- @@ -161,8 +172,7 @@ local scan_external_dir local update_names load_names = function ( ) - local path = filejoin(names.path.dir, names.path.basename) - local foundname, data = load_lua_file(path) + local foundname, data = load_lua_file(names.path.path) if data then report("info", 0, "Font names database loaded", "%s", foundname) -- cgit v1.2.3 From 397c25951b2b1fd8e67e2ddea651b0ee953b0f36 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sun, 21 Apr 2013 15:29:44 +0200 Subject: A wonderful bug fix --- otfl-font-nms.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'otfl-font-nms.lua') diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index 3ee6ee4..c9c700c 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -927,12 +927,17 @@ local function get_os_dirs() elseif os.type == "windows" or os.type == "msdos" or os.name == "cygwin" then local windir = os.getenv("WINDIR") return { filejoin(windir, 'Fonts') } - else --- TODO what about ~/config/fontconfig/fonts.conf etc? + else + local passed_paths = {} + local os_dirs = {} + -- what about ~/config/fontconfig/fonts.conf etc? + -- Answer: they should be included by the others, please report if it's not for _,p in next, {"/usr/local/etc/fonts/fonts.conf", "/etc/fonts/fonts.conf"} do if lfs.isfile(p) then - return read_fonts_conf("/etc/fonts/fonts.conf", {}, {}) + read_fonts_conf(p, os_dirs, passed_paths) end end + return os_dirs end return {} end -- cgit v1.2.3 From 908c644982184f1119339a6abeb6fb8b548d5710 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sun, 21 Apr 2013 15:42:55 +0200 Subject: Adding a little TODO and commenting a XXX --- otfl-font-nms.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'otfl-font-nms.lua') diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index c9c700c..2e54028 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -6,6 +6,11 @@ if not modules then modules = { } end modules ['font-nms'] = { license = "GNU GPL v2" } +--- TODO: if the specification is an absolute filename with a font not in the +--- database, add the font to the database and load it. There is a small +--- difficulty with the filenames of the TEXMF tree that are referenced as +--- relative paths... + --- Luatex builtins local load = load local next = next @@ -246,7 +251,7 @@ font database created by the mkluatexfontdb script. --- --- the return value of “resolve” is the file name of the requested --- font - +--- --- 'a -> 'a -> table -> (string * string | bool * bool) --- --- note by phg: I added a third return value that indicates a @@ -390,12 +395,12 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con return reload_db(resolve, nil, nil, specification) else --- else, fallback to requested name - --- XXX: specification.name is empty with absolute paths, looks - --- like a bug in the specification parser + --- specification.name is empty with absolute paths, looks + --- like a bug in the specification parser << is it still + --- relevant? looks not... return specification.name, false, false end end - else --- no db or outdated; reload names and retry if not fonts_reloaded then return reload_db(resolve, nil, nil, specification) -- cgit v1.2.3