From 1ef6591eecdbb9cd047b80992dc71beb287fa3e6 Mon Sep 17 00:00:00 2001
From: Philipp Gesang <phg42.2a@gmail.com>
Date: Mon, 27 May 2013 15:10:21 +0200
Subject: implement kpse-only font resolver

---
 luaotfload.dtx | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

(limited to 'luaotfload.dtx')

diff --git a/luaotfload.dtx b/luaotfload.dtx
index b4b7940..83885a0 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -1797,7 +1797,7 @@ loadmodule"colors.lua"     --- “font-clr”
 %    \begin{macrocode}
 
 local request_resolvers   = fonts.definers.resolvers
-local formats             = fonts.formats
+local formats             = fonts.formats -- nice table; does lowercasing ...
 formats.ofm               = "type1"
 
 %    \end{macrocode}
@@ -1916,6 +1916,33 @@ request_resolvers.path = function (specification)
     end
 end
 
+%    \end{macrocode}
+% {\bfseries EXPERIMENTAL}
+% \identifier{kpse}-only resolver, for those who can do without system
+% fonts.
+%
+%    \begin{macrocode}
+
+request_resolvers.kpse = function (specification)
+    local name       = specification.name
+    local suffix     = file.suffix(name)
+    if suffix and formats[suffix] then
+        name = file.removesuffix(name)
+        if resolvers.findfile(name, suffix) then
+            specification.forced = suffix
+            specification.name   = name
+            return
+        end
+    end
+    for t, format in next, formats do --- brute force
+        if kpse.find_file (name, format) then
+            specification.forced = t
+            specification.name   = name
+            return
+        end
+    end
+end
+
 %    \end{macrocode}
 % We create a callback for patching fonts on the fly, to be used by other
 % packages.
-- 
cgit v1.2.3

