summaryrefslogtreecommitdiff
path: root/tex/context/modules
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-10-02 23:41:59 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2018-10-02 23:41:59 +0200
commit551c89289d267c2d8901f3375e57ed1fe2508de5 (patch)
tree937be4d873b1762d93fcce75ecca3cfea07b2ca4 /tex/context/modules
parente3ad6b783e6162de6dad5531299e69c3d3079b9c (diff)
downloadcontext-551c89289d267c2d8901f3375e57ed1fe2508de5.tar.gz
2018-10-02 23:25:00
Diffstat (limited to 'tex/context/modules')
-rw-r--r--tex/context/modules/mkiv/s-fonts-system.lua39
-rw-r--r--tex/context/modules/mkiv/s-fonts-system.mkiv6
-rw-r--r--tex/context/modules/mkiv/s-xml-analyzers.lua6
3 files changed, 47 insertions, 4 deletions
diff --git a/tex/context/modules/mkiv/s-fonts-system.lua b/tex/context/modules/mkiv/s-fonts-system.lua
index 5b58a4a53..b91b3e75d 100644
--- a/tex/context/modules/mkiv/s-fonts-system.lua
+++ b/tex/context/modules/mkiv/s-fonts-system.lua
@@ -36,8 +36,7 @@ local context = context
local NC, NR, HL = context.NC, context.NR, context.HL
local bold = context.bold
-function moduledata.fonts.system.showinstalled(specification)
- specification = interfaces.checkedspecification(specification)
+local function allfiles(specification)
local pattern = lower(specification.pattern or "")
local list = fonts.names.list(pattern,false,true)
if list then
@@ -45,6 +44,14 @@ function moduledata.fonts.system.showinstalled(specification)
for k, v in next, list do
files[file.basename(string.lower(v.filename))] = v
end
+ return files
+ end
+end
+
+function moduledata.fonts.system.showinstalled(specification)
+ specification = interfaces.checkedspecification(specification)
+ local files = allfiles(specification)
+ if files then
context.starttabulate { "|Tl|Tl|Tl|Tl|Tl|Tl|" }
HL()
NC() bold("filename")
@@ -67,3 +74,31 @@ function moduledata.fonts.system.showinstalled(specification)
context.stoptabulate()
end
end
+
+function moduledata.fonts.system.cacheinstalled(specification)
+ specification = interfaces.checkedspecification(specification)
+ local files = allfiles(specification)
+ if files then
+ local threshold = tonumber(specification.threshold)
+ for filename, data in table.sortedpairs(files) do
+ if string.find(filename," ") then
+ -- skip this one
+ else
+ local s = file.suffix(filename)
+ if s == "otf" or s == "ttf" then
+ local fullname = resolvers.findfile(filename)
+ context.start()
+ context.type(fullname)
+ context.par()
+ if threshold and file.size(fullname) > threshold then
+ logs.report("fonts","ignoring : %s",fullname)
+ else
+ logs.report("fonts","caching : %s",fullname)
+ context.definedfont { filename }
+ end
+ context.stop()
+ end
+ end
+ end
+ end
+end
diff --git a/tex/context/modules/mkiv/s-fonts-system.mkiv b/tex/context/modules/mkiv/s-fonts-system.mkiv
index 6d9082a6b..a9d33d27e 100644
--- a/tex/context/modules/mkiv/s-fonts-system.mkiv
+++ b/tex/context/modules/mkiv/s-fonts-system.mkiv
@@ -24,7 +24,8 @@
\registerctxluafile{s-fonts-system}{}
-\installmodulecommandluasingle \showinstalledfonts {moduledata.fonts.system.showinstalled}
+\installmodulecommandluasingle \showinstalledfonts {moduledata.fonts.system.showinstalled}
+\installmodulecommandluasingle \cacheinstalledfonts {moduledata.fonts.system.cacheinstalled}
\stopmodule
@@ -34,6 +35,7 @@
\starttext
- \showinstalledfonts
+% \showinstalledfonts
+ \cacheinstalledfonts[threshold=4000000]
\stoptext
diff --git a/tex/context/modules/mkiv/s-xml-analyzers.lua b/tex/context/modules/mkiv/s-xml-analyzers.lua
index 6e7f7f2ba..93c6c37b6 100644
--- a/tex/context/modules/mkiv/s-xml-analyzers.lua
+++ b/tex/context/modules/mkiv/s-xml-analyzers.lua
@@ -230,6 +230,12 @@ local f_template = formatters [ [[
%% setups
+\xmlregistersetup{xml:presets:all}
+
+\starttext
+ \xmlprocessfile{main}{somefile.xml}{}
+\stoptext
+
%s
]] ]