From 9138da7d4a53d65bc15f3a5dc73fd373db40bdf7 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 12 Feb 2014 07:50:06 +0100 Subject: [*] move source files to ./src --- src/luaotfload-main.lua | 711 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 711 insertions(+) create mode 100644 src/luaotfload-main.lua (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua new file mode 100644 index 0000000..f5f012d --- /dev/null +++ b/src/luaotfload-main.lua @@ -0,0 +1,711 @@ +----------------------------------------------------------------------- +-- 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-02-09 14:42:22+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 +luaotfload.log = luaotfload.log or { } + +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.log.tex = { + error = error, + warning = warning, + info = info, + 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 + +loadmodule "log.lua" --- messages; used to be part of -override +local log = luaotfload.log +local report = log.report + +log.set_loglevel(config.luaotfload.loglevel) + +--[[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 + report ("log", 0, "main", + "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 () + report ("log", 1, "main", "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 + report ("log", 1, "main", "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 + report ("both", 0, "main", + "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 + report ("log", 0, "main", [["I am using the merged fontloader here.]]) + report ("log", 0, "main", [[ If you run into problems or experience unexpected]]) + report ("log", 0, "main", [[ behaviour, and if you have ConTeXt installed you can try]]) + report ("log", 0, "main", [[ to delete the file 'luaotfload-fontloader.lua' as I might]]) + report ("log", 0, "main", [[ then use the possibly updated libraries. The merged]]) + report ("log", 0, "main", [[ version is not supported as it is a frozen instance.]]) + report ("log", 0, "main", [[ 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) + +report ("both", 0, "main", + "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" --- load glyphlist on demand + +--[[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 + report ("log", 1, "load", "file %q exists", name) + 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 + 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 -- cgit v1.2.3 From 93d0150fdba1a1e212aafeb4e16faef1cba82d60 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 14 Feb 2014 23:15:37 +0100 Subject: =?UTF-8?q?[db,main,tool]=20scan=20local=20fonts=20upon=20failed?= =?UTF-8?q?=20lookup=20during=20a=20TeX=20run=20(requires=20the=20config?= =?UTF-8?q?=20flag=20=E2=80=9Cscan=5Flocal=E2=80=9D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/luaotfload-main.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index f5f012d..ed7fdd3 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -1,10 +1,10 @@ ----------------------------------------------------------------------- -- FILE: luaotfload-main.lua -- DESCRIPTION: Luatex fontloader initialization --- REQUIREMENTS: luatex v.0.78 or later, the lualibs package +-- REQUIREMENTS: luatex v.0.78 or later; the lualibs package -- AUTHOR: Élie Roux, Khaled Hosny, Philipp Gesang -- VERSION: same as Luaotfload --- MODIFIED: 2014-02-09 14:42:22+0100 +-- MODIFIED: 2014-02-14 22:51:09+0100 ----------------------------------------------------------------------- -- --- Note: @@ -59,6 +59,7 @@ 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" +config.luaotfload.scan_local = config.luaotfload.scan_local == true if not config.luaotfload.strip then config.luaotfload.strip = true -- cgit v1.2.3 From a7d9c930f9f0c688a2530bd23e59f0cd830fc9d6 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 25 Feb 2014 07:02:39 +0100 Subject: [doc] move Latex inline verbatim commands to listings --- src/luaotfload-main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index ed7fdd3..0055982 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -61,7 +61,7 @@ config.luaotfload.index_file = config.luaotfload.index_file or "luaot config.luaotfload.formats = config.luaotfload.formats or "otf,ttf,ttc,dfont" config.luaotfload.scan_local = config.luaotfload.scan_local == true -if not config.luaotfload.strip then +if config.luaotfload.strip = nil then config.luaotfload.strip = true end -- cgit v1.2.3 From 8b97d87e20f9ef4a97e81fc9afb852f1620ee790 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 3 Mar 2014 07:20:56 +0100 Subject: [main] fix syntax --- src/luaotfload-main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 0055982..3c4c770 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -61,7 +61,7 @@ config.luaotfload.index_file = config.luaotfload.index_file or "luaot config.luaotfload.formats = config.luaotfload.formats or "otf,ttf,ttc,dfont" config.luaotfload.scan_local = config.luaotfload.scan_local == true -if config.luaotfload.strip = nil then +if config.luaotfload.strip == nil then config.luaotfload.strip = true end -- cgit v1.2.3 From 68d04a338b74a585e12df7ab3200cda389b7c964 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 23 Mar 2014 16:52:27 +0100 Subject: [db,tool,main] implement run directive for bisection mode --- src/luaotfload-main.lua | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 3c4c770..fe4e792 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -49,20 +49,22 @@ luaotfload.log = luaotfload.log or { } 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" -config.luaotfload.scan_local = config.luaotfload.scan_local == true - -if config.luaotfload.strip == nil then - config.luaotfload.strip = true +local luaotfloadconfig = config.luaotfload +----------------.resolver = luaotfloadconfig.resolver or "normal" +luaotfloadconfig.resolver = luaotfloadconfig.resolver or "cached" +luaotfloadconfig.definer = luaotfloadconfig.definer or "patch" +luaotfloadconfig.bisect = false --- useless when running TeX +luaotfloadconfig.loglevel = luaotfloadconfig.loglevel or 2 +luaotfloadconfig.color_callback = luaotfloadconfig.color_callback or "pre_linebreak_filter" +luaotfloadconfig.prioritize = luaotfloadconfig.prioritize or "sys" +luaotfloadconfig.names_dir = luaotfloadconfig.names_dir or "names" +luaotfloadconfig.cache_dir = luaotfloadconfig.cache_dir or "fonts" +luaotfloadconfig.index_file = luaotfloadconfig.index_file or "luaotfload-names.lua" +luaotfloadconfig.formats = luaotfloadconfig.formats or "otf,ttf,ttc,dfont" +luaotfloadconfig.scan_local = luaotfloadconfig.scan_local == true + +if luaotfloadconfig.strip == nil then + luaotfloadconfig.strip = true end luaotfload.module = { @@ -151,7 +153,7 @@ loadmodule "log.lua" --- messages; used to be part of -override local log = luaotfload.log local report = log.report -log.set_loglevel(config.luaotfload.loglevel) +log.set_loglevel(luaotfloadconfig.loglevel) --[[doc-- @@ -689,7 +691,7 @@ reset_callback "define_font" --doc]]-- -local font_definer = config.luaotfload.definer +local font_definer = luaotfloadconfig.definer if font_definer == "generic" then add_to_callback("define_font", -- cgit v1.2.3 From 2237a2bc833d46a1631112fb4c220e3f4941bcc3 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 22 Apr 2014 23:46:48 +0200 Subject: [db,conf,main,tool] move primary configuration table to new configuration model (ignore those initialization stubs for now) --- src/luaotfload-main.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index fe4e792..495001b 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -431,10 +431,12 @@ loadmodule "override.lua" --- load glyphlist on demand 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” +loadmodule "parsers.lua" --- new in 2.5; fonts.conf and syntax +loadmodule "loaders.lua" --- “font-pfb” new in 2.0, added 2011 +loadmodule "configuration.lua" --- configuration options +loadmodule "database.lua" --- “font-nms” +names.initialize_env () --- XXX hack hack hack; we need common initialization +loadmodule "colors.lua" --- “font-clr” --[[doc-- -- cgit v1.2.3 From 226a72e66462faeaa5052cfd8aed6011d2545247 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 24 Apr 2014 23:29:52 +0200 Subject: [colors,conf,db,main,tool] adapt the TeX run code to new configuration --- src/luaotfload-main.lua | 100 +++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 57 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 495001b..836768a 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -43,30 +43,12 @@ if not modules then modules = { } end modules ["luaotfload-main"] = { --doc]]-- +local initial_log_level = 0 + luaotfload = luaotfload or { } local luaotfload = luaotfload luaotfload.log = luaotfload.log or { } -config = config or { } -config.luaotfload = config.luaotfload or { } -local luaotfloadconfig = config.luaotfload -----------------.resolver = luaotfloadconfig.resolver or "normal" -luaotfloadconfig.resolver = luaotfloadconfig.resolver or "cached" -luaotfloadconfig.definer = luaotfloadconfig.definer or "patch" -luaotfloadconfig.bisect = false --- useless when running TeX -luaotfloadconfig.loglevel = luaotfloadconfig.loglevel or 2 -luaotfloadconfig.color_callback = luaotfloadconfig.color_callback or "pre_linebreak_filter" -luaotfloadconfig.prioritize = luaotfloadconfig.prioritize or "sys" -luaotfloadconfig.names_dir = luaotfloadconfig.names_dir or "names" -luaotfloadconfig.cache_dir = luaotfloadconfig.cache_dir or "fonts" -luaotfloadconfig.index_file = luaotfloadconfig.index_file or "luaotfload-names.lua" -luaotfloadconfig.formats = luaotfloadconfig.formats or "otf,ttf,ttc,dfont" -luaotfloadconfig.scan_local = luaotfloadconfig.scan_local == true - -if luaotfloadconfig.strip == nil then - luaotfloadconfig.strip = true -end - luaotfload.module = { name = "luaotfload", version = 2.50000, @@ -90,7 +72,7 @@ local add_to_callback, create_callback = local reset_callback, call_callback = luatexbase.reset_callback, luatexbase.call_callback -local dummy_function = function () end +local dummy_function = function () end --- XXX this will be moved to the luaotfload namespace when we have the init module local error, warning, info, log = luatexbase.provides_module(luaotfload.module) @@ -146,14 +128,17 @@ end local fl_prefix = "luaotfload" -- “luatex” for luatex-plain local loadmodule = function (name) - require(fl_prefix .."-"..name) + require (fl_prefix .."-"..name) end -loadmodule "log.lua" --- messages; used to be part of -override +loadmodule "log.lua" --- log messages +--loadmodule "parsers.lua" --- new in 2.5; fonts.conf and syntax +--loadmodule "configuration.lua" --- configuration options + local log = luaotfload.log local report = log.report -log.set_loglevel(luaotfloadconfig.loglevel) +log.set_loglevel (default_log_level) --[[doc-- @@ -216,8 +201,7 @@ end --doc]]-- -local starttime = os.gettimeofday() - +local starttime = os.gettimeofday () local trapped_register = callback.register callback.register = dummy_function @@ -431,12 +415,22 @@ loadmodule "override.lua" --- load glyphlist on demand 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 "parsers.lua" --- fonts.conf and syntax loadmodule "configuration.lua" --- configuration options -loadmodule "database.lua" --- “font-nms” -names.initialize_env () --- XXX hack hack hack; we need common initialization -loadmodule "colors.lua" --- “font-clr” + +if not config.actions.apply_defaults () then + report ("log", 0, "load", "Configuration unsuccessful.") +end + +loadmodule "loaders.lua" --- Type1 font wrappers +loadmodule "database.lua" --- Font management. +fonts.names.initialize_env () --- XXX hack hack hack; we need common initialization +loadmodule "colors.lua" --- Per-font colors. + +if not config.actions.reconfigure () then + report ("log", 0, "load", "Post-configuration hooks failed.") +end --[[doc-- @@ -673,17 +667,20 @@ create_callback("luaotfload.patch_font", "simple", dummy_function) 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 +local definers = { + generic = read_font_file, + --- spec -> size -> id -> tmfdata + patch = 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" @@ -693,23 +690,12 @@ reset_callback "define_font" --doc]]-- -local font_definer = luaotfloadconfig.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 +local definer = config.luaotfload.run.definer +add_to_callback ("define_font", definers[definer], "luaotfload.define_font", 1) -loadmodule "features.lua" --- contains what was “font-ltx” and “font-otc” +loadmodule "features.lua" --- font request and feature handling loadmodule "letterspace.lua" --- extra character kerning -loadmodule "auxiliary.lua" --- additionaly high-level functionality (new) +loadmodule "auxiliary.lua" --- additional high-level functionality luaotfload.aux.start_rewrite_fontname () --- to be migrated to fontspec -- cgit v1.2.3 From 30100703fb61f7ca421a41615f7b9db32bd362e2 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 24 Apr 2014 23:36:07 +0200 Subject: =?UTF-8?q?[main]=20register=20as=20=E2=80=9Cluaotfload-main?= =?UTF-8?q?=E2=80=9D=20to=20silence=20luatexbase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/luaotfload-main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 836768a..a8d6ef9 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -50,7 +50,7 @@ local luaotfload = luaotfload luaotfload.log = luaotfload.log or { } luaotfload.module = { - name = "luaotfload", + name = "luaotfload-main", version = 2.50000, date = "2014/**/**", description = "OpenType layout system.", -- cgit v1.2.3 From b1856d2be074479aac62f6e89e1fafabb809e590 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 24 Apr 2014 23:38:03 +0200 Subject: [main] trivial: make local imports legible --- src/luaotfload-main.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index a8d6ef9..a752c9a 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -67,10 +67,10 @@ 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 add_to_callback = luatexbase.add_to_callback +local create_callback = luatexbase.create_callback +local reset_callback = luatexbase.reset_callback +local call_callback = luatexbase.call_callback local dummy_function = function () end --- XXX this will be moved to the luaotfload namespace when we have the init module -- cgit v1.2.3 From 2cdf631f45646e7e2f4a5cf05045cc6f5167d51e Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 24 Apr 2014 23:42:35 +0200 Subject: [main] trivial: improve Luatex minimum version test --- src/luaotfload-main.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index a752c9a..2e65788 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -98,18 +98,18 @@ luaotfload.log.tex = { --doc]]-- -local luatex_version = 76 +local min_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) +if tex.luatexversion < min_luatex_version then + warning ("LuaTeX v%.2f is old, v%.2f or later is recommended.", + tex.luatexversion / 100, + min_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 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 + for n in traverse_nodes (math_t, n.next) do return n end end -- cgit v1.2.3 From 996f42e8bf5413665adaff02f188fbf8a0be7a2d Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 15 May 2014 08:05:06 +0200 Subject: [main] remove config hack --- src/luaotfload-main.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 2e65788..82192f8 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -425,7 +425,6 @@ end loadmodule "loaders.lua" --- Type1 font wrappers loadmodule "database.lua" --- Font management. -fonts.names.initialize_env () --- XXX hack hack hack; we need common initialization loadmodule "colors.lua" --- Per-font colors. if not config.actions.reconfigure () then -- cgit v1.2.3 From 60e5dfe5a271997fe530197bbd810862125fb795 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 15 May 2014 08:17:17 +0200 Subject: [main] choose resolver at runtime --- src/luaotfload-main.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 82192f8..d8dc1d1 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -479,7 +479,6 @@ fonts.encodings.known = fonts.encodings.known or { } 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) @@ -612,8 +611,7 @@ end --[[doc-- - The \verb|name:| resolver wraps the database function - \luafunction{resolve_name}. + The \verb|name:| resolver. --doc]]-- @@ -621,7 +619,11 @@ end --- generic name resolver. request_resolvers.name = function (specification) - local resolved, subfont = resolve_name (specification) + local resolver = names.resolve_cached + if config.luaotfload.run.resolver == "normal" then + resolver = names.resolve_name + end + local resolved, subfont = resolver (specification) if resolved then specification.resolved = resolved specification.sub = subfont -- cgit v1.2.3 From aca3f50f6806f838b6acbaa2f7012fc6b12d5080 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 18 May 2014 20:57:45 +0200 Subject: [main] log name: requests independent of fontloader --- src/luaotfload-main.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index d8dc1d1..dba1f52 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -565,7 +565,7 @@ request_resolvers.path = function (specification) local name = specification.name local exists, _ = lfsisfile(name) if not exists then -- resort to file: lookup - report ("log", 1, "load", + report ("log", 0, "load", "path lookup of %q unsuccessful, falling back to file:", name) file_resolver (specification) @@ -625,6 +625,8 @@ request_resolvers.name = function (specification) end local resolved, subfont = resolver (specification) if resolved then + report ("log", 0, "load", "Lookup/name: %q -> \"%s(%d)\"", + specification.name, resolved, subfont) specification.resolved = resolved specification.sub = subfont specification.forced = filesuffix (resolved) -- cgit v1.2.3 From 0e06af55b50b2314c5d99db4843c1881dd89a88b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 18 May 2014 21:25:24 +0200 Subject: [main] lowercase file suffix when forcing file format (thanks, Bryan!) Closing https://github.com/lualatex/luaotfload/issues/215 --- src/luaotfload-main.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index dba1f52..4baa225 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -63,6 +63,7 @@ local luatexbase = luatexbase local setmetatable = setmetatable local type, next = type, next +local stringlower = string.lower local kpsefind_file = kpse.find_file local lfsisfile = lfs.isfile @@ -477,14 +478,14 @@ fonts.encodings.known = fonts.encodings.known or { } --doc]]-- -local resolve_file = names.crude_file_lookup ---local resolve_file = names.crude_file_lookup_verbose +--local resolve_file = names.crude_file_lookup +local resolve_file = names.crude_file_lookup_verbose local file_resolver = function (specification) local name = resolve_file (specification.name) local suffix = filesuffix(name) if formats[suffix] then - specification.forced = suffix + specification.forced = stringlower (suffix) specification.forcedname = file.removesuffix(name) else specification.name = name @@ -522,7 +523,7 @@ request_resolvers.file = file_resolver --doc]]-- -local type1_formats = { "tfm", "ofm", } +local type1_formats = { "tfm", "ofm", "TFM", "OFM", } request_resolvers.anon = function (specification) local name = specification.name @@ -572,7 +573,7 @@ request_resolvers.path = function (specification) else local suffix = filesuffix (name) if formats[suffix] then - specification.forced = suffix + specification.forced = stringlower (suffix) specification.name = file.removesuffix(name) specification.forcedname = name else @@ -595,7 +596,7 @@ request_resolvers.kpse = function (specification) if suffix and formats[suffix] then name = file.removesuffix(name) if resolvers.findfile(name, suffix) then - specification.forced = suffix + specification.forced = stringlower (suffix) specification.forcedname = name return end @@ -629,7 +630,7 @@ request_resolvers.name = function (specification) specification.name, resolved, subfont) specification.resolved = resolved specification.sub = subfont - specification.forced = filesuffix (resolved) + specification.forced = stringlower (filesuffix (resolved) or "") specification.forcedname = resolved specification.name = fileremovesuffix (resolved) else -- cgit v1.2.3 From 1780d5eede861e35d05387278e90412ddac13d8f Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 9 Jun 2014 23:14:05 +0200 Subject: [main] fix error message --- src/luaotfload-main.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 4baa225..36cbaf6 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -626,8 +626,10 @@ request_resolvers.name = function (specification) end local resolved, subfont = resolver (specification) if resolved then - report ("log", 0, "load", "Lookup/name: %q -> \"%s(%d)\"", - specification.name, resolved, subfont) + report ("log", 0, "load", "Lookup/name: %q -> \"%s%s\"", + specification.name, + resolved, + subfont and stringformat ("(%d)", subfont) or "") specification.resolved = resolved specification.sub = subfont specification.forced = stringlower (filesuffix (resolved) or "") -- cgit v1.2.3 From 4a9a0cb9382ffc70e68913b9fffd74b5a6d1a3d4 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 12 Jul 2014 09:51:52 +0200 Subject: [db] remove the alternative (and buggy) verbose file lookup Also document the file lookup somewhat and rename it to ``font_file_lookup()``. --- src/luaotfload-main.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 36cbaf6..83e12a9 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -478,8 +478,7 @@ fonts.encodings.known = fonts.encodings.known or { } --doc]]-- ---local resolve_file = names.crude_file_lookup -local resolve_file = names.crude_file_lookup_verbose +local resolve_file = names.font_file_lookup local file_resolver = function (specification) local name = resolve_file (specification.name) -- cgit v1.2.3 From 4a4edf88b2e69da6f609760c7a3664650b4abc2a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 13 Jul 2014 07:37:55 +0200 Subject: [main] deprioritize fontloader intro message This message originates in ``luatex-fonts.lua`` [0]. The advice given on using the Context libraries directly is counterproductive unless one is already hacking on the Luaotfload code, in which case it should be obvious anyways. Cluttering the log file with those lines is unjustified. [0] http://git.contextgarden.net/context/context/blob/master/tex/generic/context/luatex/luatex-fonts.lua#L139 --- src/luaotfload-main.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 83e12a9..7686c80 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -311,13 +311,13 @@ loadmodule "fontloader.lua" if fonts then if not fonts._merge_loaded_message_done_ then - report ("log", 0, "main", [["I am using the merged fontloader here.]]) - report ("log", 0, "main", [[ If you run into problems or experience unexpected]]) - report ("log", 0, "main", [[ behaviour, and if you have ConTeXt installed you can try]]) - report ("log", 0, "main", [[ to delete the file 'luaotfload-fontloader.lua' as I might]]) - report ("log", 0, "main", [[ then use the possibly updated libraries. The merged]]) - report ("log", 0, "main", [[ version is not supported as it is a frozen instance.]]) - report ("log", 0, "main", [[ Problems can be reported to the ConTeXt mailing list."]]) + report ("log", 5, "main", [["I am using the merged fontloader here.]]) + report ("log", 5, "main", [[ If you run into problems or experience unexpected]]) + report ("log", 5, "main", [[ behaviour, and if you have ConTeXt installed you can try]]) + report ("log", 5, "main", [[ to delete the file 'luaotfload-fontloader.lua' as I might]]) + report ("log", 5, "main", [[ then use the possibly updated libraries. The merged]]) + report ("log", 5, "main", [[ version is not supported as it is a frozen instance.]]) + report ("log", 5, "main", [[ Problems can be reported to the ConTeXt mailing list."]]) end fonts._merge_loaded_message_done_ = true -- cgit v1.2.3 From 7bf83c68f3575e1a49533ecd45178551e62746f9 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 13 Jul 2014 07:51:13 +0200 Subject: [main] adapt local to current terminology --- src/luaotfload-main.lua | 56 ++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index 7686c80..c7694ea 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -137,7 +137,7 @@ loadmodule "log.lua" --- log messages --loadmodule "configuration.lua" --- configuration options local log = luaotfload.log -local report = log.report +local logreport = log.report log.set_loglevel (default_log_level) @@ -165,8 +165,8 @@ local find_vf_file = function (name) fullname = kpsefind_file(lpegmatch(p_removesuffix, name), "ovf") end if fullname then - report ("log", 0, "main", - "loading virtual font file %s.", fullname) + logreport ("log", 0, "main", + "loading virtual font file %s.", fullname) end return fullname end @@ -249,7 +249,7 @@ end local context_environment = { } local push_namespaces = function () - report ("log", 1, "main", "push namespace for font loader") + logreport ("log", 1, "main", "push namespace for font loader") local normalglobal = { } for k, v in next, _G do normalglobal[k] = v @@ -262,7 +262,7 @@ local pop_namespaces = function (normalglobal, isolate) local _G = _G local mode = "non-destructive" if isolate then mode = "destructive" end - report ("log", 1, "main", "pop namespace from font loader -- " .. mode) + logreport ("log", 1, "main", "pop namespace from font loader -- " .. mode) for k, v in next, _G do if not normalglobal[k] then context_environment[k] = v @@ -277,8 +277,8 @@ local pop_namespaces = function (normalglobal, isolate) -- just to be sure: setmetatable(context_environment,_G) else - report ("both", 0, "main", - "irrecoverable error during pop_namespace: no globals to restore") + logreport ("both", 0, "main", + "irrecoverable error during pop_namespace: no globals to restore") os.exit() end end @@ -311,13 +311,13 @@ loadmodule "fontloader.lua" if fonts then if not fonts._merge_loaded_message_done_ then - report ("log", 5, "main", [["I am using the merged fontloader here.]]) - report ("log", 5, "main", [[ If you run into problems or experience unexpected]]) - report ("log", 5, "main", [[ behaviour, and if you have ConTeXt installed you can try]]) - report ("log", 5, "main", [[ to delete the file 'luaotfload-fontloader.lua' as I might]]) - report ("log", 5, "main", [[ then use the possibly updated libraries. The merged]]) - report ("log", 5, "main", [[ version is not supported as it is a frozen instance.]]) - report ("log", 5, "main", [[ Problems can be reported to the ConTeXt mailing list."]]) + logreport ("log", 5, "main", [["I am using the merged fontloader here.]]) + logreport ("log", 5, "main", [[ If you run into problems or experience unexpected]]) + logreport ("log", 5, "main", [[ behaviour, and if you have ConTeXt installed you can try]]) + logreport ("log", 5, "main", [[ to delete the file 'luaotfload-fontloader.lua' as I might]]) + logreport ("log", 5, "main", [[ then use the possibly updated libraries. The merged]]) + logreport ("log", 5, "main", [[ version is not supported as it is a frozen instance.]]) + logreport ("log", 5, "main", [[ Problems can be reported to the ConTeXt mailing list."]]) end fonts._merge_loaded_message_done_ = true @@ -375,8 +375,8 @@ end --- non-merge fallback scope pop_namespaces(our_environment, false)-- true) -report ("both", 0, "main", - "fontloader loaded in %0.3f seconds", os.gettimeofday()-starttime) +logreport ("both", 0, "main", + "fontloader loaded in %0.3f seconds", os.gettimeofday()-starttime) --[[doc-- @@ -421,7 +421,7 @@ loadmodule "parsers.lua" --- fonts.conf and syntax loadmodule "configuration.lua" --- configuration options if not config.actions.apply_defaults () then - report ("log", 0, "load", "Configuration unsuccessful.") + logreport ("log", 0, "load", "Configuration unsuccessful.") end loadmodule "loaders.lua" --- Type1 font wrappers @@ -429,7 +429,7 @@ loadmodule "database.lua" --- Font management. loadmodule "colors.lua" --- Per-font colors. if not config.actions.reconfigure () then - report ("log", 0, "load", "Post-configuration hooks failed.") + logreport ("log", 0, "load", "Post-configuration hooks failed.") end --[[doc-- @@ -541,9 +541,9 @@ request_resolvers.anon = function (specification) local exists, _ = lfsisfile(name) if exists then --- garbage; we do this because we are nice, --- not because it is correct - report ("log", 1, "load", "file %q exists", name) - report ("log", 1, "load", - "... overriding borked anon: lookup with path: lookup") + logreport ("log", 1, "load", "file %q exists", name) + logreport ("log", 1, "load", + "... overriding borked anon: lookup with path: lookup") specification.name = name request_resolvers.path(specification) return @@ -565,9 +565,9 @@ request_resolvers.path = function (specification) local name = specification.name local exists, _ = lfsisfile(name) if not exists then -- resort to file: lookup - report ("log", 0, "load", - "path lookup of %q unsuccessful, falling back to file:", - name) + logreport ("log", 0, "load", + "path lookup of %q unsuccessful, falling back to file:", + name) file_resolver (specification) else local suffix = filesuffix (name) @@ -625,10 +625,10 @@ request_resolvers.name = function (specification) end local resolved, subfont = resolver (specification) if resolved then - report ("log", 0, "load", "Lookup/name: %q -> \"%s%s\"", - specification.name, - resolved, - subfont and stringformat ("(%d)", subfont) or "") + logreport ("log", 0, "load", "Lookup/name: %q -> \"%s%s\"", + specification.name, + resolved, + subfont and stringformat ("(%d)", subfont) or "") specification.resolved = resolved specification.sub = subfont specification.forced = stringlower (filesuffix (resolved) or "") -- cgit v1.2.3 From d84ce4ec794e634b853ca88925e1d20f6a1287e3 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 13 Jul 2014 15:01:59 +0200 Subject: [features,conf] generalize feature option parsing --- src/luaotfload-main.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'src/luaotfload-main.lua') diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua index c7694ea..6616468 100644 --- a/src/luaotfload-main.lua +++ b/src/luaotfload-main.lua @@ -64,6 +64,7 @@ local luatexbase = luatexbase local setmetatable = setmetatable local type, next = type, next local stringlower = string.lower +local stringformat = string.format local kpsefind_file = kpse.find_file local lfsisfile = lfs.isfile -- cgit v1.2.3