summaryrefslogtreecommitdiff
path: root/tex/generic/context/luatex-fonts.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/generic/context/luatex-fonts.lua')
-rw-r--r--tex/generic/context/luatex-fonts.lua132
1 files changed, 100 insertions, 32 deletions
diff --git a/tex/generic/context/luatex-fonts.lua b/tex/generic/context/luatex-fonts.lua
index c96dada77..84d79a63f 100644
--- a/tex/generic/context/luatex-fonts.lua
+++ b/tex/generic/context/luatex-fonts.lua
@@ -6,8 +6,58 @@ 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
@@ -58,7 +108,8 @@ if fonts then
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.")
+ 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
@@ -83,24 +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. Beware, in node-dum some functions use
- -- fonts.* tables, not that nice but I don't want two dummy
- -- files. Some day I will sort this out (no problem in context).
+ -- We do need some basic node support. The code in there is not for
+ -- general use as it might change.
- loadmodule('node-dum.lua')
- loadmodule('node-inj.lua') -- will be replaced (luatex >= .70)
+ 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,37 +155,58 @@ 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-lua.lua')
- 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')
- loadmodule('font-otc.lua')
- loadmodule('font-age.lua') -- special for this variant
+ 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.
+
+if not generic_context.no_callbacks_yet then
-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.definers.read)
-callback.register('find_vf_file', nil) -- reset to normal
+ 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)