diff options
Diffstat (limited to 'luaotfload.dtx')
-rw-r--r-- | luaotfload.dtx | 652 |
1 files changed, 328 insertions, 324 deletions
diff --git a/luaotfload.dtx b/luaotfload.dtx index f86d9b7..7c74a37 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 @@ -801,102 +801,87 @@ and the derived files % \identifier{luaotfload} in one way or the other. % See figure \ref{file-graph} on page \pageref{file-graph} for a % graphical representation of the dependencies. -% From \LUATEX-Fonts the following files have been imported: +% From \LUATEX-Fonts, only the file \fileent{luatex-fonts-merged.lua} +% has been imported as \fileent{luaotfload-merged.lua}. +% It is generated by \fileent{mtx-package}, a \LUA source code merging +% too developed by Hans Hagen.\footnote{% +% \fileent{mtx-package} is +% \href +% {http://repo.or.cz/w/context.git/blob_plain/refs/heads/origin:/scripts/context/lua/mtx-package.lua} +% {part of \CONTEXT} +% and requires \fileent{mtxrun}. +% Run +% \verb|mtxrun --script package --help| +% to display further information. +% For the actual merging code see the file +% \fileent{util-mrg.lua} that is part of \CONTEXT. +% } +% It houses several \LUA files that can be classed in three +% categories. % % \begin{itemize} % \let\normalitem=\item -% \def\fileitem#1#2{% -% \normalitem{\fileent{#1}}% -% \hfill -% (as \fileent{\itshape#2})% -% \break -% } % \def\incitem#1{% % \normalitem{\fileent{#1}} % } -% \fileitem{luatex-fonts.lua}{otfl-fonts.lua} -% The wrapper that loads the font loader code. -% -% \fileitem{luatex-fonts-merged.lua}{otfl-fonts-merged.lua} -% The font loader package. -% It is generated by \fileent{mtx-package}, a \LUA -% source code merging tool developed by Hans -% Hagen.\footnote{% -% \fileent{mtx-package} is -% \href -% {http://repo.or.cz/w/context.git/blob_plain/refs/heads/origin:/scripts/context/lua/mtx-package.lua} -% {part of \CONTEXT} -% and requires \fileent{mtxrun}. -% Run -% \verb|mtxrun --script package --help| -% to display further information. -% For the actual merging code see the file -% \fileent{util-mrg.lua} that is part of \CONTEXT. -% } -% -% Included are several Lua files that can be classed in three -% categories. -% \begin{itemize} -% \normalitem \emphasis{\LUA utility libraries}, a subset -% of what is provided by the \identifier{lualibs} -% package. -% -% \begin{multicols}{2} -% \begin{itemize} -% \incitem{l-lua.lua} \incitem{l-lpeg.lua} -% \incitem{l-function.lua} \incitem{l-string.lua} -% \incitem{l-table.lua} \incitem{l-io.lua} -% \incitem{l-file.lua} \incitem{l-boolean.lua} -% \incitem{l-math.lua} \incitem{util-str.lua} -% \end{itemize} -% \end{multicols} -% -% \normalitem The \emphasis{font loader} itself. -% These files have been written for -% \LUATEX-Fonts and they are distributed along -% with \identifier{luaotfload}. -% \begin{multicols}{2} -% \begin{itemize} -% \incitem{luatex-basics-gen.lua} -% \incitem{luatex-basics-nod.lua} -% \incitem{luatex-fonts-enc.lua} -% \incitem{luatex-fonts-syn.lua} -% \incitem{luatex-fonts-tfm.lua} -% \incitem{luatex-fonts-chr.lua} -% \incitem{luatex-fonts-lua.lua} -% \incitem{luatex-fonts-def.lua} -% \incitem{luatex-fonts-ext.lua} -% \incitem{luatex-fonts-cbk.lua} -% \end{itemize} -% \end{multicols} -% -% \normalitem Code related to \emphasis{font handling and -% node processing}, taken directly from -% \CONTEXT. -% \begin{multicols}{2} -% \begin{itemize} -% \incitem{data-con.lua} \incitem{font-ini.lua} -% \incitem{font-con.lua} \incitem{font-cid.lua} -% \incitem{font-map.lua} \incitem{font-oti.lua} -% \incitem{font-otf.lua} \incitem{font-otb.lua} -% \incitem{node-inj.lua} \incitem{font-ota.lua} -% \incitem{font-otn.lua} \incitem{font-def.lua} -% \end{itemize} -% \end{multicols} -% \end{itemize} -% -% Note that if \identifier{luaotfload} cannot locate the -% merged file, it will load the individual \LUA libraries -% instead. -% Their names remain the same as in \CONTEXT (without the -% \verb|otfl|-prefix) since they are hard-coded in -% \fileent{otfl-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. -% +% \normalitem \emphasis{\LUA utility libraries}, a subset +% of what is provided by the \identifier{lualibs} +% package. +% +% \begin{multicols}{2} +% \begin{itemize} +% \incitem{l-lua.lua} \incitem{l-lpeg.lua} +% \incitem{l-function.lua} \incitem{l-string.lua} +% \incitem{l-table.lua} \incitem{l-io.lua} +% \incitem{l-file.lua} \incitem{l-boolean.lua} +% \incitem{l-math.lua} \incitem{util-str.lua} +% \end{itemize} +% \end{multicols} +% +% \normalitem The \emphasis{font loader} itself. +% These files have been written for +% \LUATEX-Fonts and they are distributed along +% with \identifier{luaotfload}. +% \begin{multicols}{2} +% \begin{itemize} +% \incitem{luatex-basics-gen.lua} +% \incitem{luatex-basics-nod.lua} +% \incitem{luatex-fonts-enc.lua} +% \incitem{luatex-fonts-syn.lua} +% \incitem{luatex-fonts-tfm.lua} +% \incitem{luatex-fonts-chr.lua} +% \incitem{luatex-fonts-lua.lua} +% \incitem{luatex-fonts-def.lua} +% \incitem{luatex-fonts-ext.lua} +% \incitem{luatex-fonts-cbk.lua} +% \end{itemize} +% \end{multicols} +% +% \normalitem Code related to \emphasis{font handling and +% node processing}, taken directly from +% \CONTEXT. +% \begin{multicols}{2} +% \begin{itemize} +% \incitem{data-con.lua} \incitem{font-ini.lua} +% \incitem{font-con.lua} \incitem{font-cid.lua} +% \incitem{font-map.lua} \incitem{font-oti.lua} +% \incitem{font-otf.lua} \incitem{font-otb.lua} +% \incitem{node-inj.lua} \incitem{font-ota.lua} +% \incitem{font-otn.lua} \incitem{font-def.lua} +% \end{itemize} +% \end{multicols} % \end{itemize} % +% Note that if \identifier{luaotfload} cannot locate the +% merged file, it will load the individual \LUA libraries +% 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}. +% 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. +% % In addition to these, \identifier{luaotfload} requires a number of % files not contained in the merge. Some of these have no equivalent in % \LUATEX-Fonts or \CONTEXT, some were taken unmodified from the @@ -908,26 +893,26 @@ 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} % % \begin{figure}[b] -% \caption{Schematic of the Files in \identifier{Luaotfload}} -% \includegraphics[width=\textheight,angle=90]{filegraph.pdf} +% \caption{Schematic of the files in \identifier{Luaotfload}} +% \includegraphics[width=\textwidth]{filegraph.pdf} % \label{file-graph} % \end{figure} % @@ -990,7 +975,12 @@ and the derived files %<*lua> % \fi % \begin{macrocode} -luaotfload = luaotfload or {} +luaotfload = luaotfload or {} +local luaotfload = luaotfload + +config = config or { } +config.luaotfload = config.luaotfload or { } +luaotfload.prefer_merge = config.luaotfload.prefer_merge or true luaotfload.module = { name = "luaotfload", @@ -1005,9 +995,11 @@ luaotfload.module = { local luatexbase = luatexbase local type, next = type, next +local setmetatable = setmetatable 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 = @@ -1018,14 +1010,14 @@ local reset_callback, call_callback = 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} -% wrapper, and a simplified version of the latter (\identifier{patch}) -% that does nothing besides applying font patches. +% 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. % % \begin{macrocode} + luaotfload.font_definer = "patch" --- | “generic” | “old” local error, warning, info, log = @@ -1047,28 +1039,25 @@ if tex.luatexversion < luatex_version then 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. +% \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 = "otfl" -- “luatex” for luatex-plain +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. +% 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 @@ -1089,208 +1078,235 @@ 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 -% \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. +% \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} -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 - skip_loading = true, -}} +local starttime = os.gettimeofday() + +local trapped_register = callback.register +callback.register = dummy_function % \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 -% if we make it call a dummy instead. +% 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} -local trapped_register = callback.register -callback.register = dummy_function +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} -% -% In order to have an output with normal verbosity, we need to pre-override -% some \CONTEXT log function: +% These next lines replicate the behavior of \fileent{luatex-fonts.lua}. % % \begin{macrocode} -local dummylogfunction=function() end -local dummylogreporter=function(c) return function(...) log(string.formatters(...)) end end +local context_environment = { } -logs={ - new=dummylogreporter, - reporter=dummylogreporter, - messenger=dummylogreporter, - report=dummylogfunction, -} +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} -% -% Now that things are sorted out we can finally load the fontloader. +% The font loader requires that the attribute with index zero be zero. +% We happily oblige. +% (Cf. \fileent{luatex-fonts-nod.lua}.) % % \begin{macrocode} -loadmodule"fonts.lua" +tex.attribute[0] = 0 % \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{otfl@}” to -% avoid name clashes. +% Now that things are sorted out we can finally load the fontloader. % % \begin{macrocode} -do - local new_attribute = luatexbase.new_attribute - local the_attributes = luatexbase.attributes +loadmodule"merged.lua" - attributes = attributes or { } +if fonts then - attributes.private = function (name) - local attr = "otfl@" .. name - local number = the_attributes[attr] - if not number then - number = new_attribute(attr) - end - return number + if not fonts._merge_loaded_message_done_ then + --- a program talking first person -- HH sure believes in strong AI ... + log[[“I am using the merged version of 'luaotfload.lua' here. If]] + log[[ you run into problems or experience unexpected behaviour,]] + log[[ and if you have ConTeXt installed you can try to delete the]] + log[[ file 'luaotfload-font-merged.lua' as I might then use the]] + log[[ possibly updated libraries. The merged version is not]] + log[[ supported as it is a frozen instance. Problems can be]] + log[[ reported to the ConTeXt mailing list.”]] end -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('node-inj.lua') + loadmodule('font-ota.lua') + loadmodule('font-otn.lua') + 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. % -% -% \subsection{Callbacks} -% -% After the fontloader is ready we can restore the callback trap from -% \identifier{luatexbase}. +% \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}. +% 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", - generic_context.callback_pre_linebreak_filter, + nodes.simple_font_handler, "luaotfload.node_processor", 1) add_to_callback("hpack_filter", - generic_context.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"font-otc.lua" -- TODO check what we can drop from otfl-features -loadmodule"lib-dir.lua" -- required by font-nms -loadmodule"luat-ovr.lua" +loadmodule"lib-dir.lua" --- required by luaofload-database.lua +loadmodule"override.lua" --- “luat-ovr” % \end{macrocode} -% -% -% \CONTEXT does not support ofm, these lines were added in order to make it -% work. However they do not seem necessary so they are commented for now. +% \CONTEXT does not support ofm, these lines were added in order to make it +% work. However they do not seem necessary so they are commented for now. % % \begin{macrocode} -- if fonts and fonts.readers.tfm then @@ -1300,57 +1316,47 @@ loadmodule"luat-ovr.lua" -- --- fonts.readers.sequence[#fonts.readers.sequence+1] = "ofm" --end % \end{macrocode} -% -% -% Now we load the modules written for \identifier{luaotfload}. +% Now we load the modules written for \identifier{luaotfload}. % % \begin{macrocode} -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 +loadmodule"loaders.lua" --- “font-pfb” new in 2.0, added 2011 +loadmodule"database.lua" --- “font-nms” +loadmodule"colors.lua" --- “font-clr” % \end{macrocode} -% -% -% This hack makes fonts called with file method found by fonts.names.resove -% 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 -% quite common case under Linux. +% 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 +% 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} -% -% -% 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. +% 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} -% -% -% 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. +% 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. % % \begin{macrocode} local define_font_wrapper = function (...) @@ -1388,12 +1394,9 @@ local define_font_wrapper = function (...) end % \end{macrocode} -% -% -% \subsection{\CONTEXT override} -% -% We provide a simplified version of the original font definition -% callback. +% \subsection{\CONTEXT override} +% We provide a simplified version of the original font definition +% callback. % % \begin{macrocode} @@ -1403,6 +1406,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 @@ -1411,8 +1415,7 @@ caches.compilemethod = "both" reset_callback("define_font") % \end{macrocode} -% -% Finally we register the callbacks +% Finally we register the callbacks. % % \begin{macrocode} @@ -1423,7 +1426,7 @@ if luaotfload.font_definer == "old" then 1) elseif luaotfload.font_definer == "generic" then add_to_callback("define_font", - generic_context.callback_define_font, + fonts.definers.read, "luaotfload.define_font", 1) elseif luaotfload.font_definer == "patch" then @@ -1465,10 +1468,11 @@ do end --]]-- -loadmodule"features.lua" +loadmodule"features.lua" --- contains what was “font-ltx” and “font-otc” -- vim:tw=71:sw=4:ts=4:expandtab + % \end{macrocode} % % \iffalse @@ -1631,7 +1635,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. % |