summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfontdbutil.lua (renamed from mkluatexfontdb.lua)14
-rw-r--r--luaotfload-basics-gen.lua (renamed from otfl-basics-gen.lua)0
-rw-r--r--luaotfload-basics-nod.lua (renamed from otfl-basics-nod.lua)0
-rw-r--r--luaotfload-blacklist.cnf (renamed from otfl-blacklist.cnf)0
-rw-r--r--luaotfload-features.lua (renamed from otfl-features.lua)0
-rw-r--r--luaotfload-font-clr.lua (renamed from otfl-font-clr.lua)0
-rw-r--r--luaotfload-font-ltx.lua (renamed from otfl-font-ltx.lua)0
-rw-r--r--luaotfload-font-nms.lua (renamed from otfl-font-nms.lua)4
-rw-r--r--luaotfload-font-otc.lua (renamed from otfl-font-otc.lua)0
-rw-r--r--luaotfload-font-pfb.lua (renamed from otfl-font-pfb.lua)0
-rw-r--r--luaotfload-fonts-cbk.lua (renamed from otfl-fonts-cbk.lua)0
-rw-r--r--luaotfload-fonts-def.lua (renamed from otfl-fonts-def.lua)0
-rw-r--r--luaotfload-fonts-enc.lua (renamed from otfl-fonts-enc.lua)0
-rw-r--r--luaotfload-fonts-ext.lua (renamed from otfl-fonts-ext.lua)0
-rw-r--r--luaotfload-fonts-lua.lua (renamed from otfl-fonts-lua.lua)0
-rw-r--r--luaotfload-fonts-tfm.lua (renamed from otfl-fonts-tfm.lua)0
-rw-r--r--luaotfload-fonts.lua (renamed from otfl-fonts.lua)0
-rw-r--r--luaotfload-lib-dir.lua (renamed from otfl-lib-dir.lua)0
-rw-r--r--luaotfload-luat-ovr.lua (renamed from otfl-luat-ovr.lua)3
-rw-r--r--luaotfload-merged.lua (renamed from otfl-fonts-merged.lua)0
-rw-r--r--luaotfload.dtx205
-rw-r--r--luaotfload.lua457
22 files changed, 122 insertions, 561 deletions
diff --git a/mkluatexfontdb.lua b/fontdbutil.lua
index 96dcf60..464cc62 100755
--- a/mkluatexfontdb.lua
+++ b/fontdbutil.lua
@@ -9,10 +9,10 @@ luaotfload bundle, please see the luaotfload documentation for more info.
kpse.set_program_name"luatex"
-local stringformat = string.format
-local texiowrite_nl = texio.write_nl
-local stringfind = string.find
-local stringlower = string.lower
+local stringformat = string.format
+local texiowrite_nl = texio.write_nl
+local stringfind = string.find
+local stringlower = string.lower
-- First we need to be able to load module (code copied from
-- luatexbase-loader.sty):
@@ -73,9 +73,9 @@ config.lualibs.prefer_merged = true
config.lualibs.load_extended = false
require"lualibs"
-require"otfl-basics-gen.lua"
-require"otfl-luat-ovr.lua" --- this populates the logs.* namespace
-require"otfl-font-nms"
+require"luaotfload-basics-gen.lua"
+require"luaotfload-luat-ovr.lua" --- this populates the logs.* namespace
+require"luaotfload-font-nms"
require"alt_getopt"
local version = "2.2" -- same version number as luaotfload
diff --git a/otfl-basics-gen.lua b/luaotfload-basics-gen.lua
index 727086e..727086e 100644
--- a/otfl-basics-gen.lua
+++ b/luaotfload-basics-gen.lua
diff --git a/otfl-basics-nod.lua b/luaotfload-basics-nod.lua
index 151d98a..151d98a 100644
--- a/otfl-basics-nod.lua
+++ b/luaotfload-basics-nod.lua
diff --git a/otfl-blacklist.cnf b/luaotfload-blacklist.cnf
index 771649b..771649b 100644
--- a/otfl-blacklist.cnf
+++ b/luaotfload-blacklist.cnf
diff --git a/otfl-features.lua b/luaotfload-features.lua
index aae0515..aae0515 100644
--- a/otfl-features.lua
+++ b/luaotfload-features.lua
diff --git a/otfl-font-clr.lua b/luaotfload-font-clr.lua
index 439fd7c..439fd7c 100644
--- a/otfl-font-clr.lua
+++ b/luaotfload-font-clr.lua
diff --git a/otfl-font-ltx.lua b/luaotfload-font-ltx.lua
index afc8621..afc8621 100644
--- a/otfl-font-ltx.lua
+++ b/luaotfload-font-ltx.lua
diff --git a/otfl-font-nms.lua b/luaotfload-font-nms.lua
index 35611a6..67619be 100644
--- a/otfl-font-nms.lua
+++ b/luaotfload-font-nms.lua
@@ -66,7 +66,7 @@ local names = fonts.names
names.version = 2.2
names.data = nil
names.path = {
- basename = "otfl-names.lua",
+ basename = "luaotfload-names.lua",
dir = "",
path = "",
}
@@ -704,7 +704,7 @@ names.blacklist = { }
local function read_blacklist()
local files = {
- kpselookup("otfl-blacklist.cnf", {all=true, format="tex"})
+ kpselookup("luaotfload-blacklist.cnf", {all=true, format="tex"})
}
local blacklist = names.blacklist
local whitelist = { }
diff --git a/otfl-font-otc.lua b/luaotfload-font-otc.lua
index a87dcad..a87dcad 100644
--- a/otfl-font-otc.lua
+++ b/luaotfload-font-otc.lua
diff --git a/otfl-font-pfb.lua b/luaotfload-font-pfb.lua
index 8ab6b29..8ab6b29 100644
--- a/otfl-font-pfb.lua
+++ b/luaotfload-font-pfb.lua
diff --git a/otfl-fonts-cbk.lua b/luaotfload-fonts-cbk.lua
index 9db94f6..9db94f6 100644
--- a/otfl-fonts-cbk.lua
+++ b/luaotfload-fonts-cbk.lua
diff --git a/otfl-fonts-def.lua b/luaotfload-fonts-def.lua
index 0c2f0db..0c2f0db 100644
--- a/otfl-fonts-def.lua
+++ b/luaotfload-fonts-def.lua
diff --git a/otfl-fonts-enc.lua b/luaotfload-fonts-enc.lua
index e20c3a0..e20c3a0 100644
--- a/otfl-fonts-enc.lua
+++ b/luaotfload-fonts-enc.lua
diff --git a/otfl-fonts-ext.lua b/luaotfload-fonts-ext.lua
index b60d045..b60d045 100644
--- a/otfl-fonts-ext.lua
+++ b/luaotfload-fonts-ext.lua
diff --git a/otfl-fonts-lua.lua b/luaotfload-fonts-lua.lua
index ec3fe38..ec3fe38 100644
--- a/otfl-fonts-lua.lua
+++ b/luaotfload-fonts-lua.lua
diff --git a/otfl-fonts-tfm.lua b/luaotfload-fonts-tfm.lua
index b9bb1bd..b9bb1bd 100644
--- a/otfl-fonts-tfm.lua
+++ b/luaotfload-fonts-tfm.lua
diff --git a/otfl-fonts.lua b/luaotfload-fonts.lua
index 96f3501..96f3501 100644
--- a/otfl-fonts.lua
+++ b/luaotfload-fonts.lua
diff --git a/otfl-lib-dir.lua b/luaotfload-lib-dir.lua
index 00cda38..00cda38 100644
--- a/otfl-lib-dir.lua
+++ b/luaotfload-lib-dir.lua
diff --git a/otfl-luat-ovr.lua b/luaotfload-luat-ovr.lua
index bd04eeb..94f2376 100644
--- a/otfl-luat-ovr.lua
+++ b/luaotfload-luat-ovr.lua
@@ -35,7 +35,8 @@ local set_loglevel = function (n)
loglevel = n
end
end
-logs.set_loglevel = set_loglevel
+logs.set_loglevel = set_loglevel
+logs.set_log_level = set_loglevel --- accomodating lazy typists
local set_logout = function (s)
if s == "stdout" then
diff --git a/otfl-fonts-merged.lua b/luaotfload-merged.lua
index 314305a..314305a 100644
--- a/otfl-fonts-merged.lua
+++ b/luaotfload-merged.lua
diff --git a/luaotfload.dtx b/luaotfload.dtx
index 3685083..0025e2f 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -315,7 +315,7 @@ and the derived files
% The next example shows how to load the \emphasis{Porson} font digitized by
% the Greek Font Society using \XETEX-style syntax and an absolute path from a
% non-standard directory:
-%
+%
% \begin{quote}
% \begin{verbatim}
% \font\gfsporson="[/tmp/GFSPorson.otf]" at 12pt
@@ -486,7 +486,7 @@ and the derived files
% Their arguments are names of \LUA tables that contain
% values for the respective features.\footnote{%
% For examples of the table layout please refer to the
-% section of the file \fileent{otfl-fonts-ext.lua} where the
+% section of the file \fileent{luaotfload-fonts-ext.lua} where the
% default values are defined.
% Alternatively and with loss of information, you can dump
% those tables into your terminal by issuing
@@ -701,7 +701,7 @@ and the derived files
% approximate matching.
% Suppose you cannot precisely remember if the variant of
% \identifier{Iwona} you are looking for was “Bright” or “Light”.
-% The query
+% The query
%
% \begin{quote}
% \begin{verbatim}
@@ -724,7 +724,7 @@ and the derived files
% \LUATEX reference manual.\footnote{%
% In \TEX Live: \fileent{texmf-dist/doc/luatex/base/luatexref-t.pdf}.
% }
-%
+%
% \verb|fontdbutil --help| will list the available command line
% switches, including some not discussed in detail here.
%
@@ -737,7 +737,7 @@ and the derived files
% running \verb|fontdbutil -v| to increase verbosity.
% Take a note of the \emphasis{filename} of the font that database
% creation fails with and append it to the file
-% \fileent{otfl-blacklist.cnf}.
+% \fileent{luaotfload-blacklist.cnf}.
%
% A blacklist file is a list of font filenames, one per line.
% Specifying the full path to where the file is located is optional, the
@@ -754,8 +754,8 @@ and the derived files
% }
% or just leave it in the working directory of your document.
% \identifier{luaotfload} reads all files named
-% \fileent{otfl-blacklist.cnf} it finds, so the fonts in
-% \fileent{./otfl-blacklist.cnf} extend the global blacklist.
+% \fileent{luaotfload-blacklist.cnf} it finds, so the fonts in
+% \fileent{./luaotfload-blacklist.cnf} extend the global blacklist.
%
% Furthermore, a filename prepended with a dash character (|-|) is
% removed from the blacklist, causing it to be temporarily whitelisted
@@ -814,10 +814,10 @@ and the derived files
% \def\incitem#1{%
% \normalitem{\fileent{#1}}
% }
-% \fileitem{luatex-fonts.lua}{otfl-fonts.lua}
+% \fileitem{luatex-fonts.lua}{luaotfload-fonts.lua}
% The wrapper that loads the font loader code.
%
-% \fileitem{luatex-fonts-merged.lua}{otfl-fonts-merged.lua}
+% \fileitem{luatex-fonts-merged.lua}{luaotfload-fonts-merged.lua}
% The font loader package.
% It is generated by \fileent{mtx-package}, a \LUA
% source code merging tool developed by Hans
@@ -890,10 +890,10 @@ and the derived files
% instead.
% Their names remain the same as in \CONTEXT (without the
% \verb|otfl|-prefix) since they are hard-coded in
-% \fileent{otfl-fonts.lua}.
+% \fileent{luaotfload-fonts.lua}.
% Thus if you prefer running bleeding edge code from the
% \CONTEXT beta, all you have to do is remove
-% \fileent{otfl-fonts-merged.lua} from the search path.
+% \fileent{luaotfload-fonts-merged.lua} from the search path.
%
% \end{itemize}
%
@@ -908,20 +908,20 @@ and the derived files
% \normalitem{\fileent{#1}}%
% \space--\hskip1em
% }
-% \ouritem {otfl-font-otc.lua} \fileent{font-otc} from \CONTEXT;
+% \ouritem {luaotfload-font-otc.lua} \fileent{font-otc} from \CONTEXT;
% font feature handling.
-% \ouritem {otfl-lib-dir.lua} \fileent{l-dir} from \CONTEXT;
+% \ouritem {luaotfload-lib-dir.lua} \fileent{l-dir} from \CONTEXT;
% contains functionality required
-% by \fileent{otfl-font-nms.lua}.
-% \ouritem {otfl-luat-ovr.lua} overrides the \CONTEXT logging
+% by \fileent{luaotfload-font-nms.lua}.
+% \ouritem {luaotfload-luat-ovr.lua} overrides the \CONTEXT logging
% functionality.
-% \ouritem {otfl-font-pfb.lua} registers the \OpenType
+% \ouritem {luaotfload-font-pfb.lua} registers the \OpenType
% font reader as handler for
% Postscript fonts.
-% \ouritem {otfl-font-nms.lua} font database.
-% \ouritem {otfl-font-clr.lua} color handling.
-% \ouritem {otfl-font-ltx.lua} font feature handling.
-% \ouritem {otfl-features.lua} definitions of the \verb|anum| and
+% \ouritem {luaotfload-font-nms.lua} font database.
+% \ouritem {luaotfload-font-clr.lua} color handling.
+% \ouritem {luaotfload-font-ltx.lua} font feature handling.
+% \ouritem {luaotfload-features.lua} definitions of the \verb|anum| and
% \verb|tlig| features.
% \end{itemize}
%
@@ -991,6 +991,7 @@ and the derived files
% \fi
% \begin{macrocode}
luaotfload = luaotfload or {}
+local luaotfload = luaotfload
luaotfload.module = {
name = "luaotfload",
@@ -1008,6 +1009,7 @@ local type, next = type, next
local stringfind = string.find
local stringsub = string.sub
local stringmatch = string.match
+local stringformat = string.format
local find_file = kpse.find_file
local add_to_callback, create_callback =
@@ -1019,6 +1021,7 @@ local dummy_function = function () end
% \end{macrocode}
%
+%
% No final decision has been made on how to handle font definition. At
% the moment, there are three candidates: The \identifier{generic}
% callback as hard-coded in the font loader, the \identifier{old}
@@ -1026,6 +1029,7 @@ local dummy_function = function () end
% that does nothing besides applying font patches.
%
% \begin{macrocode}
+
luaotfload.font_definer = "patch" --- | “generic” | “old”
local error, warning, info, log =
@@ -1033,6 +1037,7 @@ local error, warning, info, log =
% \end{macrocode}
%
+%
% This is a necessary initalization in order not to rebuild an existing
% font.
% Maybe 600 should be replaced by \texmacro{pdfpkresolution} %% (why?)
@@ -1048,6 +1053,7 @@ kpse.init_prog("", 600, "/")
% \end{macrocode}
%
+%
% We set the minimum version requirement for \LUATEX to v0.74, as it was
% the first version to include version 5.2 of the \LUA interpreter.
%
@@ -1063,15 +1069,16 @@ end
% \end{macrocode}
%
+%
% \subsection{Module loading}
%
% We load the files imported from \CONTEXT with this function.
-% It automatically prepends the prefix \fileent{otfl-} to its argument,
-% so we can refer to the files with their actual \CONTEXT name.
+% 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 = "otfl" -- “luatex” for luatex-plain
+local fl_prefix = "luaotfload" -- “luatex” for luatex-plain
local loadmodule = function (name)
require(fl_prefix .."-"..name)
end
@@ -1104,51 +1111,14 @@ local find_vf_file = function (name)
return fullname
end
---[[-- keep --]]
---- from Hans (all merged):
-
---- file name modified include name
---- × basics-gen.lua t luat-basics-gen
---- × font-def -> fonts-def t luatex-font-def (there’s also the normal font-def!)
---- × fonts-enc f luatex-font-enc
---- × fonts-ext t luatex-fonts-ext
---- × fonts-lua f luatex-fonts-lua
---- fonts-tfm f luatex-fonts-tfm
---- × fonts-cbk f luatex-fonts-lua
-
---- from Hans (unmerged):
---- font-otc.lua -> otfl-font-otc.lua
-
---- from luaotfload:
---- otfl-luat-ovr.lua -- override some luat-dum functions
---- otfl-font-clr.lua
---- otfl-font-ltx.lua
---- otfl-font-nms.lua
---- otfl-font-pfb.lua -- ?
-
---[[-- new --]]
---- basics-nod (merged as fonts-nod !)
---- fonts-demo-vf-1.lua
---- fonts-syn (merged)
-
---[[-- merged, to be dropped --]]
---- otfl-data-con.lua
---- otfl-font-cid.lua
---- otfl-font-con.lua
---- otfl-font-ini.lua
---- otfl-font-ota.lua
---- otfl-font-otb.lua
---- otfl-font-otf.lua
---- otfl-font-oti.lua
---- otfl-font-otn.lua
-
% \end{macrocode}
%
%
+%
% \subsection{Preparing the Font Loader}
% We treat the fontloader as a black box so behavior is consistent
% between formats.
-% The wrapper file is \fileent{otfl-fonts.lua} which we imported from
+% The wrapper file is \fileent{luaotfload-fonts.lua} which we imported from
% \href{http://standalone.contextgarden.net/current/context/experimental/tex/generic/context/luatex/}{\LUATEX-Plain}.
% It has roughly two purposes:
%
@@ -1163,7 +1133,7 @@ end
% How the first step is executed depends on the presence on the
% \emphasis{merged font loader code}.
% In \identifier{luaotfload} this is contained in the file
-% \fileent{otfl-fonts-merged.lua}.
+% \fileent{luaotfload-fonts-merged.lua}.
% If this file cannot be found, the original libraries from \CONTEXT of
% which the merged code was composed are loaded instead.
%
@@ -1187,16 +1157,63 @@ end
% \identifier{luatexbase}-style callback handling here.
%
% \begin{macrocode}
-generic_context = {no_callbacks_yet = true}
-non_generic_context = { luatex_fonts = {
- load_before = "otfl-fonts-merged.lua",
- -- load_after = nil, --- TODO, this is meant for callbacks
+
+--- these are obsolescent due to our plan of removing luaotfload-fonts.lua
+generic_context = generic_context or { }
+non_generic_context = non_generic_context or { }
+
+generic_context.no_callbacks_yet = true
+
+non_generic_context.luatex_fonts = {
+ --- TODO we’ll kill luaotfload-fonts.lua soon, so
+ --- this is gonna vanish, and the file will become
+ --- luaotfload-merged.lua
+ load_before = "luaotfload-fonts-merged.lua",
skip_loading = true,
-}}
+}
+
+% \end{macrocode}
+%
+%
+% In its raw form, the font loader will write to the terminal quite
+% liberally, not using the proper channels (loggers) even of \CONTEXT.
+% To make it behave we temporarily replace two functions from the
+% \luafunction{texio} library with wrappers that redirect output to the
+% log.
+% Just in case Hans decides to call \luafunction{texio.write*} with the
+% optional target parameter (which he doesn’t at the moment), we catch the
+% first argument and skip it where appropriate.
+% The originals are backed up and restored after loading
+% \fileent{luaotfload-fonts.lua}.
+%
+% Should we decide to do our own packaging (we’re capable of that
+% anyways), this will most likely become unnecessary.
+%
+% \begin{macrocode}
+
+local normal_write, normal_write_nl = texio.write, texio.write_nl
+
+local log_template = "luaotfload: %s"
+local fake_write = function (first, rest)
+ if first == "log" or first == "term" then -- ignore
+ normal_write("log", stringformat(log_template, rest))
+ else
+ normal_write("log", stringformat(log_template, first))
+ end
+end
+local fake_write_nl = function (first, rest)
+ if first == "log" or first == "term" then -- ignore
+ normal_write_nl("log", stringformat(log_template, rest))
+ else
+ normal_write_nl("log", stringformat(log_template, first, rest))
+ end
+end
+texio.write, texio.write_nl = fake_write, fake_write_nl
% \end{macrocode}
%
+%
% 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
@@ -1209,31 +1226,24 @@ callback.register = dummy_function
% \end{macrocode}
%
-% In order to have an output with normal verbosity, we need to pre-override
-% some \CONTEXT log function:
+%
+% Now that things are sorted out we can finally load the fontloader.
%
% \begin{macrocode}
-local dummylogfunction=function() end
-local dummylogreporter=function(c) return function(...) log(string.formatters(...)) end end
-
-logs={
- new=dummylogreporter,
- reporter=dummylogreporter,
- messenger=dummylogreporter,
- report=dummylogfunction,
-}
+loadmodule"fonts.lua"
% \end{macrocode}
%
-% Now that things are sorted out we can finally load the fontloader.
+%
+% Here we restore the original \luafunction{texio} functions.
%
% \begin{macrocode}
-
-loadmodule"fonts.lua"
+texio.write, texio.write_nl = normal_write, normal_write_nl
% \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
@@ -1241,22 +1251,22 @@ loadmodule"fonts.lua"
% 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!
+% Many thanks, again, to Hans Hagen for making this part
+% configurable!
% }
-% The attribute identifiers are prefixed “\fileent{otfl@}” to
+% 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
+ local new_attribute = luatexbase.new_attribute
+ local the_attributes = luatexbase.attributes
attributes = attributes or { }
attributes.private = function (name)
- local attr = "otfl@" .. name
+ local attr = "luaotfload@" .. name --- used to be: “otfl@”
local number = the_attributes[attr]
if not number then
number = new_attribute(attr)
@@ -1268,6 +1278,7 @@ end
% \end{macrocode}
%
%
+%
% \subsection{Callbacks}
%
% After the fontloader is ready we can restore the callback trap from
@@ -1279,6 +1290,7 @@ 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}
@@ -1297,7 +1309,7 @@ add_to_callback("hpack_filter",
add_to_callback("find_vf_file",
find_vf_file, "luaotfload.find_vf_file")
-loadmodule"font-otc.lua" -- TODO check what we can drop from otfl-features
+loadmodule"font-otc.lua" -- TODO check what we can drop from luaotfload-features
loadmodule"lib-dir.lua" -- required by font-nms
loadmodule"luat-ovr.lua"
@@ -1317,6 +1329,7 @@ loadmodule"luat-ovr.lua"
% \end{macrocode}
%
%
+%
% Now we load the modules written for \identifier{luaotfload}.
%
% \begin{macrocode}
@@ -1328,15 +1341,15 @@ loadmodule"font-ltx.lua" --- new in 2.0, added 2011
% \end{macrocode}
%
%
-% This hack makes fonts called with file method found by fonts.names.resove
+% This hack makes fonts called with file method found by fonts.names.resolve
% instead of just trying to find them with kpse. It is necessary in case
-% of fonts that are not accessible by kpse but present in the database, a
+% of fonts that are not accessible by kpse but present in the database, a
% quite common case under Linux.
%
% \begin{macrocode}
-fonts.definers.resolvers.file = function (specification)
- specification.name = fonts.names.resolve('', '', specification)
+fonts.definers.resolvers.file = function (specification)
+ specification.name = fonts.names.resolve('', '', specification)
end
% \end{macrocode}
@@ -1354,6 +1367,7 @@ create_callback("luaotfload.patch_font", "simple", dummy_function)
% \end{macrocode}
%
%
+%
% This is a wrapper for the imported font loader.
% As of 2013, everything it does appear to be redundand, so we won’t use
% it unless somebody points out a cogent reason.
@@ -1405,6 +1419,7 @@ end
% \end{macrocode}
%
%
+%
% \subsection{\CONTEXT override}
%
% We provide a simplified version of the original font definition
@@ -1418,6 +1433,7 @@ local patch_defined_font = function (...)
if type(tfmdata) == "table" then
call_callback("luaotfload.patch_font", tfmdata)
end
+ -- inspect(table.keys(tfmdata))
return tfmdata
end
@@ -1427,6 +1443,7 @@ reset_callback("define_font")
% \end{macrocode}
%
+%
% Finally we register the callbacks
%
% \begin{macrocode}
@@ -1646,7 +1663,7 @@ loadmodule"features.lua"
%
% \begin{enumerate}
%
-% \item
+% \item
% You must cause the modified files to carry prominent notices stating that
% you changed the files and the date of any change.
%
diff --git a/luaotfload.lua b/luaotfload.lua
deleted file mode 100644
index f11218e..0000000
--- a/luaotfload.lua
+++ /dev/null
@@ -1,457 +0,0 @@
-module("luaotfload", package.seeall)
-
-luaotfload.module = {
- name = "luaotfload",
- version = 2.2,
- date = "2013/04/15",
- description = "OpenType layout system.",
- author = "Elie Roux & Hans Hagen",
- copyright = "Elie Roux",
- license = "CC0"
-}
-
-local luatexbase = luatexbase
-
-local type, next = type, next
-local stringfind = string.find
-local stringsub = string.sub
-local stringmatch = string.match
-local stringformat = string.format
-local find_file = kpse.find_file
-
-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
-
-_G.luaotfload = _G.luaotfload or { }
-local luaotfload = _G.luaotfload
-
---[[doc--
-No final decision has been made on how to handle font definition. At
-the moment, there are three candidates: The \identifier{generic}
-callback as hard-coded in the font loader, the \identifier{old}
-wrapper, and a simplified version of the latter (\identifier{patch})
-that does nothing besides applying font patches.
---doc]]--
-
-luaotfload.font_definer = "patch" --- | “generic” | “old”
-
-local error, warning, info, log =
- luatexbase.provides_module(luaotfload.module)
-
---[[doc--
-This is a necessary initalization in order not to rebuild an existing
-font.
-Maybe 600 should be replaced by \texmacro{pdfpkresolution} %% (why?)
-or \luafunction{texconfig.pk_dpi} (and it should be replaced
-dynamically), but we don't have access (yet) to the
-\identifier{texconfig} table, so we let it be 600.
-Anyway, it does still work fine even if \texmacro{pdfpkresolution} is
-changed.
---doc]]--
-
-kpse.init_prog("", 600, "/")
-
---[[doc--
-We set the minimum version requirement for \LUATEX to v0.74, as it was
-the first version to include version 5.2 of the \LUA interpreter.
---doc]]--
-
-local luatex_version = 74
-
-if tex.luatexversion < luatex_version then
- warning("LuaTeX v%.2f is old, v%.2f is recommended.",
- tex.luatexversion/100,
- luatex_version /100)
-end
-
---[[doc--
-\subsection{Module loading}
-
-We load the files imported from \CONTEXT with this function.
-It automatically prepends the prefix \fileent{otfl-} to its argument,
-so we can refer to the files with their actual \CONTEXT name.
---doc]]--
-
-local fl_prefix = "otfl" -- “luatex” for luatex-plain
-local loadmodule = function (name)
- local tofind = fl_prefix .."-"..name
- local found = find_file(tofind,"tex")
- if found then
- log("loading file %s.", found)
- dofile(found)
- else
- error("file %s not found.", tofind)
- end
-end
-
---[[doc--
-Virtual fonts are resolved via a callback.
-\luafunction{find_vf_file} derives the name of the virtual font file
-from the filename.
-(NB: \CONTEXT handles this likewise in \fileent{font-vf.lua}.)
---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 = find_file(name, "ovf")
- if not fullname then
- --fullname = find_file(file.removesuffix(name), "ovf")
- fullname = find_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.
-The wrapper file is \fileent{otfl-fonts.lua} which we imported from
-\href{http://standalone.contextgarden.net/current/context/experimental/tex/generic/context/luatex/}{\LUATEX-Plain}.
-It has roughly two purposes:
-
-\begin{enumerate}
-
- \item insert the functionality required for fontloader; and
-
- \item put it in place via the respective callbacks.
-
-\end{enumerate}
-
-How the first step is executed depends on the presence on the
-\emphasis{merged font loader code}.
-In \identifier{luaotfload} this is contained in the file
-\fileent{otfl-fonts-merged.lua}.
-If this file cannot be found, the original libraries from \CONTEXT of
-which the merged code was composed are loaded instead.
-
-Hans provides two global tables to control the font loader:
-
- \begin{itemize}
- \item \luafunction{generic_context}:
- encapsulation mechanism, callback functions
- \item \luafunction{non generic_context}:
- customized code insertion
- \end{itemize}
-
-
-With \luafunction{non_generic_context} we can tailor the font loader
-insertion to our file naming habits (key \luafunction{load_before}).
-Additionally, \luafunction{skip_loading} can be unset to force loading
-of the original libraries as though the merged code was absent.
-Another key, \luafunction{load_after} is called at the time when the
-font loader is actually inserted.
-In combination with the option \luafunction{no_callbacks_yet} in
-\luafunction{generic_context}, we can insert our own,
-\identifier{luatexbase}-style callback handling here.
---doc]]--
-if not _G. generic_context then _G. generic_context = { } end
-if not _G.non_generic_context then _G.non_generic_context = { } end
-
-local generic_context = generic_context
-local non_generic_context =non_generic_context
-
-generic_context.no_callbacks_yet = true
-
-_G.non_generic_context = { luatex_fonts = {
- load_before = "otfl-fonts-merged.lua",
- -- load_after = nil, --- TODO, this is meant for callbacks
- skip_loading = true,
-}}
-
---[[doc--
-In its raw form, the font loader will write to the terminal quite
-liberally, not using the proper channels (loggers) even of \CONTEXT.
-To make it behave we temporarily replace two functions from the
-\luafunction{texio} library with wrappers that redirect output to the
-log.
-Just in case Hans decides to call \luafunction{texio.write*} with the
-optional target parameter (which he doesn’t at the moment), we catch the
-first argument and skip it where appropriate.
-The originals are backed up and restored after loading
-\fileent{otfl-fonts.lua}.
-
-Should we decide to do our own packaging (we’re capable of that
-anyways), this will most likely become unnecessary.
---doc]]--
-
-local normal_write, normal_write_nl = texio.write, texio.write_nl
-
-local log_template = "luaotfload: %s"
-local fake_write = function (first, rest)
- if first == "log" or first == "term" then -- ignore
- normal_write("log", stringformat(log_template, rest))
- else
- normal_write("log", stringformat(log_template, first))
- end
-end
-local fake_write_nl = function (first, rest)
- if first == "log" or first == "term" then -- ignore
- normal_write_nl("log", stringformat(log_template, rest))
- else
- normal_write_nl("log", stringformat(log_template, first, rest))
- end
-end
-texio.write, texio.write_nl = fake_write, fake_write_nl
-
---[[doc--
-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.
---doc]]--
-
-local trapped_register = callback.register
-callback.register = dummy_function
-
---[[doc--
-Now that things are sorted out we can finally load the fontloader.
---doc]]--
-
-loadmodule"fonts.lua"
-
---[[doc--
-Here we restore the original \luafunction{texio} functions.
---doc]]--
-texio.write, texio.write_nl = normal_write, normal_write_nl
-
---[[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{otfl@}” to
-avoid name clashes.
---doc]]--
-
-do
- local new_attribute = luatexbase.new_attribute
- local the_attributes = luatexbase.attributes
-
- _G.attributes = _G.attributes or { }
-
- _G.attributes.private = function (name)
- local attr = "otfl@" .. name
- local number = the_attributes[attr]
- if not number then
- number = new_attribute(attr)
- end
- return number
- end
-end
-
---[[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",
- generic_context.callback_pre_linebreak_filter,
- "luaotfload.node_processor",
- 1)
-add_to_callback("hpack_filter",
- generic_context.callback_hpack_filter,
- "luaotfload.node_processor",
- 1)
-add_to_callback("find_vf_file",
- find_vf_file, "luaotfload.find_vf_file")
-
-loadmodule"font-otc.lua" -- TODO check what we can drop from otfl-features
-loadmodule"lib-dir.lua" -- required by font-nms
-loadmodule"luat-ovr.lua"
-
-if fonts and fonts.readers.tfm then
- --------------------------------------------------------------------
- --- OFM; read this first
- --------------------------------------------------------------------
- --- I can’t quite make out whether this is still relevant
- --- as those ofm fonts always fail, even in the 2011 version
- --- (mktexpk: don't know how to create bitmap font for omarabb.ofm)
- --- the font loader appears to read ofm like tfm so if this
- --- hack was supposed achieve that, we should excise it anyways
- fonts.readers.ofm = fonts.readers.tfm
- fonts.handlers.ofm = fonts.handlers.tfm --- empty anyways
- fonts.formats.ofm = fonts.formats.tfm --- “type1”
- --- fonts.readers.sequence[#fonts.readers.sequence+1] = "ofm"
- --------------------------------------------------------------------
-end
-
---[[doc--
-
-Now we load the modules written for \identifier{luaotfload}.
-
---doc]]--
-loadmodule"font-pfb.lua" --- new in 2.0, added 2011
-loadmodule"font-nms.lua"
-loadmodule"font-clr.lua"
-loadmodule"font-ltx.lua" --- new in 2.0, added 2011
-
---[[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--
-
-This is a wrapper for the imported font loader.
-As of 2013, everything it does appear to be redundand, so we won’t use
-it unless somebody points out a cogent reason.
-Nevertheless, it has been adapted to work with the current structure of
-font data objects and will stay here for reference / until breakage is
-reported.
-
-\emphasis{TODO}
-This one also enables patching fonts.
-The current fontloader apparently comes with a dedicated mechanism for
-that already: enhancers.
-How those work remains to be figured out.
-
---doc]]--
-local define_font_wrapper = function (...)
- --- we use “tfmdata” (not “fontdata”) for consistency with the
- --- font loader
- local tfmdata = fonts.definers.read(...)
- if type(tfmdata) == "table" and tfmdata.shared then
- local metadata = tfmdata.shared.rawdata.metadata
- local mathdata = metadata.math --- do all fonts have this field?
- if mathdata then
- local mathconstants = { } --- why new hash, not modify in place?
- local units_per_em = metadata.units_per_em
- local size = tfmdata.size
- for k,v in next, mathdata do
- --- afaics this is alread taken care of by
- --- definers.read
- if stringfind(k, "Percent") then
- -- keep percent values as is
- print(k,v)
- mathconstants[k] = v
- else
- mathconstants[k] = v / units_per_em * size
- end
- end
- --- for \overwithdelims
- --- done by definers.read as well
- mathconstants.FractionDelimiterSize = 1.01 * size
- --- fontloader has 2.4 × size
- mathconstants.FractionDelimiterDisplayStyleSize = 2.39 * size
- tfmdata.MathConstants = mathconstants
- end
- call_callback("luaotfload.patch_font", tfmdata)
- end
- return tfmdata
-end
-
---[[doc--
-
-\subsection{\CONTEXT override}
-
-We provide a simplified version of the original font definition
-callback.
-
---doc]]--
-
-local read_font_file = fonts.definers.read
-local patch_defined_font = function (...)
- local tfmdata = read_font_file(...)-- spec -> size -> id -> tmfdata
- if type(tfmdata) == "table" then
- call_callback("luaotfload.patch_font", tfmdata)
- end
- -- inspect(table.keys(tfmdata))
- return tfmdata
-end
-
-caches.compilemethod = "both"
-
-reset_callback("define_font")
-
---[[doc--
-Finally we register the callbacks
---doc]]--
-
-if luaotfload.font_definer == "old" then
- add_to_callback("define_font",
- define_font_wrapper,
- "luaotfload.define_font",
- 1)
-elseif luaotfload.font_definer == "generic" then
- add_to_callback("define_font",
- generic_context.callback_define_font,
- "luaotfload.define_font",
- 1)
-elseif luaotfload.font_definer == "patch" then
- add_to_callback("define_font",
- patch_defined_font,
- "luaotfload.define_font",
- 1)
-end
-
---[[todo--
---- The manual promises coercion of the file: lookup if
---- the asked name is enclosed in brackets.
---- A couple things make me doubt that this is the case:
----
---- 1) there doesn’t appear to be code for these cases
---- 2) the brackets remain part of the file name
---- 3) we still get calls to names.resolve which
---- ignores the “lookup” field of the spec it gets
----
---- For this reason here is some code that a) coerces
---- file: lookups in these cases and b) strips the brackets
---- from the file name. As we *still* get name: lookups even
---- though this code is active I’ll just leave it here
---- for reference, ineffective as it is.
-do
- local getspecification, makespecification =
- fonts.definers.getspecification, fonts.definers.makespecification
-
- local analyze = function (specification, size)
- local lookup, name, sub, method, detail = getspecification(specification or "")
- local filename = stringmatch(name, "^%[(.*)%]$")
- if filename then
- lookup = "file" --> coerce file:
- name = filename --> remove brackets
- end
- return makespecification(specification, lookup, name, sub, method, detail, size)
- end
- fonts.definers.analyze = analyze
-end
---]]--
-
-loadmodule"features.lua"
-
--- vim:tw=71:sw=4:ts=4:expandtab