summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/m-newotf.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/m-newotf.mkiv')
-rw-r--r--tex/context/base/mkiv/m-newotf.mkiv89
1 files changed, 89 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/m-newotf.mkiv b/tex/context/base/mkiv/m-newotf.mkiv
new file mode 100644
index 000000000..267d124fa
--- /dev/null
+++ b/tex/context/base/mkiv/m-newotf.mkiv
@@ -0,0 +1,89 @@
+%D \module
+%D [ file=m-newotf,
+%D version=2015.07.08,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=Experimental OTF Loader,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% \endinput
+
+%D This module will go away as soon as we use the new loader code by default.
+%D That will happen after extensive testing. Generic support will happen after
+%D that.
+
+\unprotect
+
+\startluacode
+ local files = {
+ "font-otj",
+ "font-otr",
+ "font-cff",
+ "font-ttf",
+ "font-dsp",
+ "font-oup",
+ "font-otl",
+ "font-ots",
+ "font-oto",
+ "font-otd",
+ "font-otc",
+ "font-osd",
+ "font-map",
+ "font-fbk",
+ "font-gds",
+ }
+ local report = logs.reporter("newotf")
+ local findfile = resolvers.findfile
+ local addsuffix = file.addsuffix
+ report()
+ if fonts.handlers.otf.version >= 3.000 then
+ report("replacing new font loader code by experimental code")
+ else
+ report("replacing old font loader code by new loader code")
+ end
+ report()
+ for i=1,#files do
+ local foundfile = findfile(addsuffix(files[i],"lua"))
+ if foundfile and foundfile ~= "" then
+ report("loading %a",foundfile)
+ dofile(foundfile)
+ end
+ end
+ report()
+
+ -- needed for testing:
+
+ local nuts = nodes.nuts
+ local copy_node = nuts.copy
+ local kern = nuts.pool.register(nuts.pool.kern())
+ local setfield = nuts.setfield
+
+ nuts.setattr(kern,attributes.private('fontkern'),1) -- we can have several, attributes are shared
+
+ nodes.injections.installnewkern(function(k)
+ local c = copy_node(kern)
+ setfield(c,"kern",k)
+ return c
+ end)
+
+ directives.register("nodes.injections.fontkern", function(v) setfield(kern,"subtype",v and 0 or 1) end)
+
+ local fonts = fonts
+ local handlers = fonts.handlers
+ local otf = handlers.otf -- brrr
+ local afm = handlers.afm -- brrr
+ local getters = fonts.getters
+
+ getters.kern .opentype = otf.getkern
+ getters.substitution.opentype = otf.getsubstitution
+ getters.alternate .opentype = otf.getalternate
+ getters.multiple .opentype = otf.getmultiple
+
+\stopluacode
+
+\protect \endinput