From 1f360a62ce1f1b6cd4601e349718e414f64d8f35 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 22 Jul 2015 22:45:46 +0200 Subject: [init,main,package] split initialization in early and late stage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a big move. Due to the restructuring of the initialization we can now separate the early tasks -- mostly dirty stuff like writing globals -- from the later stage where we actually inject the actual font loader. As a consequence, the basic configuration is now present before the font loader is injected. It’s not complete, though, in that the reconfiguration step must still be executed after the font loader is there, since some config variables require values to be set up by the loader. A decision is pending regarding how we address the situation; possible approaches are, in order of increasing complexity: * reconfigure twice, skip some of the steps the first time through * split reconfiguration into two stages * make configuration independent of fontloader values Design-wise, the last point would be the most desirable, naturally. Though the fontloader has been known to require extensive static preparation which might very well make that strategy impossible or unjustifiably demanding. We’ll see how it plays out … --- src/luaotfload-init.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/luaotfload-init.lua') diff --git a/src/luaotfload-init.lua b/src/luaotfload-init.lua index ac27b2c..0ef968d 100644 --- a/src/luaotfload-init.lua +++ b/src/luaotfload-init.lua @@ -65,7 +65,7 @@ local logreport --- filled in after loading the log module --doc]]-- -local init_pre = function () +local init_early = function () local store = { } config = config or { } --- global @@ -74,6 +74,7 @@ local init_pre = function () config.lualibs.verbose = false config.lualibs.prefer_merged = true config.lualibs.load_extended = true + fonts = fonts or { } require "lualibs" @@ -131,8 +132,10 @@ local init_pre = function () return number end + luaotfload.loaders.fontloader "basics-gen" + return store -end --- [init_pre] +end --- [init_early] --[[doc-- @@ -345,6 +348,13 @@ local init_post_load_agl = function () return end + if next (fonts.encodings.agl) then + --- unnecessary because the file shouldn’t be loaded at this time + --- but we’re just making sure + fonts.encodings.agl = nil + collectgarbage"collect" + end + local agl_init = { } --- start out empty, fill on demand encodings.agl = agl_init --- ugh, replaced again later @@ -408,9 +418,9 @@ local init_post = function () end --- [init_post] return { - init = function () + early = init_early, + main = function (store) local starttime = os.gettimeofday () - local store = init_pre () store.our_environment, store.context_environment = init_adapt () init_main () init_cleanup (store) -- cgit v1.2.3