summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2014-01-15 22:53:20 -0800
committerPhilipp Gesang <phg42.2a@gmail.com>2014-01-15 22:53:20 -0800
commit164185fd15939f480627513cd42f4623f9d6d4e2 (patch)
tree257136c6ce3a71127bbd1474f2251eece0d52c6b
parent09316ec5b7eb2cc2b507aa9105e4197a90d29071 (diff)
parent2a5b67b754089b6fd3299e6621885ebcc3fb627b (diff)
downloadluaotfload-164185fd15939f480627513cd42f4623f9d6d4e2.tar.gz
Merge pull request #182 from phi-gamma/texlive2014
move main Lua file out of the DTX
-rw-r--r--.gitignore1
-rw-r--r--Makefile2
-rw-r--r--NEWS5
-rw-r--r--filegraph.dot6
-rw-r--r--luaotfload-colors.lua2
-rw-r--r--luaotfload-database.lua2
-rw-r--r--luaotfload-features.lua2
-rw-r--r--luaotfload-fontloader.lua2
-rw-r--r--luaotfload-letterspace.lua2
-rw-r--r--luaotfload-loaders.lua2
-rw-r--r--luaotfload-main.lua701
-rw-r--r--luaotfload-parsers.lua2
-rw-r--r--luaotfload.dtx687
-rwxr-xr-xmkstatus3
14 files changed, 732 insertions, 687 deletions
diff --git a/.gitignore b/.gitignore
index f231acf..e010a81 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,7 +18,6 @@ luaotfload-tool.1
luaotfload/*
# Files generated by 'make world' and removed by 'make mrproper'
-luaotfload.lua
luaotfload.pdf
luaotfload.sty
luaotfload.tds.zip
diff --git a/Makefile b/Makefile
index aec2ac0..8405e3a 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ RESOURCES = $(GLYPHS) $(CHARS) $(STATUS)
GRAPHED = $(DOTPDF)
MAN = $(MANPAGE)
COMPILED = $(DOC)
-UNPACKED = luaotfload.sty luaotfload.lua
+UNPACKED = luaotfload.sty
GENERATED = $(GRAPHED) $(UNPACKED) $(COMPILED) $(RESOURCES) $(MAN)
SOURCE = $(DTX) $(MANSOURCE) $(OTFL) README Makefile NEWS $(RESOURCESCRIPTS)
diff --git a/NEWS b/NEWS
index 9211e31..2e2bf8f 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,11 @@ Change History
* Remove compatibility with the old mkluatexfontdb script.
* Remove test directory. Use https://bitbucket.org/phg/lua-la-tex-tests
instead.
+ * Remove luaotfload.lua from luaotfload.dtx; it is now a separate file
+ luaotfload-main.lua.
+ * Move the heavier LPEG parsers from luaotfload-features (syntax) and
+ luaotfload-database (fontconfig) into the new file
+ luaotfload-parsers.lua.
2013/12/31, luaotfload v2.4
* Additional self-tests, now in separate file (luaotfload-diagnostics.lua)
diff --git a/filegraph.dot b/filegraph.dot
index 1228690..90e6e5c 100644
--- a/filegraph.dot
+++ b/filegraph.dot
@@ -122,7 +122,7 @@ strict digraph luaotfload_files { //looks weird with circo ...
style = "filled,rounded",
penwidth=2]
- luaotfload [label = "luaotfload.lua",
+ luaotfload [label = "luaotfload-main.lua",
shape = rect,
width = "3.2cm",
height = "1.2cm",
@@ -200,8 +200,8 @@ strict digraph luaotfload_files { //looks weird with circo ...
<th> <td colspan="2"> <font point-size="12" face="Iwona Italic">Luaotfload Libraries</font> </td> </th>
<tr> <td>luaotfload-auxiliary.lua</td> <td>luaotfload-features.lua</td> </tr>
<tr> <td>luaotfload-override.lua</td> <td>luaotfload-loaders.lua</td> </tr>
- <tr> <td>luaotfload-database.lua</td> <td>luaotfload-color.lua</td> </tr>
- <tr> <td>luaotfload-letterspace.lua</td> </tr>
+ <tr> <td>luaotfload-parsers.lua</td> <td>luaotfload-database.lua</td> </tr>
+ <tr> <td>luaotfload-color.lua</td> <td>luaotfload-letterspace.lua</td> </tr>
</table>
>,
]
diff --git a/luaotfload-colors.lua b/luaotfload-colors.lua
index 86e493f..d999df6 100644
--- a/luaotfload-colors.lua
+++ b/luaotfload-colors.lua
@@ -1,6 +1,6 @@
if not modules then modules = { } end modules ['luaotfload-colors'] = {
version = "2.5",
- comment = "companion to luaotfload.lua (font color)",
+ comment = "companion to luaotfload-main.lua (font color)",
author = "Khaled Hosny, Elie Roux, Philipp Gesang",
copyright = "Luaotfload Development Team",
license = "GNU GPL v2.0"
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index 3f321d2..98c5d3f 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -1,6 +1,6 @@
if not modules then modules = { } end modules ['luaotfload-database'] = {
version = "2.5",
- comment = "companion to luaotfload.lua",
+ comment = "companion to luaotfload-main.lua",
author = "Khaled Hosny, Elie Roux, Philipp Gesang",
copyright = "Luaotfload Development Team",
license = "GNU GPL v2.0"
diff --git a/luaotfload-features.lua b/luaotfload-features.lua
index d786549..5172f4b 100644
--- a/luaotfload-features.lua
+++ b/luaotfload-features.lua
@@ -1,6 +1,6 @@
if not modules then modules = { } end modules ["features"] = {
version = "2.5",
- comment = "companion to luaotfload.lua",
+ comment = "companion to luaotfload-main.lua",
author = "Hans Hagen, Khaled Hosny, Elie Roux, Philipp Gesang",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
diff --git a/luaotfload-fontloader.lua b/luaotfload-fontloader.lua
index a3a2de5..9f21df8 100644
--- a/luaotfload-fontloader.lua
+++ b/luaotfload-fontloader.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 01/07/14 17:03:56
+-- merge date : 01/14/14 16:21:00
do -- begin closure to overcome local limits and interference
diff --git a/luaotfload-letterspace.lua b/luaotfload-letterspace.lua
index d17aedf..1957f9a 100644
--- a/luaotfload-letterspace.lua
+++ b/luaotfload-letterspace.lua
@@ -1,6 +1,6 @@
if not modules then modules = { } end modules ['letterspace'] = {
version = "2.5",
- comment = "companion to luaotfload.lua",
+ comment = "companion to luaotfload-main.lua",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL; adapted by Philipp Gesang",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
diff --git a/luaotfload-loaders.lua b/luaotfload-loaders.lua
index fa00633..2aa8c7c 100644
--- a/luaotfload-loaders.lua
+++ b/luaotfload-loaders.lua
@@ -1,6 +1,6 @@
if not modules then modules = { } end modules ["loaders"] = {
version = "2.5",
- comment = "companion to luaotfload.lua",
+ comment = "companion to luaotfload-main.lua",
author = "Hans Hagen, Khaled Hosny, Elie Roux, Philipp Gesang",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
diff --git a/luaotfload-main.lua b/luaotfload-main.lua
new file mode 100644
index 0000000..27f0a99
--- /dev/null
+++ b/luaotfload-main.lua
@@ -0,0 +1,701 @@
+-----------------------------------------------------------------------
+-- FILE: luaotfload-main.lua
+-- DESCRIPTION: Luatex fontloader initialization
+-- REQUIREMENTS: luatex v.0.78 or later, the lualibs package
+-- AUTHOR: Élie Roux, Khaled Hosny, Philipp Gesang
+-- VERSION: same as Luaotfload
+-- MODIFIED: 2014-01-16 06:51:20+0100
+-----------------------------------------------------------------------
+--
+--- Note:
+--- This file was part of the original luaotfload.dtx and has been
+--- converted to a pure Lua file during the transition from Luaotfload
+--- version 2.4 to 2.5. Thus, the comments are still in TeX (Latex)
+--- markup.
+
+if not modules then modules = { } end modules ["luaotfload-main"] = {
+ version = "2.5",
+ comment = "fontloader initialization",
+ author = "Hans Hagen, Khaled Hosny, Elie Roux, Philipp Gesang",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "GNU General Public License v. 2.0"
+}
+
+
+--[[doc--
+
+ This file initializes the system and loads the font loader. To
+ minimize potential conflicts between other packages and the code
+ imported from \CONTEXT, several precautions are in order. Some of
+ the functionality that the font loader expects to be present, like
+ raw access to callbacks, are assumed to have been disabled by
+ \identifier{luatexbase} when this file is processed. In some cases
+ it is possible to trick it by putting dummies into place and
+ restoring the behavior from \identifier{luatexbase} after
+ initilization. Other cases such as attribute allocation require
+ that we hook the functionality from \identifier{luatexbase} into
+ locations where they normally wouldn’t be.
+
+ Anyways we can import the code base without modifications, which is
+ due mostly to the extra effort by Hans Hagen to make \LUATEX-Fonts
+ self-contained and encapsulate it, and especially due to his
+ willingness to incorporate our suggestions.
+
+--doc]]--
+
+luaotfload = luaotfload or { }
+local luaotfload = luaotfload
+
+config = config or { }
+config.luaotfload = config.luaotfload or { }
+------.luaotfload.resolver = config.luaotfload.resolver or "normal"
+config.luaotfload.resolver = config.luaotfload.resolver or "cached"
+config.luaotfload.definer = config.luaotfload.definer or "patch"
+config.luaotfload.loglevel = config.luaotfload.loglevel or 2
+config.luaotfload.color_callback = config.luaotfload.color_callback or "pre_linebreak_filter"
+config.luaotfload.prioritize = config.luaotfload.prioritize or "sys"
+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",
+ version = 2.50000,
+ date = "2014/**/**",
+ description = "OpenType layout system.",
+ author = "Elie Roux & Hans Hagen",
+ copyright = "Elie Roux",
+ license = "GPL v2.0"
+}
+
+local luatexbase = luatexbase
+
+local setmetatable = setmetatable
+local type, next = type, next
+
+local kpsefind_file = kpse.find_file
+local lfsisfile = lfs.isfile
+
+local add_to_callback, create_callback =
+ luatexbase.add_to_callback, luatexbase.create_callback
+local reset_callback, call_callback =
+ luatexbase.reset_callback, luatexbase.call_callback
+
+local dummy_function = function () end
+
+local error, warning, info, log =
+ luatexbase.provides_module(luaotfload.module)
+
+luaotfload.error = error
+luaotfload.warning = warning
+luaotfload.info = info
+luaotfload.log = log
+
+--[[doc--
+
+ We set the minimum version requirement for \LUATEX to v0.76,
+ because the font loader requires recent features like direct
+ attribute indexing and \luafunction{node.end_of_math()} that aren’t
+ available in earlier versions.\footnote{%
+ See Taco’s announcement of v0.76:
+ \url{http://comments.gmane.org/gmane.comp.tex.luatex.user/4042}
+ and this commit by Hans that introduced those features.
+ \url{http://repo.or.cz/w/context.git/commitdiff/a51f6cf6ee087046a2ae5927ed4edff0a1acec1b}.
+ }
+
+--doc]]--
+
+local luatex_version = 76
+
+if tex.luatexversion < luatex_version then
+ warning("LuaTeX v%.2f is old, v%.2f is recommended.",
+ tex.luatexversion/100,
+ luatex_version /100)
+ --- we install a fallback for older versions as a safety
+ if not node.end_of_math then
+ local math_t = node.id"math"
+ local traverse_nodes = node.traverse_id
+ node.end_of_math = function (n)
+ for n in traverse_nodes(math_t, n.next) do
+ return n
+ end
+ end
+ end
+end
+
+--[[doc--
+
+ \subsection{Module loading}
+ We load the files imported from \CONTEXT with this function. It
+ automatically prepends the prefix \fileent{luaotfload-} to its
+ argument, so we can refer to the files with their actual \CONTEXT
+ name.
+
+--doc]]--
+
+local fl_prefix = "luaotfload" -- “luatex” for luatex-plain
+local loadmodule = function (name)
+ require(fl_prefix .."-"..name)
+end
+
+--[[doc--
+
+ Before \TeX Live 2013 version, \LUATEX had a bug that made ofm fonts
+ fail when called with their extension. There was a side-effect making
+ ofm totally unloadable when luaotfload was present. The following
+ lines are a patch for this bug. The utility of these lines is
+ questionable as they are not necessary since \TeX Live 2013. They
+ should be removed in the next version.
+
+--doc]]--
+
+local Cs, P, lpegmatch = lpeg.Cs, lpeg.P, lpeg.match
+
+local p_dot, p_slash = P".", P"/"
+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 = kpsefind_file(name, "ovf")
+ if not fullname then
+ --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)
+ end
+ return fullname
+end
+
+--[[doc--
+
+ \subsection{Preparing the Font Loader}
+ We treat the fontloader as a black box so behavior is consistent
+ between formats.
+ We load the fontloader code directly in the same fashion as the
+ Plain format \identifier{luatex-fonts} that is part of Context.
+ 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-merged.lua}.
+ If this file cannot be found, the original libraries from \CONTEXT
+ of which the merged code was composed are loaded instead.
+ Since these files are not shipped with Luaotfload, an installation
+ of Context is required.
+ (Since we pull the fontloader directly from the Context minimals,
+ the necessary Context version is likely to be more recent than that
+ of other TeX distributions like Texlive.)
+ The imported font loader will call \luafunction{callback.register}
+ once while reading \fileent{font-def.lua}.
+ This is unavoidable unless we modify the imported files, but
+ harmless if we make it call a dummy instead.
+ However, this problem might vanish if we decide to do the merging
+ ourselves, like the \identifier{lualibs} package does.
+ With this step we would obtain the freedom to load our own
+ overrides in the process right where they are needed, at the cost
+ of losing encapsulation.
+ The decision on how to progress is currently on indefinite hold.
+
+--doc]]--
+
+local starttime = os.gettimeofday()
+
+local trapped_register = callback.register
+callback.register = dummy_function
+
+--[[doc--
+
+ By default, the fontloader requires a number of \emphasis{private
+ attributes} for internal use.
+ These must be kept consistent with the attribute handling methods
+ as provided by \identifier{luatexbase}.
+ Our strategy is to override the function that allocates new
+ attributes before we initialize the font loader, making it a
+ wrapper around \luafunction{luatexbase.new_attribute}.\footnote{%
+ Many thanks, again, to Hans Hagen for making this part
+ configurable!
+ }
+ The attribute identifiers are prefixed “\fileent{luaotfload@}” to
+ avoid name clashes.
+
+--doc]]--
+
+do
+ local new_attribute = luatexbase.new_attribute
+ local the_attributes = luatexbase.attributes
+
+ attributes = attributes or { }
+
+ attributes.private = function (name)
+ local attr = "luaotfload@" .. name --- used to be: “otfl@”
+ local number = the_attributes[attr]
+ if not number then
+ number = new_attribute(attr)
+ end
+ return number
+ end
+end
+
+--[[doc--
+
+ These next lines replicate the behavior of
+ \fileent{luatex-fonts.lua}.
+
+--doc]]--
+
+local context_environment = { }
+
+local push_namespaces = function ()
+ log("push namespace for font loader")
+ local normalglobal = { }
+ for k, v in next, _G do
+ normalglobal[k] = v
+ end
+ return normalglobal
+end
+
+local pop_namespaces = function (normalglobal, isolate)
+ if normalglobal then
+ local _G = _G
+ local mode = "non-destructive"
+ if isolate then mode = "destructive" end
+ log("pop namespace from font loader -- " .. mode)
+ for k, v in next, _G do
+ if not normalglobal[k] then
+ context_environment[k] = v
+ if isolate then
+ _G[k] = nil
+ end
+ end
+ end
+ for k, v in next, normalglobal do
+ _G[k] = v
+ end
+ -- just to be sure:
+ setmetatable(context_environment,_G)
+ else
+ log("irrecoverable error during pop_namespace: no globals to restore")
+ os.exit()
+ end
+end
+
+luaotfload.context_environment = context_environment
+luaotfload.push_namespaces = push_namespaces
+luaotfload.pop_namespaces = pop_namespaces
+
+local our_environment = push_namespaces()
+
+--[[doc--
+
+ The font loader requires that the attribute with index zero be
+ zero. We happily oblige.
+ (Cf. \fileent{luatex-fonts-nod.lua}.)
+
+--doc]]--
+
+tex.attribute[0] = 0
+
+--[[doc--
+
+ Now that things are sorted out we can finally load the fontloader.
+
+--doc]]--
+
+loadmodule "fontloader.lua"
+---loadmodule"font-odv.lua" --- <= Devanagari support from Context
+
+if fonts then
+
+ if not fonts._merge_loaded_message_done_ then
+ log [["I am using the merged fontloader 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 [[ 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."]]
+ end
+ fonts._merge_loaded_message_done_ = true
+
+else--- the loading sequence is known to change, so this might have to
+ --- be updated with future updates!
+ --- do not modify it though unless there is a change to the merged
+ --- package!
+ loadmodule("l-lua.lua")
+ loadmodule("l-lpeg.lua")
+ loadmodule("l-function.lua")
+ loadmodule("l-string.lua")
+ loadmodule("l-table.lua")
+ loadmodule("l-io.lua")
+ loadmodule("l-file.lua")
+ loadmodule("l-boolean.lua")
+ loadmodule("l-math.lua")
+ loadmodule("util-str.lua")
+ loadmodule('luatex-basics-gen.lua')
+ loadmodule('data-con.lua')
+ loadmodule('luatex-basics-nod.lua')
+ loadmodule('font-ini.lua')
+ loadmodule('font-con.lua')
+ loadmodule('luatex-fonts-enc.lua')
+ loadmodule('font-cid.lua')
+ loadmodule('font-map.lua')
+ loadmodule('luatex-fonts-syn.lua')
+ loadmodule('luatex-fonts-tfm.lua')
+ loadmodule('font-oti.lua')
+ loadmodule('font-otf.lua')
+ loadmodule('font-otb.lua')
+ loadmodule('luatex-fonts-inj.lua') --> since 2014-01-07, replaces node-inj.lua
+ loadmodule('font-ota.lua')
+ loadmodule('luatex-fonts-otn.lua') --> since 2014-01-07, replaces font-otn.lua
+ loadmodule('font-otp.lua') --> since 2013-04-23
+ loadmodule('luatex-fonts-lua.lua')
+ loadmodule('font-def.lua')
+ loadmodule('luatex-fonts-def.lua')
+ loadmodule('luatex-fonts-ext.lua')
+ loadmodule('luatex-fonts-cbk.lua')
+end --- non-merge fallback scope
+
+--[[doc--
+
+ Here we adjust the globals created during font loader
+ initialization. If the second argument to
+ \luafunction{pop_namespaces()} is \verb|true| this will restore the
+ state of \luafunction{_G}, eliminating every global generated since
+ the last call to \luafunction{push_namespaces()}. At the moment we
+ see no reason to do this, and since the font loader is considered
+ an essential part of \identifier{luatex} as well as a very well
+ organized piece of code, we happily concede it the right to add to
+ \luafunction{_G} if needed.
+
+--doc]]--
+
+pop_namespaces(our_environment, false)-- true)
+
+log("fontloader loaded in %0.3f seconds", os.gettimeofday()-starttime)
+
+--[[doc--
+
+ \subsection{Callbacks}
+ After the fontloader is ready we can restore the callback trap from
+ \identifier{luatexbase}.
+
+--doc]]--
+
+callback.register = trapped_register
+
+--[[doc--
+
+ We do our own callback handling with the means provided by
+ luatexbase.
+ Note: \luafunction{pre_linebreak_filter} and
+ \luafunction{hpack_filter} are coupled in \CONTEXT in the concept
+ of \emphasis{node processor}.
+
+--doc]]--
+
+add_to_callback("pre_linebreak_filter",
+ nodes.simple_font_handler,
+ "luaotfload.node_processor",
+ 1)
+add_to_callback("hpack_filter",
+ nodes.simple_font_handler,
+ "luaotfload.node_processor",
+ 1)
+add_to_callback("find_vf_file",
+ find_vf_file, "luaotfload.find_vf_file")
+
+loadmodule "override.lua" --- “luat-ovr”
+
+logs.set_loglevel(config.luaotfload.loglevel)
+
+--[[doc--
+
+ Now we load the modules written for \identifier{luaotfload}.
+
+--doc]]--
+loadmodule "parsers.lua" --- new in 2.5; fonts.conf and syntax
+loadmodule "loaders.lua" --- “font-pfb” new in 2.0, added 2011
+loadmodule "database.lua" --- “font-nms”
+loadmodule "colors.lua" --- “font-clr”
+
+--[[doc--
+
+ Relying on the \verb|name:| resolver for everything has been the
+ source of permanent trouble with the database.
+ With the introduction of the new syntax parser we now have enough
+ granularity to distinguish between the \XETEX emulation layer and
+ the genuine \verb|name:| and \verb|file:| lookups of \LUATEX-Fonts.
+ Another benefit is that we can now easily plug in or replace new
+ lookup behaviors if necessary.
+ The name resolver remains untouched, but it calls
+ \luafunction{fonts.names.resolve()} internally anyways (see
+ \fileent{luaotfload-database.lua}).
+
+--doc]]--
+
+local filesuffix = file.suffix
+local fileremovesuffix = file.removesuffix
+local request_resolvers = fonts.definers.resolvers
+local formats = fonts.formats
+local names = fonts.names
+formats.ofm = "type1"
+
+fonts.encodings.known = fonts.encodings.known or { }
+
+--[[doc--
+
+ \identifier{luaotfload} promises easy access to system fonts.
+ Without additional precautions, this cannot be achieved by
+ \identifier{kpathsea} alone, because it searches only the
+ \fileent{texmf} directories by default.
+ Although it is possible for \identifier{kpathsea} to include extra
+ paths by adding them to the \verb|OSFONTDIR| environment variable,
+ this is still short of the goal »\emphasis{it just works!}«.
+ When building the font database \identifier{luaotfload} scans
+ system font directories anyways, so we already have all the
+ information for looking sytem fonts.
+ 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, and when verifying the existence of a file in the
+ \fileent{texmf} tree.
+
+--doc]]--
+
+local resolve_file = names.crude_file_lookup
+--local resolve_file = names.crude_file_lookup_verbose
+local resolve_name = names.resolve_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)
+ else
+ specification.name = name
+ end
+end
+
+request_resolvers.file = file_resolver
+
+--[[doc--
+
+ We classify as \verb|anon:| those requests that have neither a
+ prefix nor brackets. According to Khaled\footnote{%
+ \url{https://github.com/phi-gamma/luaotfload/issues/4#issuecomment-17090553}.
+ }
+ they are the \XETEX equivalent of a \verb|name:| request, so we
+ will be treating them as such.
+
+--doc]]--
+
+--request_resolvers.anon = request_resolvers.name
+
+--[[doc--
+
+ There is one drawback, though.
+ This syntax is also used for requesting fonts in \identifier{Type1}
+ (\abbrev{tfm}, \abbrev{ofm}) format.
+ These are essentially \verb|file:| lookups and must be caught
+ before the \verb|name:| resolver kicks in, lest they cause the
+ database to update.
+ Even if we were to require the \verb|file:| prefix for all
+ \identifier{Type1} requests, tests have shown that certain fonts
+ still include further fonts (e.~g. \fileent{omlgcb.ofm} will ask
+ for \fileent{omsecob.tfm}) \emphasis{using the old syntax}.
+ For this reason, we introduce an extra check with an early return.
+
+--doc]]--
+
+local type1_formats = { "tfm", "ofm", }
+
+request_resolvers.anon = function (specification)
+ local name = specification.name
+ for i=1, #type1_formats do
+ local format = type1_formats[i]
+ if resolvers.findfile(name, format) then
+ specification.forcedname = file.addsuffix(name, format)
+ specification.forced = format
+ return
+ end
+ end
+ --- under some weird circumstances absolute paths get
+ --- passed to the definer; we have to catch them
+ --- before the name: resolver misinterprets them.
+ name = specification.specification
+ local exists, _ = lfsisfile(name)
+ if exists then --- garbage; we do this because we are nice,
+ --- not because it is correct
+ logs.names_report("log", 1, "load", "file %q exists", name)
+ logs.names_report("log", 1, "load",
+ "... overriding borked anon: lookup with path: lookup")
+ specification.name = name
+ request_resolvers.path(specification)
+ return
+ end
+ request_resolvers.name(specification)
+end
+
+--[[doc--
+
+ Prior to version 2.2, \identifier{luaotfload} did not distinguish
+ \verb|file:| and \verb|path:| lookups, causing complications with
+ the resolver.
+ Now we test if the requested name is an absolute path in the file
+ system, otherwise we fall back to the \verb|file:| lookup.
+
+--doc]]--
+
+request_resolvers.path = function (specification)
+ local name = specification.name
+ local exists, _ = lfsisfile(name)
+ if not exists then -- resort to file: lookup
+ logs.names_report("log", 1, "load",
+ "path lookup of %q unsuccessful, falling back to file:",
+ name)
+ file_resolver (specification)
+ else
+ local suffix = filesuffix (name)
+ if formats[suffix] then
+ specification.forced = suffix
+ specification.name = file.removesuffix(name)
+ specification.forcedname = name
+ else
+ specification.name = name
+ end
+ end
+end
+
+--[[doc--
+
+ {\bfseries EXPERIMENTAL}:
+ \identifier{kpse}-only resolver, for those who can do without
+ system fonts.
+
+--doc]]--
+
+request_resolvers.kpse = function (specification)
+ local name = specification.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.forcedname = 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
+
+--[[doc--
+
+ The \verb|name:| resolver wraps the database function
+ \luafunction{resolve_name}.
+
+--doc]]--
+
+--- 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
+
+--[[doc--
+
+ Also {\bfseries EXPERIMENTAL}: custom file resolvers via callback.
+
+--doc]]--
+create_callback("luaotfload.resolve_font", "simple", dummy_function)
+
+request_resolvers.my = function (specification)
+ call_callback("luaotfload.resolve_font", specification)
+end
+
+--[[doc--
+
+ We create a callback for patching fonts on the fly, to be used by
+ other packages.
+ It initially contains the empty function that we are going to
+ override below.
+
+--doc]]--
+
+create_callback("luaotfload.patch_font", "simple", dummy_function)
+
+--[[doc--
+
+ \subsection{\CONTEXT override}
+ \label{define-font}
+ We provide a simplified version of the original font definition
+ callback.
+
+--doc]]--
+
+local read_font_file = fonts.definers.read
+
+--- spec -> size -> id -> tmfdata
+local patch_defined_font = function (specification, size, id)
+ local tfmdata = read_font_file(specification, size, id)
+ if type(tfmdata) == "table" and tfmdata.shared then
+ --- We need to test for the “shared” field here
+ --- or else the fontspec capheight callback will
+ --- operate on tfm fonts.
+ call_callback("luaotfload.patch_font", tfmdata, specification)
+ end
+ return tfmdata
+end
+
+reset_callback "define_font"
+
+--[[doc--
+
+ Finally we register the callbacks.
+
+--doc]]--
+
+local font_definer = config.luaotfload.definer
+
+if font_definer == "generic" then
+ add_to_callback("define_font",
+ fonts.definers.read,
+ "luaotfload.define_font",
+ 1)
+elseif font_definer == "patch" then
+ add_to_callback("define_font",
+ patch_defined_font,
+ "luaotfload.define_font",
+ 1)
+end
+
+loadmodule "features.lua" --- contains what was “font-ltx” and “font-otc”
+loadmodule "letterspace.lua" --- extra character kerning
+loadmodule "auxiliary.lua" --- additionaly high-level functionality (new)
+
+luaotfload.aux.start_rewrite_fontname () --- to be migrated to fontspec
+
+-- vim:tw=79:sw=4:ts=4:et
diff --git a/luaotfload-parsers.lua b/luaotfload-parsers.lua
index e6db21f..42a43aa 100644
--- a/luaotfload-parsers.lua
+++ b/luaotfload-parsers.lua
@@ -11,7 +11,7 @@
if not modules then modules = { } end modules ['luaotfload-parsers'] = {
version = "2.5",
- comment = "companion to luaotfload.lua",
+ comment = "companion to luaotfload-main.lua",
author = "Philipp Gesang",
copyright = "Luaotfload Development Team",
license = "GNU GPL v2.0"
diff --git a/luaotfload.dtx b/luaotfload.dtx
index 366cb87..8f8632c 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -12,7 +12,7 @@
%
% This work consists of the main source file luaotfload.dtx
% and the derived files
-% luaotfload.sty, luaotfload.lua
+% luaotfload.sty
%
% Unpacking:
% tex luaotfload.dtx
@@ -63,7 +63,7 @@ This work is under the GPL v2.0 license.
This work consists of the main source file luaotfload.dtx
and the derived files
- luaotfload.sty, luaotfload.lua
+ luaotfload.sty
\endpreamble
@@ -74,30 +74,13 @@ and the derived files
\file{luaotfload.sty}{\from{luaotfload.dtx}{package}}%
}
-% The following hacks are to generate a lua file with lua comments starting with
-% -- instead of %%
-
-\def\MetaPrefix{-- }
-
-\def\luapostamble{%
- \MetaPrefix^^J%
- \MetaPrefix\space End of File `\outFileName'.%
-}
-
-\def\currentpostamble{\luapostamble}%
-
-\generate{%
- \usedir{tex/luatex/luaotfload}%
- \file{luaotfload.lua}{\from{luaotfload.dtx}{lua}}%%
-}
-
\obeyspaces
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* files into a directory searched by TeX:}
\Msg{*}
-\Msg{* luaotfload.sty, luaotfload.lua}
+\Msg{* luaotfload.sty}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
@@ -1227,7 +1210,7 @@ and the derived files
% instead.
% Their names remain the same as in \CONTEXT (without the
% \verb|otfl|-prefix) since we imported the relevant section of
-% \fileent{luatex-fonts.lua} unmodified into \fileent{luaotfload.lua}.
+% \fileent{luatex-fonts.lua} unmodified into \fileent{luaotfload-main.lua}.
% Thus if you prefer running bleeding edge code from the
% \CONTEXT beta, all you have to do is remove
% \fileent{luaotfload-merged.lua} from the search path.
@@ -1264,6 +1247,7 @@ and the derived files
% font reader as handler for
% Postscript fonts
% (\abbrev{pfa}, \abbrev{pfb}).
+% \ouritem {luaotfload-parsers.lua} various \abbrev{lpeg}-based parsers.
% \ouritem {luaotfload-database.lua} font names database.
% \ouritem {luaotfload-colors.lua} color handling.
% \ouritem {luaotfload-auxiliary.lua} access to internal functionality
@@ -1565,657 +1549,12 @@ and the derived files
%
% \section{\fileent{luaotfload.lua}}
%
-% This file initializes the system and loads the font loader.
-% To minimize potential conflicts between other packages and the
-% code imported from \CONTEXT, several precautions are in order.
-% Some of the functionality that the font loader expects to be present,
-% like raw access to callbacks, are assumed to have been disabled by
-% \identifier{luatexbase} when this file is processed.
-% In some cases it is possible to trick it by putting dummies into
-% place and restoring the behavior from \identifier{luatexbase} after
-% initilization.
-% Other cases such as attribute allocation require that we hook the
-% functionality from \identifier{luatexbase} into locations where they
-% normally wouldn’t be.
-%
-% Anyways we can import the code base without modifications, which is
-% due mostly to the extra effort by
-% Hans Hagen to make \LUATEX-Fonts self-contained and encapsulate it,
-% and especially due to his willingness to incorporate our suggestions.
-%
-% \iffalse
-%<*lua>
-% \fi
-% \begin{macrocode}
-luaotfload = luaotfload or {}
-local luaotfload = luaotfload
-
-config = config or { }
-config.luaotfload = config.luaotfload or { }
-------.luaotfload.resolver = config.luaotfload.resolver or "normal"
-config.luaotfload.resolver = config.luaotfload.resolver or "cached"
-config.luaotfload.definer = config.luaotfload.definer or "patch"
-config.luaotfload.loglevel = config.luaotfload.loglevel or 2
-config.luaotfload.color_callback = config.luaotfload.color_callback or "pre_linebreak_filter"
-config.luaotfload.prioritize = config.luaotfload.prioritize or "sys"
-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",
- version = 2.50000,
- date = "2014/**/**",
- description = "OpenType layout system.",
- author = "Elie Roux & Hans Hagen",
- copyright = "Elie Roux",
- license = "GPL v2.0"
-}
-
-local luatexbase = luatexbase
-
-local setmetatable = setmetatable
-local type, next = type, next
-
-local kpsefind_file = kpse.find_file
-local lfsisfile = lfs.isfile
-
-local add_to_callback, create_callback =
- luatexbase.add_to_callback, luatexbase.create_callback
-local reset_callback, call_callback =
- luatexbase.reset_callback, luatexbase.call_callback
-
-local dummy_function = function () end
-
-local error, warning, info, log =
- luatexbase.provides_module(luaotfload.module)
-
-luaotfload.error = error
-luaotfload.warning = warning
-luaotfload.info = info
-luaotfload.log = log
-
-% \end{macrocode}
-% We set the minimum version requirement for \LUATEX to v0.76,
-% because the font loader requires recent features like direct
-% attribute indexing and \luafunction{node.end_of_math()} that aren’t
-% available in earlier versions.\footnote{%
-% See Taco’s announcement of v0.76:
-% \url{http://comments.gmane.org/gmane.comp.tex.luatex.user/4042}
-% and this commit by Hans that introduced those features.
-% \url{http://repo.or.cz/w/context.git/commitdiff/a51f6cf6ee087046a2ae5927ed4edff0a1acec1b}.
-% }
-%
-% \begin{macrocode}
-
-local luatex_version = 76
-
-if tex.luatexversion < luatex_version then
- warning("LuaTeX v%.2f is old, v%.2f is recommended.",
- tex.luatexversion/100,
- luatex_version /100)
- --- we install a fallback for older versions as a safety
- if not node.end_of_math then
- local math_t = node.id"math"
- local traverse_nodes = node.traverse_id
- node.end_of_math = function (n)
- for n in traverse_nodes(math_t, n.next) do
- return n
- end
- end
- end
-end
-
-% \end{macrocode}
-% \subsection{Module loading}
-% We load the files imported from \CONTEXT with this function.
-% It automatically prepends the prefix \fileent{luaotfload-} to its
-% argument, so we can refer to the files with their actual \CONTEXT name.
-%
-% \begin{macrocode}
-
-local fl_prefix = "luaotfload" -- “luatex” for luatex-plain
-local loadmodule = function (name)
- require(fl_prefix .."-"..name)
-end
-
-% \end{macrocode}
-% Before \TeX Live 2013 version, \LUATEX had a bug that made ofm fonts fail
-% when called with their extension. There was a side-effect making ofm
-% totally unloadable when luaotfload was present. The following lines are
-% a patch for this bug. The utility of these lines is questionable as they
-% are not necessary since \TeX Live 2013. They should be removed in the next
-% version.
-%
-% \begin{macrocode}
-local Cs, P, lpegmatch = lpeg.Cs, lpeg.P, lpeg.match
-
-local p_dot, p_slash = P".", P"/"
-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 = kpsefind_file(name, "ovf")
- if not fullname then
- --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)
- end
- return fullname
-end
-
-% \end{macrocode}
-% \subsection{Preparing the Font Loader}
-% We treat the fontloader as a black box so behavior is consistent
-% between formats.
-% We do no longer run the intermediate wrapper file
-% \fileent{luaotfload-fonts.lua} which we used to import from
-% \href{http://standalone.contextgarden.net/current/context/experimental/tex/generic/context/luatex/}{\LUATEX-Plain}.
-% Rather, we load the fontloader code directly in the same fashion as
-% \identifier{luatex-fonts}.
-% 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-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
-% while reading \fileent{font-def.lua}.
-% This is unavoidable unless we modify the imported files, but harmless
-% if we make it call a dummy instead.
-% However, this problem might vanish if we decide to do the merging
-% ourselves, like the \identifier{lualibs} package does.
-% With this step we would obtain the freedom to load our own overrides in
-% the process right where they are needed, at the cost of losing
-% encapsulation.
-% The decision on how to progress is currently on indefinite hold.
-%
-% \begin{macrocode}
-
-local starttime = os.gettimeofday()
-
-local trapped_register = callback.register
-callback.register = dummy_function
-
-% \end{macrocode}
-% By default, the fontloader requires a number of \emphasis{private
-% attributes} for internal use.
-% These must be kept consistent with the attribute handling methods as
-% provided by \identifier{luatexbase}.
-% Our strategy is to override the function that allocates new attributes
-% before we initialize the font loader, making it a wrapper around
-% \luafunction{luatexbase.new_attribute}.\footnote{%
-% Many thanks, again, to Hans Hagen for making this part
-% configurable!
-% }
-% The attribute identifiers are prefixed “\fileent{luaotfload@}” to
-% avoid name clashes.
-%
-% \begin{macrocode}
-
-do
- local new_attribute = luatexbase.new_attribute
- local the_attributes = luatexbase.attributes
-
- attributes = attributes or { }
-
- attributes.private = function (name)
- local attr = "luaotfload@" .. name --- used to be: “otfl@”
- local number = the_attributes[attr]
- if not number then
- number = new_attribute(attr)
- end
- return number
- end
-end
-
-% \end{macrocode}
-% These next lines replicate the behavior of \fileent{luatex-fonts.lua}.
-%
-% \begin{macrocode}
-
-local context_environment = { }
-
-local push_namespaces = function ()
- log("push namespace for font loader")
- local normalglobal = { }
- for k, v in next, _G do
- normalglobal[k] = v
- end
- return normalglobal
-end
-
-local pop_namespaces = function (normalglobal, isolate)
- if normalglobal then
- local _G = _G
- local mode = "non-destructive"
- if isolate then mode = "destructive" end
- log("pop namespace from font loader -- " .. mode)
- for k, v in next, _G do
- if not normalglobal[k] then
- context_environment[k] = v
- if isolate then
- _G[k] = nil
- end
- end
- end
- for k, v in next, normalglobal do
- _G[k] = v
- end
- -- just to be sure:
- setmetatable(context_environment,_G)
- else
- log("irrecoverable error during pop_namespace: no globals to restore")
- os.exit()
- end
-end
-
-luaotfload.context_environment = context_environment
-luaotfload.push_namespaces = push_namespaces
-luaotfload.pop_namespaces = pop_namespaces
-
-local our_environment = push_namespaces()
-
-% \end{macrocode}
-% The font loader requires that the attribute with index zero be zero.
-% We happily oblige.
-% (Cf. \fileent{luatex-fonts-nod.lua}.)
-%
-% \begin{macrocode}
-
-tex.attribute[0] = 0
-
-% \end{macrocode}
-% Now that things are sorted out we can finally load the fontloader.
-%
-% \begin{macrocode}
-
-loadmodule"fontloader.lua"
----loadmodule"font-odv.lua" --- <= Devanagari support from Context
-
-if fonts then
-
- if not fonts._merge_loaded_message_done_ 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-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."]]
- end
- fonts._merge_loaded_message_done_ = true
-
-else--- the loading sequence is known to change, so this might have to
- --- be updated with future updates!
- --- do not modify it though unless there is a change to the merged
- --- package!
- loadmodule("l-lua.lua")
- loadmodule("l-lpeg.lua")
- loadmodule("l-function.lua")
- loadmodule("l-string.lua")
- loadmodule("l-table.lua")
- loadmodule("l-io.lua")
- loadmodule("l-file.lua")
- loadmodule("l-boolean.lua")
- loadmodule("l-math.lua")
- loadmodule("util-str.lua")
- loadmodule('luatex-basics-gen.lua')
- loadmodule('data-con.lua')
- loadmodule('luatex-basics-nod.lua')
- loadmodule('font-ini.lua')
- loadmodule('font-con.lua')
- loadmodule('luatex-fonts-enc.lua')
- loadmodule('font-cid.lua')
- loadmodule('font-map.lua')
- loadmodule('luatex-fonts-syn.lua')
- loadmodule('luatex-fonts-tfm.lua')
- loadmodule('font-oti.lua')
- loadmodule('font-otf.lua')
- loadmodule('font-otb.lua')
- loadmodule('luatex-fonts-inj.lua') --> since 2014-01-07, replaces node-inj.lua
- loadmodule('font-ota.lua')
- loadmodule('luatex-fonts-otn.lua') --> since 2014-01-07, replaces font-otn.lua
- loadmodule('font-otp.lua') --> since 2013-04-23
- loadmodule('luatex-fonts-lua.lua')
- loadmodule('font-def.lua')
- loadmodule('luatex-fonts-def.lua')
- loadmodule('luatex-fonts-ext.lua')
- loadmodule('luatex-fonts-cbk.lua')
-end --- non-merge fallback scope
-
-% \end{macrocode}
-% Here we adjust the globals created during font loader initialization.
-% If the second argument to \luafunction{pop_namespaces()} is \verb|true|
-% this will restore the state of \luafunction{_G}, eliminating every
-% global generated since the last call to \luafunction{push_namespaces()}.
-% At the moment we see no reason to do this, and since the font loader is
-% considered an essential part of \identifier{luatex} as well as a very
-% well organized piece of code, we happily concede it the right to add to
-% \luafunction{_G} if needed.
-%
-% \begin{macrocode}
-
-pop_namespaces(our_environment, false)-- true)
-
-log("fontloader loaded in %0.3f seconds", os.gettimeofday()-starttime)
-
-% \end{macrocode}
-% \subsection{Callbacks}
-% After the fontloader is ready we can restore the callback trap from
-% \identifier{luatexbase}.
-%
-% \begin{macrocode}
-
-callback.register = trapped_register
-
-% \end{macrocode}
-% We do our own callback handling with the means provided by luatexbase.
-% Note: \luafunction{pre_linebreak_filter} and \luafunction{hpack_filter}
-% are coupled in \CONTEXT in the concept of \emphasis{node processor}.
-%
-% \begin{macrocode}
-
-add_to_callback("pre_linebreak_filter",
- nodes.simple_font_handler,
- "luaotfload.node_processor",
- 1)
-add_to_callback("hpack_filter",
- nodes.simple_font_handler,
- "luaotfload.node_processor",
- 1)
-add_to_callback("find_vf_file",
- find_vf_file, "luaotfload.find_vf_file")
-
-loadmodule"override.lua" --- “luat-ovr”
-
-logs.set_loglevel(config.luaotfload.loglevel)
-
-% \end{macrocode}
-% Now we load the modules written for \identifier{luaotfload}.
-%
-% \begin{macrocode}
-loadmodule"parsers.lua" --- new in 2.5; fonts.conf and syntax
-loadmodule"loaders.lua" --- “font-pfb” new in 2.0, added 2011
-loadmodule"database.lua" --- “font-nms”
-loadmodule"colors.lua" --- “font-clr”
-
-% \end{macrocode}
-% Relying on the \verb|name:| resolver for everything has been the source
-% of permanent trouble with the database.
-% With the introduction of the new syntax parser we now have enough
-% granularity to distinguish between the \XETEX emulation layer and the
-% genuine \verb|name:| and \verb|file:| lookups of \LUATEX-Fonts.
-% Another benefit is that we can now easily plug in or replace new lookup
-% behaviors if necessary.
-% The name resolver remains untouched, but it calls
-% \luafunction{fonts.names.resolve()} internally anyways (see
-% \fileent{luaotfload-database.lua}).
-%
-% \begin{macrocode}
-
-local filesuffix = file.suffix
-local fileremovesuffix = file.removesuffix
-local request_resolvers = fonts.definers.resolvers
-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
-% \identifier{kpathsea} alone, because it searches only the
-% \fileent{texmf} directories by default.
-% Although it is possible for \identifier{kpathsea} to include extra
-% paths by adding them to the \verb|OSFONTDIR| environment variable,
-% this is still short of the goal »\emphasis{it just works!}«.
-% When building the font database \identifier{luaotfload} scans
-% system font directories anyways, so we already have all the
-% information for looking sytem fonts.
-% 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,
-% and when verifying the existence of a file in the \fileent{texmf} tree.
-%
-% \begin{macrocode}
-
-local resolve_file = names.crude_file_lookup
---local resolve_file = names.crude_file_lookup_verbose
-local resolve_name = names.resolve_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)
- else
- specification.name = name
- 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{%
-% \url{https://github.com/phi-gamma/luaotfload/issues/4#issuecomment-17090553}.
-% }
-% they are the \XETEX equivalent of a \verb|name:| request, so we will be
-% treating them as such.
-%
-% \begin{macrocode}
-
---request_resolvers.anon = request_resolvers.name
-
-% \end{macrocode}
-% There is one drawback, though.
-% This syntax is also used for requesting fonts in \identifier{Type1}
-% (\abbrev{tfm}, \abbrev{ofm}) format.
-% These are essentially \verb|file:| lookups and must be caught before
-% the \verb|name:| resolver kicks in, lest they cause the database to
-% update.
-% Even if we were to require the \verb|file:| prefix for all
-% \identifier{Type1} requests, tests have shown that certain fonts still
-% include further fonts (e.~g. \fileent{omlgcb.ofm} will ask for
-% \fileent{omsecob.tfm}) \emphasis{using the old syntax}.
-% For this reason, we introduce an extra check with an early return.
-%
-% \begin{macrocode}
-
-local type1_formats = { "tfm", "ofm", }
-
-request_resolvers.anon = function (specification)
- local name = specification.name
- for i=1, #type1_formats do
- local format = type1_formats[i]
- if resolvers.findfile(name, format) then
- specification.forcedname = file.addsuffix(name, format)
- specification.forced = format
- return
- end
- end
- --- under some weird circumstances absolute paths get
- --- passed to the definer; we have to catch them
- --- before the name: resolver misinterprets them.
- name = specification.specification
- local exists, _ = lfsisfile(name)
- if exists then --- garbage; we do this because we are nice,
- --- not because it is correct
- logs.names_report("log", 1, "load", "file %q exists", name)
- logs.names_report("log", 1, "load",
- "... overriding borked anon: lookup with path: lookup")
- specification.name = name
- request_resolvers.path(specification)
- return
- end
- request_resolvers.name(specification)
-end
-
-% \end{macrocode}
-% Prior to version 2.2, \identifier{luaotfload} did not distinguish
-% \verb|file:| and \verb|path:| lookups, causing complications with the
-% resolver.
-% Now we test if the requested name is an absolute path in the file
-% system, otherwise we fall back to the \verb|file:| lookup.
-%
-% \begin{macrocode}
-
-request_resolvers.path = function (specification)
- local name = specification.name
- local exists, _ = lfsisfile(name)
- if not exists then -- resort to file: lookup
- logs.names_report("log", 1, "load",
- "path lookup of %q unsuccessful, falling back to file:",
- name)
- file_resolver (specification)
- else
- local suffix = filesuffix (name)
- if formats[suffix] then
- specification.forced = suffix
- specification.name = file.removesuffix(name)
- specification.forcedname = name
- else
- specification.name = name
- end
- 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 = filesuffix(name)
- if suffix and formats[suffix] then
- name = file.removesuffix(name)
- if resolvers.findfile(name, suffix) then
- specification.forced = suffix
- specification.forcedname = 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}
-% 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.
-%
-% \begin{macrocode}
-create_callback("luaotfload.resolve_font", "simple", dummy_function)
-
-request_resolvers.my = function (specification)
- call_callback("luaotfload.resolve_font", specification)
-end
-
-% \end{macrocode}
-% We create a callback for patching fonts on the fly, to be used by other
-% packages.
-% It initially contains the empty function that we are going to override
-% below.
-%
-% \begin{macrocode}
-
-create_callback("luaotfload.patch_font", "simple", dummy_function)
-
-% \end{macrocode}
-% \subsection{\CONTEXT override}
-% \label{define-font}
-% We provide a simplified version of the original font definition
-% callback.
-%
-% \begin{macrocode}
-
-local read_font_file = fonts.definers.read
-
---- spec -> size -> id -> tmfdata
-local patch_defined_font = function (specification, size, id)
- local tfmdata = read_font_file(specification, size, id)
- if type(tfmdata) == "table" and tfmdata.shared then
- --- We need to test for the “shared” field here
- --- or else the fontspec capheight callback will
- --- operate on tfm fonts.
- call_callback("luaotfload.patch_font", tfmdata, specification)
- end
- return tfmdata
-end
-
-reset_callback "define_font"
-
-% \end{macrocode}
-% Finally we register the callbacks.
-%
-% \begin{macrocode}
-
-local font_definer = config.luaotfload.definer
-
-if font_definer == "generic" then
- add_to_callback("define_font",
- fonts.definers.read,
- "luaotfload.define_font",
- 1)
-elseif font_definer == "patch" then
- add_to_callback("define_font",
- patch_defined_font,
- "luaotfload.define_font",
- 1)
-end
-
-loadmodule"features.lua" --- contains what was “font-ltx” and “font-otc”
-loadmodule"letterspace.lua" --- extra character kerning
-loadmodule"auxiliary.lua" --- additionaly high-level functionality (new)
-
-luaotfload.aux.start_rewrite_fontname () --- to be migrated to fontspec
-
--- vim:tw=71:sw=4:ts=4:expandtab
-
-% \end{macrocode}
-%
-% \iffalse
-%</lua>
-% \fi
+% As of version 2.5, the file \fileent{luaotfload.lua} is no longer
+% generated from the \abbrev{dtx}.
+% Instead, it is maintained separately as a plain \identifier{Lua} file
+% \fileent{luaotfload-main.lua} in the Luaotfload \identifier{git} tree.
+% The file documentation which used to be found in this section has
+% been preserved in the comments.
%
% \section{\fileent{luaotfload.sty}}
%
@@ -2234,10 +1573,10 @@ luaotfload.aux.start_rewrite_fontname () --- to be migrated to fontspec
\else
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{luaotfload}%
- [2014/**/** v2.5 OpenType layout system]
+ [2014/42/42 v2.5 OpenType layout system]
\RequirePackage{luatexbase}
\fi
-\RequireLuaModule{luaotfload}
+\RequireLuaModule{luaotfload-main}
\endinput
% \end{macrocode}
% \iffalse
diff --git a/mkstatus b/mkstatus
index 9940970..28b80ff 100755
--- a/mkstatus
+++ b/mkstatus
@@ -50,9 +50,10 @@ local names = {
"luaotfload-glyphlist.lua",
"luaotfload-letterspace.lua",
"luaotfload-loaders.lua",
- "luaotfload.lua",
+ "luaotfload-main.lua",
"luaotfload-fontloader.lua",
"luaotfload-override.lua",
+ "luaotfload-parsers.lua",
"luaotfload-tool.lua",
"mkcharacters",
"mkglyphlist",