summaryrefslogtreecommitdiff
path: root/tex/context/base/s-math-coverage.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/s-math-coverage.lua')
-rw-r--r--tex/context/base/s-math-coverage.lua223
1 files changed, 119 insertions, 104 deletions
diff --git a/tex/context/base/s-math-coverage.lua b/tex/context/base/s-math-coverage.lua
index a74e24450..3c6080dc3 100644
--- a/tex/context/base/s-math-coverage.lua
+++ b/tex/context/base/s-math-coverage.lua
@@ -6,135 +6,101 @@ if not modules then modules = { } end modules ['s-math-coverage'] = {
license = "see context related readme files"
}
-moduledata.math = moduledata.math or { }
-moduledata.math.coverage = moduledata.math.coverage or { }
-
local utfchar, utfbyte = utf.char, utf.byte
local formatters, lower = string.formatters, string.lower
local concat = table.concat
+local sortedhash = table.sortedhash
-local context = context
-local NC, NR, HL = context.NC, context.NR, context.HL
-local char, getglyph, bold = context.char, context.getglyph, context.bold
+moduledata.math = moduledata.math or { }
+moduledata.math.coverage = moduledata.math.coverage or { }
-local ucgreek = {
- 0x0391, 0x0392, 0x0393, 0x0394, 0x0395,
- 0x0396, 0x0397, 0x0398, 0x0399, 0x039A,
- 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
- 0x03A0, 0x03A1, 0x03A3, 0x03A4, 0x03A5,
- 0x03A6, 0x03A7, 0x03A8, 0x03A9
-}
+local context = context
-local lcgreek = {
- 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5,
- 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA,
- 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
- 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4,
- 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9,
- 0x03D1, 0x03D5, 0x03D6, 0x03F0, 0x03F1,
- 0x03F4, 0x03F5
-}
+local ctx_NC = context.NC
+local ctx_NR = context.NR
+local ctx_HL = context.HL
-local ucletters = {
- 0x00041, 0x00042, 0x00043, 0x00044, 0x00045,
- 0x00046, 0x00047, 0x00048, 0x00049, 0x0004A,
- 0x0004B, 0x0004C, 0x0004D, 0x0004E, 0x0004F,
- 0x00050, 0x00051, 0x00052, 0x00053, 0x00054,
- 0x00055, 0x00056, 0x00057, 0x00058, 0x00059,
- 0x0005A,
-}
+local ctx_startmixedcolumns = context.startmixedcolumns
+local ctx_stopmixedcolumns = context.stopmixedcolumns
+local ctx_setupalign = context.setupalign
+local ctx_starttabulate = context.starttabulate
+local ctx_stoptabulate = context.stoptabulate
+local ctx_rawmathematics = context.formatted.rawmathematics
+local ctx_mathematics = context.formatted.mathematics
+local ctx_startimath = context.startimath
+local ctx_stopimath = context.stopimath
+local ctx_setmathattribute = context.setmathattribute
+local ctx_underbar = context.underbar
+local ctx_getglyph = context.getglyph
-local lcletters = {
- 0x00061, 0x00062, 0x00063, 0x00064, 0x00065,
- 0x00066, 0x00067, 0x00068, 0x00069, 0x0006A,
- 0x0006B, 0x0006C, 0x0006D, 0x0006E, 0x0006F,
- 0x00070, 0x00071, 0x00072, 0x00073, 0x00074,
- 0x00075, 0x00076, 0x00077, 0x00078, 0x00079,
- 0x0007A,
-}
+local styles = mathematics.styles
+local alternatives = mathematics.alternatives
+local charactersets = mathematics.charactersets
-local digits = {
- 0x00030, 0x00031, 0x00032, 0x00033, 0x00034,
- 0x00035, 0x00036, 0x00037, 0x00038, 0x00039,
-}
+local getboth = mathematics.getboth
+local remapalphabets = mathematics.remapalphabets
-local styles = {
- "regular", "sansserif", "monospaced", "fraktur", "script", "blackboard"
-}
-
-local alternatives = {
- "normal", "bold", "italic", "bolditalic"
-}
-
-local alphabets = {
- ucletters, lcletters, ucgreek, lcgreek, digits,
-}
-
-local getboth = mathematics.getboth
-local remapalphabets = mathematics.remapalphabets
-
-local chardata = characters.data
-local superscripts = characters.superscripts
-local subscripts = characters.subscripts
+local chardata = characters.data
+local superscripts = characters.superscripts
+local subscripts = characters.subscripts
context.writestatus("math coverage","underline: not remapped")
function moduledata.math.coverage.showalphabets()
- context.starttabulate { "|lT|l|Tl|" }
+ ctx_starttabulate { "|lT|l|Tl|" }
for i=1,#styles do
local style = styles[i]
for i=1,#alternatives do
local alternative = alternatives[i]
- for i=1,#alphabets do
- local alphabet = alphabets[i]
- NC()
+ for _, alphabet in sortedhash(charactersets) do
+ ctx_NC()
if i == 1 then
context("%s %s",style,alternative)
end
- NC()
- context.startimath()
- context.setmathattribute(style,alternative)
+ ctx_NC()
+ ctx_startimath()
+ ctx_setmathattribute(style,alternative)
for i=1,#alphabet do
local letter = alphabet[i]
local id = getboth(style,alternative)
local unicode = remapalphabets(letter,id)
if not unicode then
- context.underbar(utfchar(letter))
+ ctx_underbar(utfchar(letter))
elseif unicode == letter then
context(utfchar(unicode))
else
context(utfchar(unicode))
end
end
- context.stopimath()
- NC()
+ ctx_stopimath()
+ ctx_NC()
local first = alphabet[1]
local last = alphabet[#alphabet]
local id = getboth(style,alternative)
local f_unicode = remapalphabets(first,id) or utfbyte(first)
local l_unicode = remapalphabets(last,id) or utfbyte(last)
context("%05X - %05X",f_unicode,l_unicode)
- NC()
- NR()
+ ctx_NC()
+ ctx_NR()
end
end
end
- context.stoptabulate()
+ ctx_stoptabulate()
end
function moduledata.math.coverage.showcharacters()
- context.startcolumns()
- context.setupalign { "nothyphenated" }
- context.starttabulate { "|T|i2|Tpl|" }
- for u, d in table.sortedpairs(chardata) do
+ ctx_startmixedcolumns { balance = "yes" }
+ ctx_setupalign { "nothyphenated" }
+ ctx_starttabulate { "|T|i2|Tpl|" }
+ for u, d in sortedhash(chardata) do
local mathclass = d.mathclass
local mathspec = d.mathspec
if mathclass or mathspec then
- NC()
+ ctx_NC()
context("%05X",u)
- NC()
- getglyph("MathRoman",u)
- NC()
+ ctx_NC()
+ ctx_getglyph("MathRoman",u)
+ ctx_NC()
if mathspec then
local t = { }
for i=1,#mathspec do
@@ -145,38 +111,87 @@ function moduledata.math.coverage.showcharacters()
else
context(mathclass)
end
- NC()
- NR()
+ ctx_NC()
+ ctx_NR()
end
end
- context.stoptabulate()
- context.stopcolumns()
+ ctx_stoptabulate()
+ ctx_stopmixedcolumns()
end
-- This is a somewhat tricky table as we need to bypass the math machinery.
function moduledata.math.coverage.showscripts()
- context.starttabulate { "|cT|c|cT|c|c|c|l|" }
- for k, v in table.sortedpairs(table.merged(superscripts,subscripts)) do
+ ctx_starttabulate { "|cT|c|cT|c|c|c|l|" }
+ for k, v in sortedhash(table.merged(superscripts,subscripts)) do
local ck = utfchar(k)
local cv = utfchar(v)
local ss = superscripts[k] and "^" or "_"
- NC()
- context("%05X",k)
- NC()
- context(ck)
- NC()
- context("%05X",v)
- NC()
- context(cv)
- NC()
- context.formatted.rawmathematics("x%s = x%s%s",ck,ss,cv)
- NC()
- context.formatted.mathematics("x%s = x%s%s",ck,ss,cv)
- NC()
- context(lower(chardata[k].description))
- NC()
- NR()
+ ctx_NC() context("%05X",k)
+ ctx_NC() context(ck)
+ ctx_NC() context("%05X",v)
+ ctx_NC() context(cv)
+ ctx_NC() ctx_rawmathematics("x%s = x%s%s",ck,ss,cv)
+ ctx_NC() ctx_mathematics("x%s = x%s%s",ck,ss,cv)
+ ctx_NC() context(lower(chardata[k].description))
+ ctx_NC() ctx_NR()
+ end
+ ctx_stoptabulate()
+end
+
+-- Handy too.
+
+function moduledata.math.coverage.showbold()
+ ctx_starttabulate { "|lT|cm|lT|cm|lT|" }
+ for k, v in sortedhash(mathematics.boldmap) do
+ ctx_NC() context("%U",k)
+ ctx_NC() context("%c",k)
+ ctx_NC() context("%U",v)
+ ctx_NC() context("%c",v)
+ ctx_NC() context(chardata[k].description)
+ ctx_NC() ctx_NR()
end
- context.stoptabulate()
+ ctx_stoptabulate()
end
+
+-- function moduledata.math.coverage.showentities()
+-- ctx_startmixedcolumns { balance = "yes" }
+-- ctx_starttabulate { "|Tl|c|Tl|" }
+-- for k, v in sortedhash(characters.entities) do
+-- local b = utf.byte(v)
+-- local d = chardata[b]
+-- local m = d.mathname
+-- local c = d.contextname
+-- local s = ((m and "\\"..m) or (c and "\\".. c) or v) .. "{}{}{}"
+-- ctx_NC()
+-- context("%U",b)
+-- ctx_NC()
+-- ctx_mathematics(s)
+-- ctx_NC()
+-- context(k)
+-- ctx_NC()
+-- ctx_NR()
+-- end
+-- ctx_stoptabulate()
+-- ctx_stopmixedcolumns()
+-- end
+
+function moduledata.math.coverage.showentities()
+ ctx_startmixedcolumns { balance = "yes" }
+ ctx_starttabulate { "|T||T|T|" }
+ for k, v in sortedhash(characters.entities) do
+ local d = chardata[v]
+ if d then
+ local m = d.mathclass or d.mathspec
+ local u = d.unicodeslot
+ ctx_NC() context(m and "m" or "t")
+ ctx_NC() ctx_getglyph("MathRoman",u)
+ ctx_NC() context("%05X",u)
+ ctx_NC() context(k)
+ ctx_NC() ctx_NR()
+ end
+ end
+ ctx_stoptabulate()
+ ctx_stopmixedcolumns()
+end
+