diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
commit | d7ccb42582f85acf30568913610ccf4d602023fb (patch) | |
tree | 7292e3545a420676878e7451b68892d360c62cb6 /Master/texmf-dist/tex/context/base/math-ini.lua | |
parent | 2d62a6fe9b80def59c392268022f1f9a2d6e358f (diff) |
commit context 2011.05.18
git-svn-id: svn://tug.org/texlive/trunk@22719 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/math-ini.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/math-ini.lua | 197 |
1 files changed, 112 insertions, 85 deletions
diff --git a/Master/texmf-dist/tex/context/base/math-ini.lua b/Master/texmf-dist/tex/context/base/math-ini.lua index 63d7cad3852..a122f722975 100644 --- a/Master/texmf-dist/tex/context/base/math-ini.lua +++ b/Master/texmf-dist/tex/context/base/math-ini.lua @@ -9,22 +9,26 @@ if not modules then modules = { } end modules ['math-ext'] = { -- if needed we can use the info here to set up xetex definition files -- the "8000 hackery influences direct characters (utf) as indirect \char's -local utf = unicode.utf8 - local texsprint, format, utfchar, utfbyte = tex.sprint, string.format, utf.char, utf.byte +local setmathcode, setdelcode = tex.setmathcode, tex.setdelcode + +local allocate = utilities.storage.allocate local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end) -mathematics = mathematics or { } +local report_math = logs.reporter("mathematics","initializing") + +mathematics = mathematics or { } +local mathematics = mathematics mathematics.extrabase = 0xFE000 -- here we push some virtuals mathematics.privatebase = 0xFF000 -- here we push the ex -local families = { - tf = 0, it = 1, sl = 2, bf = 3, bi = 4, bs = 5, -- virtual fonts or unicode otf +local families = allocate { + tf = 0, it = 1, sl = 2, bf = 3, bi = 4, bs = 5, -- no longer relevant } -local classes = { +local classes = allocate { ord = 0, -- mathordcomm mathord op = 1, -- mathopcomm mathop bin = 2, -- mathbincomm mathbin @@ -94,77 +98,127 @@ end local function mathtopaccent(class,family,slot) return format('\\Umathaccent "%X "%X "%X ',0,family,slot) -- no class end -local function mathbotaccent(class,family,slot) - return format('\\Umathbotaccent "%X "%X "%X ',0,family,slot) -- no class +if tex.luatexversion > 65 then -- this will disappear at 0.70 + local function mathbotaccent(class,family,slot) + return format('\\Umathaccent bottom "%X "%X "%X ',0,family,slot) -- no class + end +else + local function mathbotaccent(class,family,slot) + return format('\\Umathbotaccent "%X "%X "%X ',0,family,slot) -- no class + end end local function mathtopdelimiter(class,family,slot) - return format('\\Uoverdelimiter "%X "%X ',0,family,slot) -- no class + return format('\\Udelimiterover "%X "%X ',family,slot) -- no class end local function mathbotdelimiter(class,family,slot) - return format('\\Uunderdelimiter "%X "%X ',0,family,slot) -- no class + return format('\\Udelimiterunder "%X "%X ',family,slot) -- no class end local escapes = characters.filters.utf.private.escapes -local function setmathsymbol(name,class,family,slot) - if class == classes.accent then - texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,mathaccent(class,family,slot))) - elseif class == classes.topaccent then - texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,mathtopaccent(class,family,slot))) - elseif class == classes.botaccent then - texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,mathbotaccent(class,family,slot))) - elseif class == classes.over then - texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,mathtopdelimiter(class,family,slot))) - elseif class == classes.under then - texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,mathbotdelimiter(class,family,slot))) - elseif class == classes.open or class == classes.close then - texsprint(delcode(slot,family,slot)) - texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,delimiter(class,family,slot))) - elseif class == classes.delimiter then - texsprint(delcode(slot,family,slot)) - texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,delimiter(0,family,slot))) - elseif class == classes.radical then - texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,radical(family,slot))) - else - -- beware, open/close and other specials should not end up here ---~ local ch = utfchar(slot) ---~ if escapes[ch] then ---~ texsprint(format("\\xdef\\%s{\\char%s }",name,slot)) ---~ else - texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,mathchar(class,family,slot))) ---~ end +local setmathcharacter, setmathsynonym, setmathsymbol -- once updated we will inline them + +if setmathcode then + + setmathcharacter = function(class,family,slot,unicode,firsttime) + if not firsttime and class <= 7 then + setmathcode(slot,{class,family,unicode or slot}) + end end -end -local function setmathcharacter(class,family,slot,unicode,firsttime) - if not firsttime and class <= 7 then - texsprint(mathcode(slot,class,family,unicode or slot)) + setmathsynonym = function(class,family,slot,unicode,firsttime) + if not firsttime and class <= 7 then + setmathcode(slot,{class,family,unicode}) + end + if class == classes.open or class == classes.close then + setdelcode(slot,{family,unicode,0,0}) + end end -end -local function setmathsynonym(class,family,slot,unicode,firsttime) - if not firsttime and class <= 7 then - texsprint(mathcode(slot,class,family,unicode)) + setmathsymbol = function(name,class,family,slot) -- hex is nicer for tracing + if class == classes.accent then + texsprint(format([[\unexpanded\gdef\%s{\Umathaccent 0 "%X "%X }]],name,family,slot)) + elseif class == classes.topaccent then + texsprint(format([[\unexpanded\gdef\%s{\Umathaccent 0 "%X "%X }]],name,family,slot)) + elseif class == classes.botaccent then + texsprint(format([[\unexpanded\gdef\%s{\Umathbotaccent 0 "%X "%X }]],name,family,slot)) + elseif class == classes.over then + texsprint(format([[\unexpanded\gdef\%s{\Udelimiterover "%X "%X }]],name,family,slot)) + elseif class == classes.under then + texsprint(format([[\unexpanded\gdef\%s{\Udelimiterunder "%X "%X }]],name,family,slot)) + elseif class == classes.open or class == classes.close then + setdelcode(slot,{family,slot,0,0}) + texsprint(format([[\unexpanded\gdef\%s{\Udelimiter "%X "%X "%X }]],name,class,family,slot)) + elseif class == classes.delimiter then + setdelcode(slot,{family,slot,0,0}) + texsprint(format([[\unexpanded\gdef\%s{\Udelimiter 0 "%X "%X }]],name,family,slot)) + elseif class == classes.radical then + texsprint(format([[\unexpanded\gdef\%s{\Uradical "%X "%X }]],name,family,slot)) + else + -- beware, open/close and other specials should not end up here + texsprint(format([[\unexpanded\gdef\%s{\Umathchar "%X "%X "%X }]],name,class,family,slot)) + end + end + + +else + + setmathcharacter = function(class,family,slot,unicode,firsttime) + if not firsttime and class <= 7 then + texsprint(mathcode(slot,class,family,unicode or slot)) + end + end + + setmathsynonym = function(class,family,slot,unicode,firsttime) + if not firsttime and class <= 7 then + texsprint(mathcode(slot,class,family,unicode)) + end + if class == classes.open or class == classes.close then + texsprint(delcode(slot,family,unicode)) + end end - if class == classes.open or class == classes.close then - texsprint(delcode(slot,family,unicode)) + + setmathsymbol = function(name,class,family,slot) + if class == classes.accent then + texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,mathaccent(class,family,slot))) + elseif class == classes.topaccent then + texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,mathtopaccent(class,family,slot))) + elseif class == classes.botaccent then + texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,mathbotaccent(class,family,slot))) + elseif class == classes.over then + texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,mathtopdelimiter(class,family,slot))) + elseif class == classes.under then + texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,mathbotdelimiter(class,family,slot))) + elseif class == classes.open or class == classes.close then + texsprint(delcode(slot,family,slot)) + texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,delimiter(class,family,slot))) + elseif class == classes.delimiter then + texsprint(delcode(slot,family,slot)) + texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,delimiter(0,family,slot))) + elseif class == classes.radical then + texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,radical(family,slot))) + else + -- beware, open/close and other specials should not end up here + texsprint(format("\\unexpanded\\xdef\\%s{%s}",name,mathchar(class,family,slot))) + end end + end local function report(class,family,unicode,name) local nametype = type(name) if nametype == "string" then - logs.report("mathematics","%s:%s %s U+%05X (%s) => %s",classname,class,family,unicode,utfchar(unicode),name) + report_math("%s:%s %s U+%05X (%s) => %s",classname,class,family,unicode,utfchar(unicode),name) elseif nametype == "number" then - logs.report("mathematics","%s:%s %s U+%05X (%s) => U+%05X",classname,class,family,unicode,utfchar(unicode),name) + report_math("%s:%s %s U+%05X (%s) => U+%05X",classname,class,family,unicode,utfchar(unicode),name) else - logs.report("mathematics","%s:%s %s U+%05X (%s)", classname,class,family,unicode,utfchar(unicode)) + report_math("%s:%s %s U+%05X (%s)", classname,class,family,unicode,utfchar(unicode)) end end -- there will be a combined \(math)chardef -function mathematics.define(slots,family) +function mathematics.define(family) family = family or 0 family = families[family] or family local data = characters.data @@ -209,14 +263,12 @@ function mathematics.define(slots,family) report(class,family,unicode,name) end setmathsymbol(name,class,family,unicode) - -- setmathcharacter(class,family,unicode,unicode,i) else name = class == classes.variable or class == classes.number and character.adobename if name then if trace_defining then report(class,family,unicode,name) end - -- setmathcharacter(class,family,unicode,unicode,i) end end setmathcharacter(class,family,unicode,unicode,i) @@ -262,19 +314,21 @@ end function mathematics.utfmathcommand(chr, default) local cd = characters.data[utfbyte(chr)] local cmd = cd and cd.mathname - tex.sprint(cmd or default or "") + return cmd or default or "" end function mathematics.utfmathfiller(chr, default) local cd = characters.data[utfbyte(chr)] local cmd = cd and (cd.mathfiller or cd.mathname) - tex.sprint(cmd or default or "") + return cmd or default or "" end -mathematics.entities = mathematics.entities or { } +-- xml -function mathematics.register_xml_entities() +mathematics.xml = { entities = { } } + +function mathematics.xml.registerentities() local entities = xml.entities - for name, unicode in next, mathematics.entities do + for name, unicode in next, mathematics.xml.entities do if not entities[name] then entities[name] = utfchar(unicode) end @@ -311,30 +365,3 @@ function mathematics.big(tfmdata,unicode,n) return unicode end --- plugins - -local hvars = table.tohash { - --~ "RadicalKernBeforeDegree", - --~ "RadicalKernAfterDegree", -} - -function mathematics.scaleparameters(t,tfmtable,delta,hdelta,vdelta) - local math_parameters = tfmtable.math_parameters - if math_parameters and next(math_parameters) then - delta = delta or 1 - hdelta, vdelta = hdelta or delta, vdelta or delta - local _, mp = mathematics.dimensions(math_parameters) - for name, value in next, mp do - if name == "RadicalDegreeBottomRaisePercent" then - mp[name] = value - elseif hvars[name] then - mp[name] = hdelta * value - else - mp[name] = vdelta * value - end - end - t.MathConstants = mp - end -end - -table.insert(fonts.tfm.mathactions,mathematics.scaleparameters) |