From 29c426e86ad54e035c1e9501b8dcade8e352f1a4 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 20 May 2013 21:12:12 +0200 Subject: add temporary workaround for cache directory creation --- luaotfload.dtx | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 94 insertions(+), 8 deletions(-) diff --git a/luaotfload.dtx b/luaotfload.dtx index eabc240..706ee1c 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1455,12 +1455,14 @@ local luatexbase = luatexbase local type, next = type, next local setmetatable = setmetatable -local find_file = kpse.find_file +local kpsefind_file = kpse.find_file +local kpseexpand_path = kpse.expand_path +local kpseexpand_var = kpse.expand_var local lfsisfile = lfs.isfile -local stringfind = string.find -local stringformat = string.format -local stringmatch = string.match -local stringsub = string.sub +local lfsisdir = lfs.isdir +local lfsmkdir = lfs.mkdir +local stringexplode = string.explode +local stringgmatch = string.gmatch local add_to_callback, create_callback = luatexbase.add_to_callback, luatexbase.create_callback @@ -1508,6 +1510,80 @@ if tex.luatexversion < luatex_version then end end +% \end{macrocode} +% Create $TEXMFCACHE if not present. This is necessary due to +% two bugs in Luatex-Fonts that surface simultaneously if none +% of the possible cache directories exists. We add a fixed version +% of lfs.mkdirs() first. +% +% \begin{macrocode} + +local ostype = os.type + +local mkdirs = function (path) + local full + for sub in stringgmatch(path, "([^\\/]+)") do + if full then + full = full .. "/" .. sub + else + if ostype == "windows" then + full = sub + else + full = "/" .. sub + end + end + if not lfsisdir(full) then + lfsmkdir(full) + end + end +end + +--- + +local phantom_kpse, normal_expand_path +do --- take care of writable path + local cachepath = kpseexpand_path"$TEXMFCACHE" + if cachepath == "" then + cachepath = kpseexpand_path"$TEXMFVAR" + end + if cachepath == "" then --- dir missing, create + texio.write_nl("term and log", + "(luaotfload: cache directory inaccessible)") + local cachedest = kpseexpand_var"$TEXMFCACHE" + local pathsep = ostype == "windows" and ";" or ":" + if cachedest then + cachedest = stringexplode(cachedest, pathsep) + end + for _, path in next, cachedest do + if not lfsisdir(path) then + texio.write_nl("term and log", + "(luaotfload: creating path " .. path) + mkdirs(path) + if lfsisdir(path) then + local writable = kpseexpand_path("$TEXMFCACHE", true) + texio.write("term and log", " -- success)") + phantom_kpse = kpse.new "luatex" + goto writable_cache + end + texio.write("term and log", " FAILED!)") + end + end + end +end + +::writable_cache:: +if phantom_kpse ~= nil then + normal_expand_path = kpseexpand_path + kpse.expand_path = function (spec) + --- the second kpse instance is needed because kpathsea + --- doesn’t update variables + --- http://www.ntg.nl/pipermail/dev-luatex/2007-December/001172.html + return phantom_kpse:expand_path(spec) + end +end + +--- + % \end{macrocode} % \subsection{Module loading} % We load the files imported from \CONTEXT with this function. @@ -1537,10 +1613,10 @@ local p_suffix = (p_dot * (1 - p_dot - p_slash)^1 * P(-1)) / "" local p_removesuffix = Cs((p_suffix + 1)^1) local find_vf_file = function (name) - local fullname = find_file(name, "ovf") + local fullname = kpsefind_file(name, "ovf") if not fullname then - --fullname = find_file(file.removesuffix(name), "ovf") - fullname = find_file(lpegmatch(p_removesuffix, name), "ovf") + --fullname = kpsefind_file(file.removesuffix(name), "ovf") + fullname = kpsefind_file(lpegmatch(p_removesuffix, name), "ovf") end if fullname then log("loading virtual font file %s.", fullname) @@ -1745,6 +1821,16 @@ pop_namespaces(our_environment, false)-- true) log("fontloader loaded in %0.3f seconds", os.gettimeofday()-starttime) +% \end{macrocode} +% Restore original \luafunction{kpse.expand_path} function. +% +% \begin{macrocode} + +if normal_expand_path ~= nil then + kpse.expand_path = normal_expand_path + phantom_kpse = nil +end + % \end{macrocode} % \subsection{Callbacks} % After the fontloader is ready we can restore the callback trap from -- cgit v1.2.3 From c1406e4fff6268137d2fad0a96cf6382e625bf16 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 20 May 2013 21:24:52 +0200 Subject: [doc] escape verbatims --- luaotfload.dtx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/luaotfload.dtx b/luaotfload.dtx index 706ee1c..1c21460 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1511,10 +1511,10 @@ if tex.luatexversion < luatex_version then end % \end{macrocode} -% Create $TEXMFCACHE if not present. This is necessary due to +% Create \verb|$TEXMFCACHE| if not present. This is necessary due to % two bugs in Luatex-Fonts that surface simultaneously if none % of the possible cache directories exists. We add a fixed version -% of lfs.mkdirs() first. +% of \verb|lfs.mkdirs()| first. % % \begin{macrocode} -- cgit v1.2.3 From e326f02d3f1db23d7f8dbbef328839666e9957ff Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 21 May 2013 11:10:20 +0200 Subject: restore catchall rule for non-assignment options --- luaotfload-features.lua | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/luaotfload-features.lua b/luaotfload-features.lua index 9713f95..a4d495e 100644 --- a/luaotfload-features.lua +++ b/luaotfload-features.lua @@ -1015,18 +1015,15 @@ local field = field_char^1 --- switches are “+key” | “-key” local normal_option = C(field) * ws * equals * ws * C(field) * ws local xetex_option = P"+" * ws * normal_option +local ignore_option = (1 - equals)^1 * equals * (1 - featuresep)^1 local assignment = xetex_option / handle_xetex_option + normal_option / handle_normal_option ------ assignment = (field / strip_leading_sign) * ws ------ * equals * ws ------ * (field / toboolean) + + ignore_option / handle_invalid_option local switch = P"+" * ws * C(field) * Cc(true) + P"-" * ws * C(field) * Cc(false) --- + C(field) * Cc(true) -- catch crap -local ignore = (1 - featuresep)^1 --- ignores one option - / handle_invalid_option + + C(field) * Cc(true) --- default local feature_expr = ws * Cg(assignment + switch) * ws -local option = feature_expr + ignore +local option = feature_expr local feature_list = Cf(Ct"" * option * (featuresep * option)^0 -- cgit v1.2.3 From ae2b1986d0c8a62fd4015499b02bdd1d5da9f99d Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 21 May 2013 11:30:29 +0200 Subject: fix inconsistency in fontname lookup --- luaotfload-database.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 0e46874..ee7701d 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -568,9 +568,11 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con subfamily = facenames.subfamily fullname = facenames.fullname psname = facenames.psname + fontname = facenames.fontname + pfullname = facenames.pfullname end - fontname = facenames.fontname or sanitize_string(face.fontname) - pfullname = facenames.pfullname or sanitize_string(face.fullname) + fontname = fontname or sanitize_string(face.fontname) + pfullname = pfullname or sanitize_string(face.fullname) local optsize, dsnsize, maxsize, minsize if #face.size > 0 then -- cgit v1.2.3 From 3452cfde0557e637b566dd87f922aa926f743e16 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 21 May 2013 20:47:34 +0200 Subject: sync with Context as of 2013-05-21 --- luaotfload-merged.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/luaotfload-merged.lua b/luaotfload-merged.lua index 82ea91f..310febe 100644 --- a/luaotfload-merged.lua +++ b/luaotfload-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 05/18/13 02:06:59 +-- merge date : 05/21/13 16:14:48 do -- begin closure to overcome local limits and interference @@ -2017,11 +2017,21 @@ local pattern=(noslashes^0*slashes)^0*(noperiod^1*period)^1*C(noperiod^1)*-1 local function suffixonly(name) return name and lpegmatch(pattern,name) or "" end +local pattern=(noslashes^0*slashes)^0*noperiod^1*((period*C(noperiod^1))^1)*-1+Cc("") +local function suffixesonly(name) + if name then + return lpegmatch(pattern,name) + else + return "" + end +end file.pathpart=pathpart file.basename=basename file.nameonly=nameonly file.suffixonly=suffixonly file.suffix=suffixonly +file.suffixesonly=suffixesonly +file.suffixes=suffixesonly file.dirname=pathpart file.extname=suffixonly local drive=C(R("az","AZ"))*colon @@ -3007,12 +3017,12 @@ if not caches.namespace or caches.namespace=="" or caches.namespace=="context" t caches.namespace='generic' end do - local cachepaths=kpse.expand_path('$TEXMFCACHE') or "" + local cachepaths=kpse.expand_var('$TEXMFCACHE') or "" if cachepaths=="" then - cachepaths=kpse.expand_path('$TEXMFVAR') + cachepaths=kpse.expand_var('$TEXMFVAR') or "" end if cachepaths=="" then - cachepaths=kpse.expand_path('$VARTEXMF') + cachepaths=kpse.expand_var('$VARTEXMF') or "" end if cachepaths=="" then cachepaths="." -- cgit v1.2.3 From f6e2761e6e9941c14a50f4222a6382fe14b35645 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 21 May 2013 20:50:30 +0200 Subject: sync luatex-fonts files (merged) --- luaotfload-basics-gen.lua | 6 +++--- luaotfload-basics-nod.lua | 13 +++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/luaotfload-basics-gen.lua b/luaotfload-basics-gen.lua index 0561778..4a46fbb 100644 --- a/luaotfload-basics-gen.lua +++ b/luaotfload-basics-gen.lua @@ -147,18 +147,18 @@ do -- standard context tree setup - local cachepaths = kpse.expand_path('$TEXMFCACHE') or "" + local cachepaths = kpse.expand_var('$TEXMFCACHE') or "" -- quite like tex live or so if cachepaths == "" then - cachepaths = kpse.expand_path('$TEXMFVAR') + cachepaths = kpse.expand_var('$TEXMFVAR') or "" end -- this also happened to be used if cachepaths == "" then - cachepaths = kpse.expand_path('$VARTEXMF') + cachepaths = kpse.expand_var('$VARTEXMF') or "" end -- and this is a last resort diff --git a/luaotfload-basics-nod.lua b/luaotfload-basics-nod.lua index 151d98a..5ab9df7 100644 --- a/luaotfload-basics-nod.lua +++ b/luaotfload-basics-nod.lua @@ -28,12 +28,12 @@ if tex.attribute[0] ~= 0 then end -attributes = { } +attributes = attributes or { } attributes.unsetvalue = -0x7FFFFFFF local numbers, last = { }, 127 -function attributes.private(name) +attributes.private = attributes.private or function(name) local number = numbers[name] if not number then if last < 255 then @@ -63,6 +63,9 @@ nodes.glyphcodes = glyphcodes local free_node = node.free local remove_node = node.remove local new_node = node.new +local traverse_id = node.traverse_id + +local math_code = nodecodes.math nodes.handlers.protectglyphs = node.protect_glyphs nodes.handlers.unprotectglyphs = node.unprotect_glyphs @@ -93,3 +96,9 @@ function nodes.pool.kern(k) n.kern = k return n end + +function nodes.endofmath(n) + for n in traverse_id(math_code,n.next) do + return n + end +end -- cgit v1.2.3 From 6bb6f091d1a7a0327cea59cb7c124b4b84e31059 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 21 May 2013 22:31:01 +0200 Subject: new, less brutal workaround for updated-yet-not-completely-satisfying ``lfs.mkdirs()`` --- luaotfload.dtx | 106 +++++++++++++++++++++++---------------------------------- 1 file changed, 42 insertions(+), 64 deletions(-) diff --git a/luaotfload.dtx b/luaotfload.dtx index 1c21460..af43615 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1451,18 +1451,23 @@ luaotfload.module = { license = "GPL v2.0" } -local luatexbase = luatexbase +local luatexbase = luatexbase -local type, next = type, next +local getmetatable = getmetatable +local rawset = rawset local setmetatable = setmetatable -local kpsefind_file = kpse.find_file +local type, next = type, next + + local kpseexpand_path = kpse.expand_path local kpseexpand_var = kpse.expand_var -local lfsisfile = lfs.isfile +local kpsefind_file = kpse.find_file local lfsisdir = lfs.isdir +local lfsisfile = lfs.isfile local lfsmkdir = lfs.mkdir local stringexplode = string.explode local stringgmatch = string.gmatch +local stringsub = string.sub local add_to_callback, create_callback = luatexbase.add_to_callback, luatexbase.create_callback @@ -1511,77 +1516,50 @@ if tex.luatexversion < luatex_version then end % \end{macrocode} -% Create \verb|$TEXMFCACHE| if not present. This is necessary due to -% two bugs in Luatex-Fonts that surface simultaneously if none -% of the possible cache directories exists. We add a fixed version -% of \verb|lfs.mkdirs()| first. +% Create $TEXMFCACHE if not present. This is necessary due to a bug +% in Luatex-Fonts that surfaces if none of the possible cache +% directories exists. We add a fixed version of lfs.mkdirs() first +% that will be installed as soon as l-file.lua tries to insert its +% buggy version. % % \begin{macrocode} -local ostype = os.type - +local ostype = os.type local mkdirs = function (path) - local full - for sub in stringgmatch(path, "([^\\/]+)") do - if full then - full = full .. "/" .. sub - else - if ostype == "windows" then - full = sub - else - full = "/" .. sub - end - end - if not lfsisdir(full) then - lfsmkdir(full) - end + local full + if ostype ~= "windows" and stringsub(path, 1, 1) == "/" then + --- absolute path, force initial backslash + full = "" + end + for sub in stringgmatch(path,"([^\\/]+)") do + if full then + full = full .. "/" .. sub + else + full = sub + end + if not lfsisdir(full) then + lfsmkdir(full) end + end end ---- +--- -local phantom_kpse, normal_expand_path -do --- take care of writable path - local cachepath = kpseexpand_path"$TEXMFCACHE" - if cachepath == "" then - cachepath = kpseexpand_path"$TEXMFVAR" - end - if cachepath == "" then --- dir missing, create - texio.write_nl("term and log", - "(luaotfload: cache directory inaccessible)") - local cachedest = kpseexpand_var"$TEXMFCACHE" - local pathsep = ostype == "windows" and ";" or ":" - if cachedest then - cachedest = stringexplode(cachedest, pathsep) - end - for _, path in next, cachedest do - if not lfsisdir(path) then - texio.write_nl("term and log", - "(luaotfload: creating path " .. path) - mkdirs(path) - if lfsisdir(path) then - local writable = kpseexpand_path("$TEXMFCACHE", true) - texio.write("term and log", " -- success)") - phantom_kpse = kpse.new "luatex" - goto writable_cache - end - texio.write("term and log", " FAILED!)") - end - end - end -end +local backup_mkdirs -- just in case -::writable_cache:: -if phantom_kpse ~= nil then - normal_expand_path = kpseexpand_path - kpse.expand_path = function (spec) - --- the second kpse instance is needed because kpathsea - --- doesn’t update variables - --- http://www.ntg.nl/pipermail/dev-luatex/2007-December/001172.html - return phantom_kpse:expand_path(spec) - end +local lfs_mt = getmetatable(lfs) or { } --- should be empty + +lfs_mt.__newindex = function (t, k, v) + if k == "mkdirs" then + backup_mkdirs = v --> backup + rawset(t, "mkdirs", mkdirs) --> ours + else -- insert normally + t[k] = v + end end +setmetatable(lfs, lfs_mt) + --- % \end{macrocode} -- cgit v1.2.3 From bd84183e5fb0e97e974b4a9c5fdfac776fdf369a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 21 May 2013 22:38:35 +0200 Subject: [doc] fix verbatim etc. (again...) --- luaotfload.dtx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/luaotfload.dtx b/luaotfload.dtx index af43615..8042a6f 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1516,10 +1516,10 @@ if tex.luatexversion < luatex_version then end % \end{macrocode} -% Create $TEXMFCACHE if not present. This is necessary due to a bug +% Create \verb+$TEXMFCACHE+ if not present. This is necessary due to a bug % in Luatex-Fonts that surfaces if none of the possible cache -% directories exists. We add a fixed version of lfs.mkdirs() first -% that will be installed as soon as l-file.lua tries to insert its +% directories exists. We add a fixed version of \luafunction{lfs.mkdirs} first +% that will be installed as soon as \fileent{l-file.lua} tries to insert its % buggy version. % % \begin{macrocode} -- cgit v1.2.3