summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-04-16 13:13:20 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2018-04-16 13:13:20 +0200
commitd57683f5f67d6651f7b3353ff347ae57a409e0d4 (patch)
tree1ffc5bda90e3eedad0a35eaa8937472f5563c796 /tex
parentd5d5a39dc16881d098a99b74cba9020d96be4e11 (diff)
downloadcontext-d57683f5f67d6651f7b3353ff347ae57a409e0d4.tar.gz
2018-04-16 12:13:00
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/mkii/cont-new.mkii2
-rw-r--r--tex/context/base/mkii/context.mkii2
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/l-os.lua2
-rw-r--r--tex/context/base/mkiv/mlib-ctx.lua6
-rw-r--r--tex/context/base/mkiv/mlib-lua.lua47
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin26106 -> 26106 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin255834 -> 256772 bytes
-rw-r--r--tex/context/base/mkiv/util-sto.lua3
-rw-r--r--tex/context/base/mkiv/util-str.lua65
-rw-r--r--tex/context/interface/mkiv/i-context.pdfbin847277 -> 847126 bytes
-rw-r--r--tex/context/interface/mkiv/i-readme.pdfbin61032 -> 61031 bytes
-rw-r--r--tex/context/modules/mkiv/s-fonts-basics.mkiv2
-rw-r--r--tex/context/modules/mkiv/s-fonts-statistics.mkiv80
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua52
16 files changed, 204 insertions, 61 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii
index 49600d565..1c4691d8c 100644
--- a/tex/context/base/mkii/cont-new.mkii
+++ b/tex/context/base/mkii/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2018.04.15 23:11}
+\newcontextversion{2018.04.16 12:05}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii
index 644aca35c..d10d2d600 100644
--- a/tex/context/base/mkii/context.mkii
+++ b/tex/context/base/mkii/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2018.04.15 23:11}
+\edef\contextversion{2018.04.16 12:05}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index cc45fc559..e0353b955 100644
--- a/tex/context/base/mkiv/cont-new.mkiv
+++ b/tex/context/base/mkiv/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2018.04.15 23:11}
+\newcontextversion{2018.04.16 12:05}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv
index b08b78ef4..9a05525a1 100644
--- a/tex/context/base/mkiv/context.mkiv
+++ b/tex/context/base/mkiv/context.mkiv
@@ -42,7 +42,7 @@
%D has to match \type {YYYY.MM.DD HH:MM} format.
\edef\contextformat {\jobname}
-\edef\contextversion{2018.04.15 23:11}
+\edef\contextversion{2018.04.16 12:05}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/l-os.lua b/tex/context/base/mkiv/l-os.lua
index bf13baaa6..b4b1a8645 100644
--- a/tex/context/base/mkiv/l-os.lua
+++ b/tex/context/base/mkiv/l-os.lua
@@ -254,7 +254,7 @@ elseif name == "linux" then
function resolvers.platform(t,k)
-- we sometimes have HOSTTYPE set so let's check that first
local architecture = os.getenv("HOSTTYPE") or resultof("uname -m") or ""
- local platform = os.getenv("MTX_PLATFORM")
+ local platform = os.getenv("MTX_PLATFORM") or ""
local musl = find(os.selfdir or "","linuxmusl")
if platform ~= "" then
-- we're done
diff --git a/tex/context/base/mkiv/mlib-ctx.lua b/tex/context/base/mkiv/mlib-ctx.lua
index c568b92a3..b51c4fd9d 100644
--- a/tex/context/base/mkiv/mlib-ctx.lua
+++ b/tex/context/base/mkiv/mlib-ctx.lua
@@ -337,17 +337,17 @@ implement {
}
}
-statistics.register("metapost processing time", function()
+statistics.register("metapost", function()
local n = metapost.n
if n and n > 0 then
local nofconverted = metapost.makempy.nofconverted
local elapsedtime = statistics.elapsedtime
local elapsed = statistics.elapsed
local instances, memory = metapost.getstatistics(true)
- local str = format("%s seconds, loading: %s, execution: %s, n: %s, average: %s, instances: %i, memory: %0.3f M",
+ local str = format("%s seconds, loading: %s, execution: %s, n: %s, average: %s, instances: %i, luacalls: %i, memory: %0.3f M",
elapsedtime(metapost), elapsedtime(mplib), elapsedtime(metapost.exectime), n,
elapsedtime((elapsed(metapost) + elapsed(mplib) + elapsed(metapost.exectime)) / n),
- instances, memory/(1024*1024))
+ instances, metapost.nofscriptruns(),memory/(1024*1024))
if nofconverted > 0 then
return format("%s, external: %s (%s calls)",
str, elapsedtime(metapost.makempy), nofconverted)
diff --git a/tex/context/base/mkiv/mlib-lua.lua b/tex/context/base/mkiv/mlib-lua.lua
index d934e6472..189f207c7 100644
--- a/tex/context/base/mkiv/mlib-lua.lua
+++ b/tex/context/base/mkiv/mlib-lua.lua
@@ -359,35 +359,36 @@ end
-- endfor ;
-- \stopMPpage
-local cache, n = { }, 0 -- todo: when > n then reset cache or make weak
+local runs = 0
+
+function metapost.nofscriptruns()
+ return runs
+end
+
+-- local cache = table.makeweak()
+--
+-- f = cache[code]
+-- if not f then
+-- f = loadstring(f_code(code))
+-- if f then
+-- cache[code] = f
+-- elseif be_tolerant then
+-- f = loadstring(code)
+-- if f then
+-- cache[code] = f
+-- end
+-- end
+-- end
function metapost.runscript(code)
local trace = trace_enabled and trace_luarun
if trace then
report_luarun("code: %s",code)
end
- local f
- if n > 100 then
- cache = nil -- forget about caching
- f = loadstring(f_code(code))
- if not f and be_tolerant then
- f = loadstring(code)
- end
- else
- f = cache[code]
- if not f then
- f = loadstring(f_code(code))
- if f then
- n = n + 1
- cache[code] = f
- elseif be_tolerant then
- f = loadstring(code)
- if f then
- n = n + 1
- cache[code] = f
- end
- end
- end
+ runs = runs + 1
+ local f = loadstring(f_code(code))
+ if not f and be_tolerant then
+ f = loadstring(code)
end
if f then
local result = f()
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 44f2a3e83..489383f73 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index 6ac2e451c..f0e3e40b0 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/util-sto.lua b/tex/context/base/mkiv/util-sto.lua
index 0da685e9f..a08d25ced 100644
--- a/tex/context/base/mkiv/util-sto.lua
+++ b/tex/context/base/mkiv/util-sto.lua
@@ -197,6 +197,9 @@ function table.getmetatablekey(t,key,value)
end
function table.makeweak(t)
+ if not t then
+ t = { }
+ end
local m = getmetatable(t)
if m then
m.__mode = "v"
diff --git a/tex/context/base/mkiv/util-str.lua b/tex/context/base/mkiv/util-str.lua
index 05ff9f304..56c5b011c 100644
--- a/tex/context/base/mkiv/util-str.lua
+++ b/tex/context/base/mkiv/util-str.lua
@@ -412,25 +412,46 @@ end
local digit = patterns.digit
local period = patterns.period
-local three = digit * digit * digit
+local two = digit * digit
+local three = two * digit
+local prefix = (Carg(1) * three)^1
+
local splitter = Cs (
- (((1 - (three^1 * period))^1 + C(three)) * (Carg(1) * three)^1 + C((1-period)^1))
+ (((1 - (three^1 * period))^1 + C(three)) * prefix + C((1-period)^1))
* (P(1)/"" * Carg(2)) * C(2)
)
+local splitter3 = Cs (
+ three * prefix * P(-1) +
+ two * prefix * P(-1) +
+ digit * prefix * P(-1) +
+ three +
+ two +
+ digit
+)
+
patterns.formattednumber = splitter
function number.formatted(n,sep1,sep2)
- local s = type(s) == "string" and n or format("%0.2f",n)
- if sep1 == true then
- return lpegmatch(splitter,s,1,".",",")
- elseif sep1 == "." then
- return lpegmatch(splitter,s,1,sep1,sep2 or ",")
- elseif sep1 == "," then
- return lpegmatch(splitter,s,1,sep1,sep2 or ".")
+ if sep1 == false then
+ if type(n) == "number" then
+ n = tostring(n)
+ end
+ return lpegmatch(splitter3,n,1,sep2 or ".")
else
- return lpegmatch(splitter,s,1,sep1 or ",",sep2 or ".")
+ if type(n) == "number" then
+ n = format("%0.2f",n)
+ end
+ if sep1 == true then
+ return lpegmatch(splitter,n,1,".",",")
+ elseif sep1 == "." then
+ return lpegmatch(splitter,n,1,sep1,sep2 or ",")
+ elseif sep1 == "," then
+ return lpegmatch(splitter,n,1,sep1,sep2 or ".")
+ else
+ return lpegmatch(splitter,n,1,sep1 or ",",sep2 or ".")
+ end
end
end
@@ -443,6 +464,14 @@ end
-- print(number.formatted(1234567))
-- print(number.formatted(12345678))
-- print(number.formatted(12345678,true))
+-- print(number.formatted(1,false))
+-- print(number.formatted(12,false))
+-- print(number.formatted(123,false))
+-- print(number.formatted(1234,false))
+-- print(number.formatted(12345,false))
+-- print(number.formatted(123456,false))
+-- print(number.formatted(1234567,false))
+-- print(number.formatted(12345678,false))
-- print(number.formatted(1234.56,"!","?"))
local p = Cs(
@@ -882,7 +911,11 @@ local format_m = function(f)
if not f or f == "" then
f = ","
end
- return format([[formattednumber(a%s,%q,".")]],n,f)
+ if f == "0" then
+ return format([[formattednumber(a%s,false)]],n)
+ else
+ return format([[formattednumber(a%s,%q,".")]],n,f)
+ end
end
local format_M = function(f)
@@ -890,7 +923,11 @@ local format_M = function(f)
if not f or f == "" then
f = "."
end
- return format([[formattednumber(a%s,%q,",")]],n,f)
+ if f == "0" then
+ return format([[formattednumber(a%s,false)]],n)
+ else
+ return format([[formattednumber(a%s,%q,",")]],n,f)
+ end
end
--
@@ -1029,8 +1066,8 @@ local builder = Cs { "start",
["j"] = (prefix_any * P("j")) / format_j, -- %j => %e (float) stripped exponent (irrational)
["J"] = (prefix_any * P("J")) / format_J, -- %J => %E (float) stripped exponent (irrational)
--
- ["m"] = (prefix_tab * P("m")) / format_m, -- %m => xxx.xxx.xxx,xx (optional prefix instead of .)
- ["M"] = (prefix_tab * P("M")) / format_M, -- %M => xxx,xxx,xxx.xx (optional prefix instead of ,)
+ ["m"] = (prefix_any * P("m")) / format_m, -- %m => xxx.xxx.xxx,xx (optional prefix instead of .)
+ ["M"] = (prefix_any * P("M")) / format_M, -- %M => xxx,xxx,xxx.xx (optional prefix instead of ,)
--
["z"] = (prefix_any * P("z")) / format_z, -- %z => skip n arguments
--
diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf
index cb4dc61e3..3e39f95c8 100644
--- a/tex/context/interface/mkiv/i-context.pdf
+++ b/tex/context/interface/mkiv/i-context.pdf
Binary files differ
diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf
index f7bfb2747..5cf37dc48 100644
--- a/tex/context/interface/mkiv/i-readme.pdf
+++ b/tex/context/interface/mkiv/i-readme.pdf
Binary files differ
diff --git a/tex/context/modules/mkiv/s-fonts-basics.mkiv b/tex/context/modules/mkiv/s-fonts-basics.mkiv
index e9d0a21a2..370be3598 100644
--- a/tex/context/modules/mkiv/s-fonts-basics.mkiv
+++ b/tex/context/modules/mkiv/s-fonts-basics.mkiv
@@ -1,5 +1,5 @@
%D \module
-%D [ file=s-fnt-01,
+%D [ file=s-fonts-basics, % was s-fnt-01,
%D version=2006.10.10, % guess
%D title=\CONTEXT\ Style File,
%D subtitle=Listing Glyphs in Large Fonts,
diff --git a/tex/context/modules/mkiv/s-fonts-statistics.mkiv b/tex/context/modules/mkiv/s-fonts-statistics.mkiv
new file mode 100644
index 000000000..3b5cddd3c
--- /dev/null
+++ b/tex/context/modules/mkiv/s-fonts-statistics.mkiv
@@ -0,0 +1,80 @@
+%D \module
+%D [ file=s-fonts-statistics,
+%D version=2018.03.21, % guess
+%D title=\CONTEXT\ Style File,
+%D subtitle=Listing font statistics,
+%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.
+
+\startmodule[fonts-statistics]
+
+\startluacode
+
+moduledata.fonts = moduledata.fonts or { }
+moduledata.fonts.statistics = moduledata.fonts.statistics or { }
+
+local context = context
+local ctx_NC, ctx_BC, ctx_NR = context.NC, context.BC, context.NR
+
+function moduledata.fonts.statistics.showusage()
+ local t = table.load(tex.jobname.."-fonts-usage.lua")
+ if t then
+ local totalinstances = 0
+ local totalfilesize = 0
+ local totalfilenames = #t
+ if totalfilenames > 0 then
+ context.starttabulate { "|r|r|c||" }
+ context.FL()
+ ctx_BC() context("used")
+ ctx_BC() context("filesize")
+ ctx_BC() context("version")
+ ctx_BC() context("filename")
+ ctx_NR()
+ context.ML()
+ for i=1,#t do
+ local ti = t[i]
+ local version = tonumber(string.match(ti.version or "","^.-([%d%.]+)"))
+ local instances = ti.instances or 1
+ local filename = file.basename(ti.filename) or "unknown"
+ local filesize = ti.size or 0
+ totalinstances = totalinstances + instances
+ totalfilesize = totalfilesize + filesize
+ ctx_NC() context(instances)
+ ctx_NC() context("%0m",filesize)
+ ctx_NC() if version then context("%0.3f",version) end
+ ctx_NC() context.type(filename)
+ ctx_NR()
+ end
+ context.LL()
+ ctx_BC() context(totalinstances)
+ ctx_BC() context("%0m",totalfilesize)
+ ctx_BC() context()
+ ctx_BC() context("%i files loaded",totalfilenames)
+ ctx_NR()
+ context.stoptabulate()
+ end
+ end
+end
+
+\stopluacode
+
+\installmodulecommandluasingle \showfontusage {moduledata.fonts.statistics.showusage}
+
+\stopmodule
+
+\continueifinputfile{s-fonts-statistics.mkiv}
+
+\enabletrackers[fonts.usage]
+
+\starttext
+
+ \input klein
+
+ \showfontusage
+
+\stoptext
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 6829fd982..519590bf8 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua
-- parent file : c:/data/develop/context/sources/luatex-fonts.lua
--- merge date : 04/15/18 23:11:48
+-- merge date : 04/16/18 12:05:06
do -- begin closure to overcome local limits and interference
@@ -3974,21 +3974,35 @@ function number.signed(i)
end
local digit=patterns.digit
local period=patterns.period
-local three=digit*digit*digit
+local two=digit*digit
+local three=two*digit
+local prefix=(Carg(1)*three)^1
local splitter=Cs (
- (((1-(three^1*period))^1+C(three))*(Carg(1)*three)^1+C((1-period)^1))*(P(1)/""*Carg(2))*C(2)
+ (((1-(three^1*period))^1+C(three))*prefix+C((1-period)^1))*(P(1)/""*Carg(2))*C(2)
+)
+local splitter3=Cs (
+ three*prefix*P(-1)+two*prefix*P(-1)+digit*prefix*P(-1)+three+two+digit
)
patterns.formattednumber=splitter
function number.formatted(n,sep1,sep2)
- local s=type(s)=="string" and n or format("%0.2f",n)
- if sep1==true then
- return lpegmatch(splitter,s,1,".",",")
- elseif sep1=="." then
- return lpegmatch(splitter,s,1,sep1,sep2 or ",")
- elseif sep1=="," then
- return lpegmatch(splitter,s,1,sep1,sep2 or ".")
+ if sep1==false then
+ if type(n)=="number" then
+ n=tostring(n)
+ end
+ return lpegmatch(splitter3,n,1,sep2 or ".")
else
- return lpegmatch(splitter,s,1,sep1 or ",",sep2 or ".")
+ if type(n)=="number" then
+ n=format("%0.2f",n)
+ end
+ if sep1==true then
+ return lpegmatch(splitter,n,1,".",",")
+ elseif sep1=="." then
+ return lpegmatch(splitter,n,1,sep1,sep2 or ",")
+ elseif sep1=="," then
+ return lpegmatch(splitter,n,1,sep1,sep2 or ".")
+ else
+ return lpegmatch(splitter,n,1,sep1 or ",",sep2 or ".")
+ end
end
end
local p=Cs(
@@ -4347,14 +4361,22 @@ local format_m=function(f)
if not f or f=="" then
f=","
end
- return format([[formattednumber(a%s,%q,".")]],n,f)
+ if f=="0" then
+ return format([[formattednumber(a%s,false)]],n)
+ else
+ return format([[formattednumber(a%s,%q,".")]],n,f)
+ end
end
local format_M=function(f)
n=n+1
if not f or f=="" then
f="."
end
- return format([[formattednumber(a%s,%q,",")]],n,f)
+ if f=="0" then
+ return format([[formattednumber(a%s,false)]],n)
+ else
+ return format([[formattednumber(a%s,%q,",")]],n,f)
+ end
end
local format_z=function(f)
n=n+(tonumber(f) or 1)
@@ -4451,8 +4473,8 @@ local builder=Cs { "start",
["W"]=(prefix_any*P("W"))/format_W,
["j"]=(prefix_any*P("j"))/format_j,
["J"]=(prefix_any*P("J"))/format_J,
- ["m"]=(prefix_tab*P("m"))/format_m,
- ["M"]=(prefix_tab*P("M"))/format_M,
+ ["m"]=(prefix_any*P("m"))/format_m,
+ ["M"]=(prefix_any*P("M"))/format_M,
["z"]=(prefix_any*P("z"))/format_z,
["a"]=(prefix_any*P("a"))/format_a,
["A"]=(prefix_any*P("A"))/format_A,