diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/context/luatex-fonts.lua')
-rw-r--r-- | Master/texmf-dist/tex/generic/context/luatex-fonts.lua | 163 |
1 files changed, 118 insertions, 45 deletions
diff --git a/Master/texmf-dist/tex/generic/context/luatex-fonts.lua b/Master/texmf-dist/tex/generic/context/luatex-fonts.lua index 84acb2b18c6..23d33f26b8f 100644 --- a/Master/texmf-dist/tex/generic/context/luatex-fonts.lua +++ b/Master/texmf-dist/tex/generic/context/luatex-fonts.lua @@ -6,8 +6,62 @@ if not modules then modules = { } end modules ['luatex-fonts'] = { license = "see context related readme files" } +-- The following code isolates the generic ConTeXt code from already +-- defined or to be defined namespaces. + +-- todo: all global namespaces in called modules will get local shortcuts + +utf = unicode.utf8 + +if not generic_context then + + generic_context = { } + +end + +if not generic_context.push_namespaces then + + function generic_context.push_namespaces() + texio.write(" <push namespace>") + local normalglobal = { } + for k, v in next, _G do + normalglobal[k] = v + end + return normalglobal + end + + function generic_context.pop_namespaces(normalglobal,isolate) + if normalglobal then + texio.write(" <pop namespace>") + for k, v in next, _G do + if not normalglobal[k] then + generic_context[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(generic_context,_G) + else + texio.write(" <fatal error: invalid pop of generic_context>") + os.exit() + end + end + +end + +local whatever = generic_context.push_namespaces() + -- We keep track of load time by storing the current time. That --- way we cannot be accused of slowing down luading too much. +-- way we cannot be accused of slowing down loading too much. +-- +-- Please don't update to this version without proper testing. It +-- might be that this version lags behind stock context and the only +-- formal release takes place around tex live code freeze. local starttime = os.gettimeofday() @@ -47,21 +101,19 @@ loadmodule('luatex-fonts-merged.lua',true) -- you might comment this line if fonts then - -- We're using the merged version. That one could be outdated so - -- remove it from your system when you want to use the files from - -- from the ConTeXt tree, or keep your copy of the merged version - -- up to date. - - texio.write_nl("log",[[ - -I am using the merged version of 'luatex-fonts.lua' here. If -you run into problems or experience unexpected behaviour, and -if you have ConTeXt installed you can try to delete the file -'luatex-font-merged.lua' as I might then use the possibly -updated libraries. The merged version is not supported as it -is a frozen instance. + if not fonts._merge_loaded_message_done_ then + texio.write_nl("log", "!") + texio.write_nl("log", "! I am using the merged version of 'luatex-fonts.lua' here. If") + texio.write_nl("log", "! you run into problems or experience unexpected behaviour, and") + texio.write_nl("log", "! if you have ConTeXt installed you can try to delete the file") + texio.write_nl("log", "! 'luatex-font-merged.lua' as I might then use the possibly") + texio.write_nl("log", "! updated libraries. The merged version is not supported as it") + texio.write_nl("log", "! is a frozen instance. Problems can be reported to the ConTeXt") + texio.write_nl("log", "! mailing list.") + texio.write_nl("log", "!") + end - ]]) + fonts._merge_loaded_message_done_ = true else @@ -82,25 +134,20 @@ else -- lack of other modules. -- First we load a few helper modules. This is about the miminum - -- needed to let the font modules do theuir work. + -- needed to let the font modules do their work. Don't depend on + -- their functions as we might strip them in future versions of + -- this generic variant. - loadmodule('luat-dum.lua') -- not used in context at all - loadmodule('data-con.lua') -- maybe some day we don't need this one + loadmodule('luatex-basics-gen.lua') + loadmodule('data-con.lua') - -- We do need some basic node support although the following - -- modules contain a little bit of code that is not used. It's - -- not worth weeding. + -- We do need some basic node support. The code in there is not for + -- general use as it might change. - loadmodule('node-ini.lua') - loadmodule('node-res.lua') -- will be stripped - loadmodule('node-inj.lua') -- will be replaced (luatex > .50) - loadmodule('node-fnt.lua') - loadmodule('node-dum.lua') + loadmodule('luatex-basics-nod.lua') -- Now come the font modules that deal with traditional TeX fonts - -- as well as open type fonts. We don't load the afm related code - -- from font-enc.lua and font-afm.lua as only ConTeXt deals with - -- it. + -- as well as open type fonts. We only support OpenType fonts here. -- -- The font database file (if used at all) must be put someplace -- visible for kpse and is not shared with ConTeXt. The mtx-fonts @@ -108,33 +155,59 @@ else -- option). loadmodule('font-ini.lua') - loadmodule('font-tfm.lua') -- will be split (we may need font-log) + loadmodule('font-con.lua') + loadmodule('luatex-fonts-enc.lua') -- will load font-age on demand loadmodule('font-cid.lua') - loadmodule('font-ott.lua') -- might be split - loadmodule('font-map.lua') -- for loading lum file (will be stripped) - loadmodule('font-otf.lua') - loadmodule('font-otd.lua') + loadmodule('font-map.lua') -- for loading lum file (will be stripped) + loadmodule('luatex-fonts-syn.lua') -- deals with font names (synonyms) + loadmodule('luatex-fonts-tfm.lua') loadmodule('font-oti.lua') + loadmodule('font-otf.lua') loadmodule('font-otb.lua') + loadmodule('node-inj.lua') -- will be replaced (luatex >= .70) loadmodule('font-otn.lua') - loadmodule('font-ota.lua') -- might be split - loadmodule('font-otc.lua') + -- loadmodule('luatex-fonts-chr.lua') + loadmodule('font-ota.lua') + loadmodule('luatex-fonts-lua.lua') loadmodule('font-def.lua') - loadmodule('font-xtx.lua') - loadmodule('font-dum.lua') + loadmodule('luatex-fonts-def.lua') + loadmodule('luatex-fonts-ext.lua') -- some extensions + + -- We need to plug into a callback and the following module implements + -- the handlers. Actual plugging in happens later. + + loadmodule('luatex-fonts-cbk.lua') end +resolvers.loadmodule = loadmodule + -- In order to deal with the fonts we need to initialize some --- callbacks. One can overload them later on if needed. +-- callbacks. One can overload them later on if needed. First +-- a bit of abstraction. + +generic_context.callback_ligaturing = false +generic_context.callback_kerning = false +generic_context.callback_pre_linebreak_filter = nodes.simple_font_handler +generic_context.callback_hpack_filter = nodes.simple_font_handler +generic_context.callback_define_font = fonts.definers.read + +-- The next ones can be done at a different moment if needed. You can create +-- a generic_context namespace and set no_callbacks_yet to true, load this +-- module, and enable the callbacks later. -callback.register('ligaturing', false) -callback.register('kerning', false) -callback.register('pre_linebreak_filter', nodes.simple_font_handler) -callback.register('hpack_filter', nodes.simple_font_handler) -callback.register('define_font' , fonts.define.read) -callback.register('find_vf_file', nil) -- reset to normal +if not generic_context.no_callbacks_yet then + + callback.register('ligaturing', generic_context.callback_ligaturing) + callback.register('kerning', generic_context.callback_kerning) + callback.register('pre_linebreak_filter', generic_context.callback_pre_linebreak_filter) + callback.register('hpack_filter', generic_context.callback_hpack_filter) + callback.register('define_font' , generic_context.callback_define_font) + +end -- We're done. texio.write(string.format(" <luatex-fonts.lua loaded in %0.3f seconds>", os.gettimeofday()-starttime)) + +generic_context.pop_namespaces(whatever) |