summaryrefslogtreecommitdiff
path: root/luaotfload.dtx
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-11-05 20:52:25 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2013-11-05 20:52:25 +0100
commit74207efa91378a06eea07e24f65346e9e4a4eb3c (patch)
tree3521aac1fc7a28ff2a1c971eca94cf36ec53c06e /luaotfload.dtx
parent9dc36bf3fc8a076d53b8abcb35c9c86f167a2d3a (diff)
parentc05e323e497d7d8e3befb371d6b78e1f91be83d9 (diff)
downloadluaotfload-74207efa91378a06eea07e24f65346e9e4a4eb3c.tar.gz
Merge branch 'font-matching'
Conflicts: NEWS luaotfload-database.lua luaotfload-override.lua luaotfload.dtx
Diffstat (limited to 'luaotfload.dtx')
-rw-r--r--luaotfload.dtx67
1 files changed, 51 insertions, 16 deletions
diff --git a/luaotfload.dtx b/luaotfload.dtx
index b0fb17d..4107185 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -1174,7 +1174,7 @@ and the derived files
% \fileent{luatex-fonts.lua} unmodified into \fileent{luaotfload.lua}.
% Thus if you prefer running bleeding edge code from the
% \CONTEXT beta, all you have to do is remove
-% \fileent{luaotfload-fontloader.lua} from the search path.
+% \fileent{luaotfload-merged.lua} from the search path.
%
% Also, the merged file at some point
% loads the Adobe Glyph List from a \LUA table that is contained in
@@ -1550,6 +1550,9 @@ config.luaotfload.names_dir = config.luaotfload.names_dir or "names
config.luaotfload.cache_dir = config.luaotfload.cache_dir or "fonts"
config.luaotfload.index_file = config.luaotfload.index_file or "luaotfload-names.lua"
config.luaotfload.formats = config.luaotfload.formats or "otf,ttf,ttc,dfont"
+if not config.luaotfload.strip then
+ config.luaotfload.strip = true
+end
luaotfload.module = {
name = "luaotfload",
@@ -1667,7 +1670,7 @@ end
% How this is executed depends on the presence on the \emphasis{merged
% font loader code}.
% In \identifier{luaotfload} this is contained in the file
-% \fileent{luaotfload-fontloader.lua}.
+% \fileent{luaotfload-merged.lua}.
% If this file cannot be found, the original libraries from \CONTEXT of
% which the merged code was composed are loaded instead.
% The imported font loader will call \luafunction{callback.register} once
@@ -1790,7 +1793,7 @@ if fonts then
log [["I am using the merged version of 'luaotfload.lua' here.]]
log [[ If you run into problems or experience unexpected]]
log [[ behaviour, and if you have ConTeXt installed you can try]]
- log [[ to delete the file 'luaotfload-fontloader.lua' as I might]]
+ log [[ to delete the file 'luaotfload-merged.lua' as I might]]
log [[ then use the possibly updated libraries. The merged]]
log [[ version is not supported as it is a frozen instance.]]
log [[ Problems can be reported to the ConTeXt mailing list."]]
@@ -1904,10 +1907,15 @@ loadmodule"colors.lua" --- “font-clr”
%
% \begin{macrocode}
+local filesuffix = file.suffix
+local fileremovesuffix = file.removesuffix
local request_resolvers = fonts.definers.resolvers
-local formats = fonts.formats -- nice table; does lowercasing ...
+local formats = fonts.formats
+local names = fonts.names
formats.ofm = "type1"
+fonts.encodings.known = fonts.encodings.known or { }
+
% \end{macrocode}
% \identifier{luaotfload} promises easy access to system fonts.
% Without additional precautions, this cannot be achieved by
@@ -1922,16 +1930,18 @@ formats.ofm = "type1"
% With the release version 2.2 the file names are indexed in the database
% as well and we are ready to resolve \verb|file:| lookups this way.
% Thus we no longer need to call the \identifier{kpathsea} library in
-% most cases when looking up font files, only when generating the database.
+% most cases when looking up font files, only when generating the database,
+% and when verifying the existence of a file in the \fileent{texmf} tree.
%
% \begin{macrocode}
-local resolvefile = fonts.names.crude_file_lookup
---local resolvefile = fonts.names.crude_file_lookup_verbose
+local resolve_file = names.crude_file_lookup
+--local resolve_file = names.crude_file_lookup_verbose
+local resolve_name = names.resolve_name
-request_resolvers.file = function (specification)
- local name = resolvefile(specification.name)
- local suffix = file.suffix(name)
+local file_resolver = function (specification)
+ local name = resolve_file (specification.name)
+ local suffix = filesuffix(name)
if formats[suffix] then
specification.forced = suffix
specification.forcedname = file.removesuffix(name)
@@ -1940,6 +1950,8 @@ request_resolvers.file = function (specification)
end
end
+request_resolvers.file = file_resolver
+
% \end{macrocode}
% We classify as \verb|anon:| those requests that have neither a
% prefix nor brackets. According to Khaled\footnote{%
@@ -1974,7 +1986,8 @@ request_resolvers.anon = function (specification)
for i=1, #type1_formats do
local format = type1_formats[i]
if resolvers.findfile(name, format) then
- specification.forced = format
+ specification.forcedname = file.addsuffix(name, format)
+ specification.forced = format
return
end
end
@@ -2011,9 +2024,9 @@ request_resolvers.path = function (specification)
logs.names_report("log", 1, "load",
"path lookup of %q unsuccessful, falling back to file:",
name)
- request_resolvers.file(specification)
+ file_resolver (specification)
else
- local suffix = file.suffix(name)
+ local suffix = filesuffix (name)
if formats[suffix] then
specification.forced = suffix
specification.name = file.removesuffix(name)
@@ -2032,12 +2045,12 @@ end
request_resolvers.kpse = function (specification)
local name = specification.name
- local suffix = file.suffix(name)
+ local suffix = filesuffix(name)
if suffix and formats[suffix] then
name = file.removesuffix(name)
if resolvers.findfile(name, suffix) then
- specification.forced = suffix
- specification.name = name
+ specification.forced = suffix
+ specification.forcedname = name
return
end
end
@@ -2051,6 +2064,28 @@ request_resolvers.kpse = function (specification)
end
% \end{macrocode}
+% The \verb|name:| resolver wraps the database function
+% \luafunction{resolve_name}.
+%
+% \begin{macrocode}
+
+--- fonts.names.resolvers.name -- Customized version of the
+--- generic name resolver.
+
+request_resolvers.name = function (specification)
+ local resolved, subfont = resolve_name (specification)
+ if resolved then
+ specification.resolved = resolved
+ specification.sub = subfont
+ specification.forced = filesuffix (resolved)
+ specification.forcedname = resolved
+ specification.name = fileremovesuffix (resolved)
+ else
+ file_resolver (specification)
+ end
+end
+
+% \end{macrocode}
% Also {\bfseries EXPERIMENTAL}:
% custom file resolvers via callback.
%