From 25fc028ca9e811187704cf2de2ba0d0bb9846b67 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Thu, 9 Apr 2015 21:15:05 +0200 Subject: 2015-04-09 20:58:00 --- metapost/context/base/mp-mlib.mpiv | 50 ++++++-- tex/context/base/char-def.lua | 1 + tex/context/base/char-ent.lua | 10 +- tex/context/base/char-tex.lua | 45 ++++--- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4178 -> 4186 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/enco-ini.mkiv | 4 + tex/context/base/font-con.lua | 22 ++++ tex/context/base/font-ext.lua | 13 ++ tex/context/base/font-otf.lua | 33 ++++-- tex/context/base/java-imp-fld.mkiv | 33 +++--- tex/context/base/java-ini.mkiv | 6 +- tex/context/base/lang-txt.lua | 20 ++-- tex/context/base/lxml-ini.lua | 2 +- tex/context/base/m-chart.mkvi | 1 - tex/context/base/m-visual.mkiv | 2 +- tex/context/base/math-act.lua | 2 + tex/context/base/meta-pag.mkiv | 2 +- tex/context/base/mlib-lua.lua | 32 +++++ tex/context/base/mlib-pps.lua | 77 +++++++----- tex/context/base/mlib-run.lua | 2 +- tex/context/base/pack-bck.mkvi | 9 +- tex/context/base/pack-rul.lua | 10 +- tex/context/base/pack-rul.mkiv | 95 ++++++++------- tex/context/base/publ-imp-cite.mkvi | 6 +- tex/context/base/spac-ver.mkiv | 14 ++- tex/context/base/status-files.pdf | Bin 24544 -> 24522 bytes tex/context/base/status-lua.pdf | Bin 416994 -> 249889 bytes tex/context/base/syst-ini.mkiv | 15 +-- tex/context/base/tabl-ntb.mkiv | 2 +- tex/context/base/tabl-tab.mkiv | 3 +- tex/context/base/tabl-xtb.mkvi | 2 +- tex/context/base/trac-vis.lua | 3 +- tex/context/base/x-mathml.lua | 131 ++++++++++++--------- tex/context/base/x-mathml.mkiv | 31 +++-- tex/generic/context/luatex/luatex-fonts-merged.lua | 44 +++++-- 37 files changed, 464 insertions(+), 262 deletions(-) diff --git a/metapost/context/base/mp-mlib.mpiv b/metapost/context/base/mp-mlib.mpiv index 8f69546ec..b19f47f1e 100644 --- a/metapost/context/base/mp-mlib.mpiv +++ b/metapost/context/base/mp-mlib.mpiv @@ -134,7 +134,8 @@ enddef ; newinternal textextoffset ; textextoffset := 0 ; -numeric mfun_tt_w[], mfun_tt_h[], mfun_tt_d[] ; % we can consider using colors (less hash space) +%%%%%%% mfun_tt_w[], mfun_tt_h[], mfun_tt_d[] ; % we can consider using colors (less hash space) +color mfun_tt_b ; numeric mfun_tt_n ; mfun_tt_n := 0 ; picture mfun_tt_p ; mfun_tt_p := nullpicture ; picture mfun_tt_o ; mfun_tt_o := nullpicture ; @@ -175,6 +176,35 @@ extra_beginfig := extra_beginfig & "mfun_reset_tex_texts ;" ; % see mp-keep.mpiv for older code +% vardef rawtextext(expr s) = % todo: avoid currentpicture +% if s = "" : +% nullpicture +% else : +% mfun_tt_n := mfun_tt_n + 1 ; +% mfun_tt_c := nullpicture ; +% if mfun_trial_run : +% mfun_tt_o := nullpicture ; +% addto mfun_tt_o doublepath origin _op_ ; % save drawoptions +% addto mfun_tt_c doublepath unitsquare +% withprescript "tx_number=" & decimal mfun_tt_n +% withprescript "tx_stage=trial" +% withprescript "tx_color=" & colordecimals colorpart mfun_tt_o +% withpostscript s ; +% addto mfun_tt_p also mfun_tt_c ; +% elseif known mfun_tt_d[mfun_tt_n] : +% addto mfun_tt_c doublepath unitsquare +% xscaled mfun_tt_w[mfun_tt_n] +% yscaled (mfun_tt_h[mfun_tt_n] + mfun_tt_d[mfun_tt_n]) +% shifted (0,-mfun_tt_d[mfun_tt_n]) +% withprescript "tx_number=" & decimal mfun_tt_n +% withprescript "tx_stage=final" ; +% else : +% addto mfun_tt_c doublepath unitsquare ; % unitpicture +% fi ; +% mfun_tt_c +% fi +% enddef ; + vardef rawtextext(expr s) = % todo: avoid currentpicture if s = "" : nullpicture @@ -190,15 +220,14 @@ vardef rawtextext(expr s) = % todo: avoid currentpicture withprescript "tx_color=" & colordecimals colorpart mfun_tt_o withpostscript s ; addto mfun_tt_p also mfun_tt_c ; - elseif known mfun_tt_d[mfun_tt_n] : + else : + mfun_tt_b := lua.mp.tt_dimensions(mfun_tt_n) ; addto mfun_tt_c doublepath unitsquare - xscaled mfun_tt_w[mfun_tt_n] - yscaled (mfun_tt_h[mfun_tt_n] + mfun_tt_d[mfun_tt_n]) - shifted (0,-mfun_tt_d[mfun_tt_n]) + xscaled redpart mfun_tt_b + yscaled (greenpart mfun_tt_b + bluepart mfun_tt_b) + shifted (0,- bluepart mfun_tt_b) withprescript "tx_number=" & decimal mfun_tt_n withprescript "tx_stage=final" ; - else : - addto mfun_tt_c doublepath unitsquare ; % unitpicture fi ; mfun_tt_c fi @@ -1119,12 +1148,13 @@ numeric mfun_esc_b ; % begin numeric mfun_esc_l ; % length string mfun_esc_s ; % character -mfun_esc_s := str 37 ; +mfun_esc_s := "%" ; % or: char(37) % this one is the fastest when we have a match % vardef escaped_format(expr s) = % "" for n=0 upto length(s)-1 : & +% % if ASCII substring (n,n+1) of s = 37 : % if substring (n,n+1) of s = mfun_esc_s : % "@" % else : @@ -1139,6 +1169,7 @@ vardef escaped_format(expr s) = mfun_esc_b := 0 ; mfun_esc_l := length(s) ; for n=0 upto mfun_esc_l-1 : + % if ASCII substring (n,n+1) of s = 37 : if substring (n,n+1) of s = mfun_esc_s : if mfun_esc_b = 0 : "" @@ -1152,7 +1183,8 @@ vardef escaped_format(expr s) = endfor if mfun_esc_b = 0 : s - elseif mfun_esc_b > 0 : + % elseif mfun_esc_b > 0 : + elseif mfun_esc_b < mfun_esc_l : & (substring (mfun_esc_b,mfun_esc_l) of s) fi enddef ; diff --git a/tex/context/base/char-def.lua b/tex/context/base/char-def.lua index 864ca26c4..f6986e76d 100644 --- a/tex/context/base/char-def.lua +++ b/tex/context/base/char-def.lua @@ -1040,6 +1040,7 @@ characters.data={ direction="on", linebreak="al", mathclass="topaccent", + mathname="Hat", unicodeslot=0x5E, }, { diff --git a/tex/context/base/char-ent.lua b/tex/context/base/char-ent.lua index 58ee9472c..e48856a84 100644 --- a/tex/context/base/char-ent.lua +++ b/tex/context/base/char-ent.lua @@ -332,7 +332,7 @@ local entities = utilities.storage.allocate { ["NestedLessLess"] = "≪", -- U+0226A ["Nfr"] = "𝔑", -- U+1D511 ["Ngr"] = "Ν", -- U+0039D - ["NoBreak"] = "⁠", -- U+02060 + ["NoBreak"] = "⁠", -- U+02060 ["NonBreakingSpace"] = " ", -- U+000A0 ["Nopf"] = "ℕ", -- U+02115 ["Not"] = "⫬", -- U+02AEC @@ -2252,6 +2252,8 @@ local entities = utilities.storage.allocate { characters = characters or { } characters.entities = entities -entities.plusminus = "±" -- 0x000B1 -entities.minusplus = "∓" -- 0x02213 -entities.cdots = utf.char(0x02026) -- U+02026 +entities.plusminus = "±" -- U+000B1 +entities.minusplus = "∓" -- U+02213 +entities.Hat = "ˆ" -- U+002C6 -- better as this will stretch +entities.cdots = "⋯" -- U+022EF +entities.dots = "…" -- U+02026 diff --git a/tex/context/base/char-tex.lua b/tex/context/base/char-tex.lua index 537ab8581..48dccfe79 100644 --- a/tex/context/base/char-tex.lua +++ b/tex/context/base/char-tex.lua @@ -227,16 +227,6 @@ local accentmapping = allocate { O = "Õ", o = "õ", U = "Ũ", u = "ũ", }, - ["o"] = { [""] = "ø", - }, - ["O"] = { [""] = "Ø", - }, - ["a"] = { - ["a"] = "å", - }, - ["A"] = { - ["A"] = "Å", - }, } texcharacters.accentmapping = accentmapping @@ -283,17 +273,15 @@ local function remap_accent(a,c,braced) end local commandmapping = allocate { - ["i"] = "ı", - ["l"] = "ł", - ["ss"] = "ß", - ["ae"] = "æ", - ["AE"] = "Æ", - ["oe"] = "œ", - ["OE"] = "Œ", - ["o"] = "ø", - ["O"] = "Ø", - ["aa"] = "å", - ["AA"] = "Å", + ["aa"] = "å", ["AA"] = "Å", + ["ae"] = "æ", ["AE"] = "Æ", + ["cc"] = "ç", ["CC"] = "Ç", + ["i"] = "ı", ["j"] = "ȷ", + ["ij"] = "ij", ["IJ"] = "IJ", + ["l"] = "ł", ["L"] = "Ł", + ["o"] = "ø", ["O"] = "Ø", + ["oe"] = "œ", ["OE"] = "Œ", + ["sz"] = "ß", ["SZ"] = "SZ", ["SS"] = "ß", } texcharacters.commandmapping = commandmapping @@ -431,14 +419,18 @@ local contextsprint = context.sprint local ctxcatcodes = catcodes.numbers.ctxcatcodes function texcharacters.defineaccents() - local dodefineaccentcommand = context.dodefineaccentcommand - local dodefineaccent = context.dodefineaccent + local ctx_dodefineaccentcommand = context.dodefineaccentcommand + local ctx_dodefineaccent = context.dodefineaccent + local ctx_dodefinecommand = context.dodefinecommand for accent, group in next, accentmapping do - dodefineaccentcommand(accent) + ctx_dodefineaccentcommand(accent) for character, mapping in next, group do - dodefineaccent(accent,character,mapping) + ctx_dodefineaccent(accent,character,mapping) end end + for command, mapping in next, commandmapping do + ctx_dodefinecommand(command,mapping) + end end implement { -- a waste of scanner but consistent @@ -632,6 +624,9 @@ if not csletters then storage.register("characters/csletters", csletters, "characters.csletters") end +else + mark(csletters) + end lpegpatterns.csletter = utfchartabletopattern(csletters) diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 92da40985..c794639b9 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2015.04.08 21:31} +\newcontextversion{2015.04.09 20:56} %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/context-version.pdf b/tex/context/base/context-version.pdf index 344f96cf3..15c689560 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 03653f6fd..d3c2b5d0e 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2015.04.08 21:31} +\edef\contextversion{2015.04.09 20:56} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/enco-ini.mkiv b/tex/context/base/enco-ini.mkiv index 2c5488bcd..b2e7efd3e 100644 --- a/tex/context/base/enco-ini.mkiv +++ b/tex/context/base/enco-ini.mkiv @@ -66,9 +66,13 @@ \fi\fi \endcsname} +\unexpanded\def\enco_define_command#1#2% + {\setuvalue{\string#1}{#2}} + \let\dohandleaccent \enco_handle_accent % maybe useful \let\dodefineaccent \enco_define_accent % used at the lua end \let\dodefineaccentcommand\enco_define_accent_command % used at the lua end +\let\dodefinecommand \enco_define_command % used at the lua end \unexpanded\def\definecharacter#1 #2 % {\doifelsenumber{\string#2} diff --git a/tex/context/base/font-con.lua b/tex/context/base/font-con.lua index bb9691225..72fbb5c0d 100644 --- a/tex/context/base/font-con.lua +++ b/tex/context/base/font-con.lua @@ -507,6 +507,7 @@ function constructors.scale(tfmdata,specification) local nonames = properties.noglyphnames local haskerns = properties.haskerns or properties.mode == "base" -- we can have afm in node mode local hasligatures = properties.hasligatures or properties.mode == "base" -- we can have afm in node mode + local realdimensions = properties.realdimensions -- if changed and not next(changed) then changed = false @@ -618,6 +619,27 @@ function constructors.scale(tfmdata,specification) local width = description.width local height = description.height local depth = description.depth + if realdimensions then + -- this is mostly for checking issues + if not height or height == 0 then + local bb = description.boundingbox + local ht = bb[4] + if ht ~= 0 then + height = ht + end + if not depth or depth == 0 then + local dp = -bb[2] + if dp ~= 0 then + depth = dp + end + end + elseif not depth or depth == 0 then + local dp = -description.boundingbox[2] + if dp ~= 0 then + depth = dp + end + end + end if width then width = hdelta*width else width = scaledwidth end if height then height = vdelta*height else height = scaledheight end -- if depth then depth = vdelta*depth else depth = scaleddepth end diff --git a/tex/context/base/font-ext.lua b/tex/context/base/font-ext.lua index 6ab89c909..2ef79f8c2 100644 --- a/tex/context/base/font-ext.lua +++ b/tex/context/base/font-ext.lua @@ -506,6 +506,19 @@ registerotffeature { } } +local function initializerealdimensions(tfmdata,value) + tfmdata.properties.realdimensions = value and true +end + +registerotffeature { + name = "realdimensions", + description = "accept negative dimenions", + initializers = { + base = initializerealdimensions, + node = initializerealdimensions, + } +} + local function initializeitlc(tfmdata,value) -- hm, always value if value then -- the magic 40 and it formula come from Dohyun Kim but we might need another guess diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua index c7e83a4cb..85eebaaeb 100644 --- a/tex/context/base/font-otf.lua +++ b/tex/context/base/font-otf.lua @@ -107,6 +107,7 @@ registerdirective("fonts.otf.loader.pack", function(v) packdata = registerdirective("fonts.otf.loader.syncspace", function(v) syncspace = v end) registerdirective("fonts.otf.loader.forcenotdef", function(v) forcenotdef = v end) registerdirective("fonts.otf.loader.overloadkerns", function(v) overloadkerns = v end) +-----------------("fonts.otf.loader.alldimensions", function(v) alldimensions = v end) function otf.fileformat(filename) local leader = lower(io.loadchunk(filename,4)) @@ -637,17 +638,27 @@ actions["add dimensions"] = function(data,filename) -- d.name = ".notdef" -- end if bb then - local ht, dp = bb[4], -bb[2] - if ht == 0 or ht < 0 then - -- not set - else - d.height = ht - end - if dp == 0 or dp < 0 then - -- not set - else - d.depth = dp - end + local ht = bb[4] + local dp = -bb[2] + -- if alldimensions then + -- if ht ~= 0 then + -- d.height = ht + -- end + -- if dp ~= 0 then + -- d.depth = dp + -- end + -- else + if ht == 0 or ht < 0 then + -- not set + else + d.height = ht + end + if dp == 0 or dp < 0 then + -- not set + else + d.depth = dp + end + -- end end end end diff --git a/tex/context/base/java-imp-fld.mkiv b/tex/context/base/java-imp-fld.mkiv index aaec257f2..cbd53fffb 100644 --- a/tex/context/base/java-imp-fld.mkiv +++ b/tex/context/base/java-imp-fld.mkiv @@ -30,29 +30,34 @@ %D On into Yes. Also, we've changed the test for the on value %D into !Off as we dón't know what value it gets in the reader. +% Is this still okay? We can have unicode now, can't we? Anyway it's kind of +% messy and unneeded in these unicode times. + \startluasetups javascript:pdfencoding - local verbatim = context.verbatim - verbatim("{\n") - for accent, group in table.sortedhash(characters.tex.accentmapping) do - for character, mapping in table.sortedhash(group) do + local ctx_verbatim = context.verbatim + local utfbyte = utf.byte + local sortedhash = table.sortedhash + + ctx_verbatim("{\n") + for accent, group in sortedhash(characters.tex.accentmapping) do + for character, mapping in sortedhash(group) do if character == "" then character = " " end if accent == '"' then - verbatim(" '\\\\%s%s' : '\\u%04X',\n",accent,character,utf.byte(mapping)) + ctx_verbatim(" '\\\\%s%s' : '\\u%04X',\n",accent,character,utfbyte(mapping)) else - verbatim(' "\\\\%s%s" : "\\u%04X",\n',accent,character,utf.byte(mapping)) + ctx_verbatim(' "\\\\%s%s" : "\\u%04X",\n',accent,character,utfbyte(mapping)) end end end - verbatim(" '\\\\OE' : '\\u0152',\n") - verbatim(" '\\\\oe' : '\\u0153',\n") - verbatim(" '\\\\AE' : '\\u00C6',\n") - verbatim(" '\\\\ae' : '\\u00E6',\n") - verbatim(" '\\\\<<' : '\\u00AB',\n") - verbatim(" '\\\\>>' : '\\u00BB',\n") - verbatim(" '\\\\ss' : '\\u00DF' \n") - verbatim("}\n") + for command, mapping in sortedhash(characters.tex.commandmapping) do + ctx_verbatim(' "\\\\%s" : "\\u%04X",\n',command,utfbyte(mapping)) + end + -- ctx_verbatim(" '\\\\<<' : '\\u00AB',\n") + -- ctx_verbatim(" '\\\\>>' : '\\u00BB',\n") + ctx_verbatim("}\n") + \stopluasetups % maybe make { } tex braces in javascript code so that we can call lua diff --git a/tex/context/base/java-ini.mkiv b/tex/context/base/java-ini.mkiv index 59679e463..d6fe4dd8a 100644 --- a/tex/context/base/java-ini.mkiv +++ b/tex/context/base/java-ini.mkiv @@ -105,11 +105,13 @@ %D This macro can be used to force inclusion of postponed %D \JAVASCRIPT\ preambles. +\def\m_java_escape_u{\letterbackslash u} + \unexpanded\def\startJScode {\begingroup \obeylualines \obeyluatokens - \def\u{\letterbackslash u}% + \let\u\m_java_escape_u \java_start_code} \def\java_start_code#1\stopJScode @@ -121,7 +123,7 @@ {\begingroup \obeylualines \obeyluatokens - \def\u{\letterbackslash u}% + \let\u\m_java_escape_u \java_start_preamble} \def\java_start_preamble#1\stopJSpreamble diff --git a/tex/context/base/lang-txt.lua b/tex/context/base/lang-txt.lua index 0cfb5bcea..298e05db4 100644 --- a/tex/context/base/lang-txt.lua +++ b/tex/context/base/lang-txt.lua @@ -702,7 +702,7 @@ data.labels={ fr="Chapitre ", gr="Κεφάλαιο", hr="Poglavlje ", - hu=",. fejezet:", + hu={""," fejezet"}, it="", ja={"第","章"}, kr={"제","장"}, @@ -916,12 +916,12 @@ data.labels={ fr="Figure ", gr="Σχήμα", hr="Slika ", - hu=",. ábra:", + hu={""," ábra"}, it="Fig. ", ja="図", kr="그림 ", la="Imago ", - lt=", pav.", + lt={""," pav."}, nb="Figur ", nl="Figuur ", nn="Figur ", @@ -990,7 +990,7 @@ data.labels={ fr="Illustration ", gr="Γραφικό", hr="Slika ", - hu=",. kép:", + hu={""," kép"}, it="Grafico ", ja="イラスト", la="Typus ", @@ -1108,7 +1108,7 @@ data.labels={ fr="Intermède ", gr="Παύση", hr="Intermeco ", - hu=",. intermezzo:", + hu={""," intermezzo"}, it="Intermezzo ", ja="間奏曲", kr="간주곡", @@ -1362,7 +1362,7 @@ data.labels={ fr="ligne ", gr="Γραμμή", hr="redak ", - hu=",. sor:", + hu={""," sor"}, it="riga ", ja="線", kr="행", @@ -1795,12 +1795,12 @@ data.labels={ fr="Partie ", gr="Μέρος", hr="Dio ", - hu=",. rész:", + hu={""," rész"}, it="Parte ", ja={"第","パート"}, kr={"제","부"}, la="Pars ", - lt=", dalis", + lt={""," dalis"}, nb="Del", nl="Deel ", nn="Del", @@ -2162,12 +2162,12 @@ data.labels={ fr="Tableau ", gr="Πίνακας", hr="Tablica ", - hu=",. táblázat:", + hu={""," táblázat"}, it="Tabella ", ja="表", kr="표 ", la="Tabula ", - lt=", lentelė.", + lt={""," lentelė."}, nb="Tabell ", nl="Tabel ", nn="Tabell ", diff --git a/tex/context/base/lxml-ini.lua b/tex/context/base/lxml-ini.lua index 6feaa8500..64e78eb42 100644 --- a/tex/context/base/lxml-ini.lua +++ b/tex/context/base/lxml-ini.lua @@ -93,7 +93,7 @@ implement { name = "xmlremapnamespace", actions = xml.renamespace, implement { name = "xmlsave", actions = lxml.save, arguments = { "string", "string" } } implement { name = "xmlsetfunction", actions = lxml.setaction, arguments = { "string", "string", "string" } } implement { name = "xmlsetsetup", actions = lxml.setsetup, arguments = { "string", "string", "string" } } -implement { name = "xmlsnippet", actions = lxml.snippet, arguments = { "string", "integer" } } +implement { name = "xmlsnippet", actions = lxml.snippet, arguments = { "string", "string" } } implement { name = "xmlstrip", actions = lxml.strip, arguments = { "string", "string" } } implement { name = "xmlstripanywhere", actions = lxml.strip, arguments = { "string", "string", true, true } } implement { name = "xmlstripnolines", actions = lxml.strip, arguments = { "string", "string", true } } diff --git a/tex/context/base/m-chart.mkvi b/tex/context/base/m-chart.mkvi index f910b88eb..877a0fa37 100644 --- a/tex/context/base/m-chart.mkvi +++ b/tex/context/base/m-chart.mkvi @@ -97,7 +97,6 @@ [\c!framecolor=FLOWfocuscolor, \c!background=\FLOWshapeparameter\c!background, \c!backgroundcolor=\FLOWshapeparameter\c!backgroundcolor, - \c!backgroundscreen=\FLOWshapeparameter\c!backgroundscreen, \c!rulethickness=\FLOWshapeparameter\c!rulethickness, \c!offset=\FLOWshapeparameter\c!offset] diff --git a/tex/context/base/m-visual.mkiv b/tex/context/base/m-visual.mkiv index 486e9859e..3c57691ec 100644 --- a/tex/context/base/m-visual.mkiv +++ b/tex/context/base/m-visual.mkiv @@ -762,7 +762,7 @@ \startoverlay {\copy\scratchbox} {\dodotagbox{#1}\scratchbox{\framed - [\c!background=\v!screen,\c!backgroundscreen=1]{#2}}} + [\c!background=\v!color,\c!backgroundcolor=\v!gray]{#2}}} \stopoverlay \egroup \nextboxwd\the\wd\scratchbox diff --git a/tex/context/base/math-act.lua b/tex/context/base/math-act.lua index 76222913b..d0ea78990 100644 --- a/tex/context/base/math-act.lua +++ b/tex/context/base/math-act.lua @@ -90,6 +90,8 @@ end sequencers.appendaction("mathparameters","system","mathematics.scaleparameters") +-- AccentBaseHeight vs FlattenedAccentBaseHeight + function mathematics.checkaccentbaseheight(target,original) local mathparameters = target.mathparameters if mathparameters and mathparameters.AccentBaseHeight == 0 then diff --git a/tex/context/base/meta-pag.mkiv b/tex/context/base/meta-pag.mkiv index 3e3025344..6b6abd211 100644 --- a/tex/context/base/meta-pag.mkiv +++ b/tex/context/base/meta-pag.mkiv @@ -115,7 +115,7 @@ % \to \everyMPgraphic \prependtoks - \calculatereducedvsizes % this is really needed + \calculatereducedvsizes % bah, this is really needed \to \everyMPgraphic \protect \endinput diff --git a/tex/context/base/mlib-lua.lua b/tex/context/base/mlib-lua.lua index 7d95e1b37..392fc1a3c 100644 --- a/tex/context/base/mlib-lua.lua +++ b/tex/context/base/mlib-lua.lua @@ -348,3 +348,35 @@ function metapost.initializescriptrunner(mpx,trialrun) end -- trace_enabled = not trialrun blocks too much end + +-- texts: + +local factor = 65536*(7227/7200) +local textexts = nil +local mptriplet = mp.triplet + +function mp.tt_initialize(tt) + textexts = tt +end + +-- function mp.tt_wd(n) +-- local box = textexts and textexts[n] +-- mpprint(box and box.width/factor or 0) +-- end +-- function mp.tt_ht(n) +-- local box = textexts and textexts[n] +-- mpprint(box and box.height/factor or 0) +-- end +-- function mp.tt_dp(n) +-- local box = textexts and textexts[n] +-- mpprint(box and box.depth/factor or 0) +-- end + +function mp.tt_dimensions(n) + local box = textexts and textexts[n] + if box then + mptriplet(box.width/factor,box.height/factor,box.depth/factor) + else + mptriplet(0,0,0) + end +end diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua index 31dbaf2da..8f7a3df10 100644 --- a/tex/context/base/mlib-pps.lua +++ b/tex/context/base/mlib-pps.lua @@ -270,6 +270,10 @@ local function stopjob() end end +function metapost.getjobdata() + return top +end + -- end of new local function settext(box,slot) @@ -546,29 +550,34 @@ local do_begin_fig = "; beginfig(1) ; " local do_end_fig = "; endfig ;" local do_safeguard = ";" -local f_text_data = formatters["mfun_tt_w[%i] := %f ; mfun_tt_h[%i] := %f ; mfun_tt_d[%i] := %f ;"] +-- local f_text_data = formatters["mfun_tt_w[%i] := %f ; mfun_tt_h[%i] := %f ; mfun_tt_d[%i] := %f ;"] +-- +-- function metapost.textextsdata() +-- local textexts = top.textexts +-- local collected = { } +-- local nofcollected = 0 +-- for k, data in sortedhash(top.texdata) do -- sort is nicer in trace +-- local texorder = data.texorder +-- for n=1,#texorder do +-- local box = textexts[texorder[n]] +-- if box then +-- local wd, ht, dp = box.width/factor, box.height/factor, box.depth/factor +-- if trace_textexts then +-- report_textexts("passed data item %s:%s > (%p,%p,%p)",k,n,wd,ht,dp) +-- end +-- nofcollected = nofcollected + 1 +-- collected[nofcollected] = f_text_data(n,wd,n,ht,n,dp) +-- else +-- break +-- end +-- end +-- end +-- return collected +-- end function metapost.textextsdata() - local textexts = top.textexts - local collected = { } - local nofcollected = 0 - for k, data in sortedhash(top.texdata) do -- sort is nicer in trace - local texorder = data.texorder - for n=1,#texorder do - local box = textexts[texorder[n]] - if box then - local wd, ht, dp = box.width/factor, box.height/factor, box.depth/factor - if trace_textexts then - report_textexts("passed data item %s:%s > (%p,%p,%p)",k,n,wd,ht,dp) - end - nofcollected = nofcollected + 1 - collected[nofcollected] = f_text_data(n,wd,n,ht,n,dp) - else - break - end - end - end - return collected + local top = metapost.getjobdata() + mp.tt_initialize(top and top.textexts) end metapost.intermediate = metapost.intermediate or { } @@ -601,10 +610,11 @@ local function extrapass() if trace_runs then report_metapost("second run of job %s, asked figure %a",top.nofruns,top.askedfig) end + local textexts = metapost.textextsdata() processmetapost(top.mpx, { top.wrappit and do_begin_fig or "", no_trial_run, - concat(metapost.textextsdata()," ;\n"), + textexts and concat(textexts," ;\n") or "", top.initializations, do_safeguard, top.data, @@ -921,8 +931,16 @@ local fmt = formatters["%s %s %s % t"] ----- pat = tsplitat(":") local pat = lpeg.tsplitter(":",tonumber) -- so that %F can do its work +local f_gray_yes = formatters["s=%F,a=%F,t=%F"] +local f_gray_nop = formatters["s=%F"] +local f_rgb_yes = formatters["r=%F,g=%F,b=%F,a=%F,t=%F"] +local f_rgb_nop = formatters["r=%F,g=%F,b=%F"] +local f_cmyk_yes = formatters["c=%F,m=%F,y=%F,k=%F,a=%F,t=%F"] +local f_cmyk_nop = formatters["c=%F,m=%F,y=%F,k=%F"] + local ctx_MPLIBsetNtext = context.MPLIBsetNtext local ctx_MPLIBsetCtext = context.MPLIBsetCtext +local ctx_MPLIBsettext = context.MPLIBsettext local function tx_analyze(object,prescript) -- todo: hash content and reuse them local data = top.texdata[metapost.properties.number] @@ -946,25 +964,26 @@ local function tx_analyze(object,prescript) -- todo: hash content and reuse them if not n then local tx_last = top.texlast + 1 top.texlast = tx_last + -- report_textexts("tex string: %s",s) if not c then ctx_MPLIBsetNtext(tx_last,s) elseif #c == 1 then if a and t then - ctx_MPLIBsetCtext(tx_last,formatters["s=%F,a=%F,t=%F"](c[1],a,t),s) + ctx_MPLIBsetCtext(tx_last,f_gray_yes(c[1],a,t),s) else - ctx_MPLIBsetCtext(tx_last,formatters["s=%F"](c[1]),s) + ctx_MPLIBsetCtext(tx_last,f_gray_nop(c[1]),s) end elseif #c == 3 then if a and t then - ctx_MPLIBsetCtext(tx_last,formatters["r=%F,g=%F,b=%F,a=%F,t=%F"](c[1],c[2],c[3],a,t),s) + ctx_MPLIBsetCtext(tx_last,f_rgb_nop(c[1],c[2],c[3],a,t),s) else - ctx_MPLIBsetCtext(tx_last,formatters["r=%F,g=%F,b=%F"](c[1],c[2],c[3]),s) + ctx_MPLIBsetCtext(tx_last,f_rgb_nop(c[1],c[2],c[3]),s) end elseif #c == 4 then if a and t then - ctx_MPLIBsetCtext(tx_last,formatters["c=%F,m=%F,y=%F,k=%F,a=%F,t=%F"](c[1],c[2],c[3],c[4],a,t),s) + ctx_MPLIBsetCtext(tx_last,f_cmyk_yes(c[1],c[2],c[3],c[4],a,t),s) else - ctx_MPLIBsetCtext(tx_last,formatters["c=%F,m=%F,y=%F,k=%F"](c[1],c[2],c[3],c[4]),s) + ctx_MPLIBsetCtext(tx_last,f_cmyk_nop(c[1],c[2],c[3],c[4]),s) end else ctx_MPLIBsetNtext(tx_last,s) @@ -990,7 +1009,7 @@ local function tx_analyze(object,prescript) -- todo: hash content and reuse them local s = object.postscript or "" local tx_last = top.texlast + 1 top.texlast = tx_last - context.MPLIBsettext(tx_last,s) + ctx_MPLIBsettext(tx_last,s) top.multipass = true data.texslots[tx_trial] = tx_last data.texorder[tx_number] = tx_last diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua index 5b4301f9b..121c32ae9 100644 --- a/tex/context/base/mlib-run.lua +++ b/tex/context/base/mlib-run.lua @@ -389,7 +389,7 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, tra.inp:write(formatters["\n%% end snippet %s\n"](i)) end starttiming(metapost.exectime) - result = mpx:execute(d) + result = mpx:execute(d) -- some day we wil use a coroutine with textexts stoptiming(metapost.exectime) if trace_graphics and result then local str = result.log or result.error diff --git a/tex/context/base/pack-bck.mkvi b/tex/context/base/pack-bck.mkvi index 72eafd282..bb4b72252 100644 --- a/tex/context/base/pack-bck.mkvi +++ b/tex/context/base/pack-bck.mkvi @@ -32,7 +32,7 @@ %D \starttyping %D \setupbackground %D [backgroundoffset=4pt, -%D background=screen, +%D background=color, %D frame=on, %D framecolor=red, %D leftoffset=2pt] @@ -206,14 +206,9 @@ \c!corner=\v!rectangular, \c!frame=\v!off, \c!depth=\zeropoint, -% \c!color=, -% \c!background=\v!screen, -% \c!backgroundcolor=\backgroundparameter\c!color, -% \c!screen=\defaultbackgroundscreen, -% + % \c!color=, \c!background=\v!color, \c!backgroundcolor=lightgray, -% \c!before=, \c!after=] diff --git a/tex/context/base/pack-rul.lua b/tex/context/base/pack-rul.lua index 5229987ea..151642c3a 100644 --- a/tex/context/base/pack-rul.lua +++ b/tex/context/base/pack-rul.lua @@ -14,6 +14,12 @@ if not modules then modules = { } end modules ['pack-rul'] = { -- challenge: adapt glue_set -- setfield(h,"glue_set", getfield(h,"glue_set") * getfield(h,"width")/maxwidth -- interesting ... doesn't matter much +-- \framed[align={lohi,middle}]{$x$} +-- \framed[align={lohi,middle}]{$ $} +-- \framed[align={lohi,middle}]{\hbox{ }} +-- \framed[align={lohi,middle}]{\hbox{}} +-- \framed[align={lohi,middle}]{$\hskip2pt$} + local type = type local hlist_code = nodes.nodecodes.hlist @@ -93,7 +99,7 @@ local function doreshapeframedbox(n) -- vdone = true end if not firstheight then - -- done + -- done) elseif maxwidth ~= 0 then if hdone then for h in traverse_id(hlist_code,list) do @@ -119,6 +125,8 @@ local function doreshapeframedbox(n) -- end setfield(box,"width",maxwidth) averagewidth = noflines > 0 and totalwidth/noflines or 0 + else -- e.g. empty math {$ $} or \hbox{} or ... +setfield(box,"width",0) end end end diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv index f2979a5e1..9a8c2784e 100644 --- a/tex/context/base/pack-rul.mkiv +++ b/tex/context/base/pack-rul.mkiv @@ -43,23 +43,23 @@ \def\pack_framed_setup_line_width[#1]% {\assigndimension{#1}\linewidth{.2\points}{.4\points}{.6\points}} -%D \macros -%D {setupscreens} -%D -%D Sort of obsolete: -%D -%D \showsetup{setupscreens} - -\installcorenamespace{screens} - -\installsetuponlycommandhandler \??screens {screens} - -\appendtoks - \edef\defaultbackgroundscreen{\directscreensparameter\c!screen} -\to \everysetupscreens - -\setupscreens - [\c!screen=.90] % was .95 but that's hardly visible +% %D \macros +% %D {setupscreens} +% %D +% %D Sort of obsolete: +% %D +% %D \showsetup{setupscreens} +% +% \installcorenamespace{screens} +% +% \installsetuponlycommandhandler \??screens {screens} +% +% \appendtoks +% \edef\defaultbackgroundscreen{\directscreensparameter\c!screen} +% \to \everysetupscreens +% +% \setupscreens +% [\c!screen=.90] % was .95 but that's hardly visible %D The parameter handler: @@ -155,8 +155,6 @@ %\c!foregroundcolor=, %\c!foregroundstyle=, %\c!background=, - %\c!backgroundscreen=, - \c!backgroundscreen=\defaultbackgroundscreen, %\c!backgroundcolor=, \c!backgroundoffset=\zeropoint, %\c!framecolor=, @@ -238,7 +236,6 @@ \let\p_framed_lines \empty \let\p_framed_empty \empty \let\p_framed_backgroundcolor \empty -\let\p_framed_backgroundscreen\empty \let\p_framed_framecolor \empty \let\p_framed_component \empty \let\p_framed_region \empty @@ -352,14 +349,14 @@ %D The oval box is drawn using a special macro, depending on %D the driver in use. -\def\pack_framed_background_box_gray % avoid black rules when no gray - {\edef\p_framed_backgroundscreen{\framedparameter\c!backgroundscreen}% - \ifx\p_framed_backgroundscreen\empty \else - \pack_framed_background_box_gray_indeed - \fi} - -\def\pack_framed_background_box_gray_indeed % can be more direct but who cares, just compatibility - {\colored[s=\p_framed_backgroundscreen]{\pack_framed_filled_box}} +% \def\pack_framed_background_box_gray % avoid black rules when no gray +% {\edef\p_framed_backgroundscreen{\framedparameter\c!backgroundscreen}% +% \ifx\p_framed_backgroundscreen\empty \else +% \pack_framed_background_box_gray_indeed +% \fi} +% +% \def\pack_framed_background_box_gray_indeed % can be more direct but who cares, just compatibility +% {\colored[s=\p_framed_backgroundscreen]{\pack_framed_filled_box}} %D It won't be a surprise that we not only provide gray boxes, but also colored %D ones. Here it is: @@ -1402,10 +1399,19 @@ \def\pack_framed_restart {\aftergroup\pack_framed_finish} -\def\pack_framed_do_top {\raggedtopcommand\framedparameter\c!top} -\def\pack_framed_do_bottom{\framedparameter\c!bottom\raggedbottomcommand} +\def\pack_framed_do_top + {\raggedtopcommand + \framedparameter\c!top + \edef\p_blank{\framedparameter\c!blank}% + \ifx\p_blank\v!yes\else % auto or no + \doinhibitblank + \fi} + +\def\pack_framed_do_bottom + {\framedparameter\c!bottom + \raggedbottomcommand} -%D Carefull analysis of this macro will learn us that not all branches in the last +%D Careful analysis of this macro will learn us that not all branches in the last %D conditionals can be encountered, that is, some assignments to \type{\next} will %D never occur. Nevertheless we implement the whole scheme, if not for future %D extensions. @@ -2106,7 +2112,7 @@ {\vbox to \d_framed_height \bgroup \let\postprocessframebox\relax -% \pack_framed_forgetall + % \pack_framed_forgetall \iftrialtypesetting \else \pack_framed_set_foregroundcolor \fi @@ -2117,7 +2123,7 @@ \raggedcommand \pack_framed_do_top \bgroup -\synchronizeinlinedirection + \synchronizeinlinedirection \localbegstrut \aftergroup\localendstrut \aftergroup\pack_framed_do_bottom @@ -2128,7 +2134,7 @@ {\vbox to \d_framed_height \bgroup \let\postprocessframebox\relax -% \pack_framed_forgetall + % \pack_framed_forgetall \iftrialtypesetting \else \pack_framed_set_foregroundcolor \fi @@ -2139,7 +2145,7 @@ \raggedcenter \vss \bgroup -\synchronizeinlinedirection + \synchronizeinlinedirection \localbegstrut \aftergroup\localendstrut \aftergroup\vss @@ -2150,7 +2156,7 @@ {\vbox to \d_framed_height \bgroup \let\postprocessframebox\relax -% \pack_framed_forgetall + % \pack_framed_forgetall \iftrialtypesetting \else \pack_framed_set_foregroundcolor \fi @@ -2162,7 +2168,7 @@ \aftergroup\localendstrut \aftergroup\vss \aftergroup\egroup -\synchronizeinlinedirection + \synchronizeinlinedirection \localbegstrut \doformatonelinerbox} @@ -2170,7 +2176,7 @@ {\vbox \bgroup \let\postprocessframebox\relax -% \pack_framed_forgetall + % \pack_framed_forgetall \iftrialtypesetting \else \pack_framed_set_foregroundcolor \fi @@ -2180,7 +2186,7 @@ \raggedcommand \pack_framed_do_top \bgroup -\synchronizeinlinedirection + \synchronizeinlinedirection \localbegstrut \aftergroup\localendstrut \aftergroup\pack_framed_do_bottom @@ -2191,7 +2197,7 @@ {\vbox to \d_framed_height \bgroup \let\postprocessframebox\relax -% \pack_framed_forgetall + % \pack_framed_forgetall \iftrialtypesetting \else \pack_framed_set_foregroundcolor \fi @@ -2204,7 +2210,7 @@ \hbox \bgroup \aftergroup\egroup -\synchronizeinlinedirection + \synchronizeinlinedirection \localstrut \doformatonelinerbox} @@ -2212,13 +2218,13 @@ {\hbox to \d_framed_width \bgroup \let\postprocessframebox\relax -% \pack_framed_forgetall + % \pack_framed_forgetall \iftrialtypesetting \else \pack_framed_set_foregroundcolor \fi \pack_framed_do_setups \hss -\synchronizeinlinedirection + \synchronizeinlinedirection \localstrut \bgroup \aftergroup\hss @@ -2233,7 +2239,7 @@ \fi \let\postprocessframebox\relax \pack_framed_do_setups -\synchronizeinlinedirection + \synchronizeinlinedirection \localstrut \doformatonelinerbox} @@ -2612,7 +2618,6 @@ %\c!foregroundstyle=, %\c!background=, %\c!backgroundcolor=, - \c!backgroundscreen=\defaultbackgroundscreen, \c!linecorrection=\v!on, \c!depthcorrection=\v!on, \c!margin=\v!standard] diff --git a/tex/context/base/publ-imp-cite.mkvi b/tex/context/base/publ-imp-cite.mkvi index 94fa3f528..d763c2d4f 100644 --- a/tex/context/base/publ-imp-cite.mkvi +++ b/tex/context/base/publ-imp-cite.mkvi @@ -111,7 +111,7 @@ \startsetups btx:cite:normal \texdefinition{\s!btx:\s!cite:concat} - \currentbtxleftttext + \currentbtxlefttext \ifx\currentbtxfirst\empty \fastsetup{\s!btx:\s!cite:\s!empty} \else @@ -142,7 +142,7 @@ \startsetups btx:cite:range \texdefinition{\s!btx:\s!cite:concat} - \currentbtxleftttext + \currentbtxlefttext \ifx\currentbtxfirst\empty \fastsetup{\s!btx:\s!cite:\s!empty} \else @@ -163,7 +163,7 @@ \startsetups btx:cite:listelement \texdefinition{\s!btx:\s!cite:concat} - \currentbtxleftttext + \currentbtxlefttext \ifx\currentbtxfirst\empty \fastsetup{\s!btx:\s!cite:\s!empty} \else diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv index e860aacde..e44056954 100644 --- a/tex/context/base/spac-ver.mkiv +++ b/tex/context/base/spac-ver.mkiv @@ -1991,8 +1991,20 @@ %D \type {\blank} (we needed the first one while playing with the %D new code). +% We keep this one as reference +% +% \unexpanded\def\inhibitblank +% {\vspacing[\v!disable]} +% +% but use the following more efficient variant instead: + \unexpanded\def\inhibitblank - {\vspacing[\v!disable]} % can be made faster + {\ifvmode + \begingroup + \attribute\skipcategoryattribute\plusfive + \vskip\zeropoint + \endgroup + \fi} \let\doinhibitblank\inhibitblank % keep this command, used in styles diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 829e20164..feb2b3c79 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index b0e7c9663..e0c35e9a9 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/syst-ini.mkiv b/tex/context/base/syst-ini.mkiv index 5ff80531a..8631aed90 100644 --- a/tex/context/base/syst-ini.mkiv +++ b/tex/context/base/syst-ini.mkiv @@ -114,15 +114,6 @@ end } -%D Handy. - - -\suppresslongerror = 1 -\suppressoutererror = 1 -%suppressmathparerror = 1 - -\ifdefined\suppressmathparerror \suppressmathparerror = 1 \fi - %D \ETEX\ has a not so handy way of telling you the version number, i.e. the revision %D number has a period in it: @@ -1098,6 +1089,12 @@ \voffset\zeropoint \let\voffset\relax \newdimen\voffset % prevent messing up \hoffset\zeropoint \let\hoffset\relax \newdimen\hoffset % prevent messing up +%D Handy. + +\suppresslongerror \plusone +\suppressoutererror \plusone +\suppressmathparerror \plusone + %D While cleaning this code up a bit I was listening to Heather Nova's \CD\ Redbird. %D The first song on that \CD\ ends with a few lines suitable for ending this %D initialization module: diff --git a/tex/context/base/tabl-ntb.mkiv b/tex/context/base/tabl-ntb.mkiv index 9454ce1d9..2b6f3a3ec 100644 --- a/tex/context/base/tabl-ntb.mkiv +++ b/tex/context/base/tabl-ntb.mkiv @@ -104,7 +104,7 @@ \to \t_tabl_ntb_cell_start \unexpanded\def\tabl_ntb_cell_start - {\inhibitblank + {% \inhibitblank \dotagTABLEcell %\tabl_ntb_next_level \usenaturaltablelocalstyleandcolor\c!style\c!color diff --git a/tex/context/base/tabl-tab.mkiv b/tex/context/base/tabl-tab.mkiv index 9813b995e..16a16601c 100644 --- a/tex/context/base/tabl-tab.mkiv +++ b/tex/context/base/tabl-tab.mkiv @@ -2288,8 +2288,7 @@ \c!distance=\v!medium, \c!bodyfont=, \c!commands=, - \c!background=\v!screen, % huh? - \c!backgroundscreen=\defaultbackgroundscreen, + \c!background=, \c!backgroundcolor=, \c!split=\v!auto] diff --git a/tex/context/base/tabl-xtb.mkvi b/tex/context/base/tabl-xtb.mkvi index 777016d50..530232b1e 100644 --- a/tex/context/base/tabl-xtb.mkvi +++ b/tex/context/base/tabl-xtb.mkvi @@ -475,7 +475,7 @@ \tabl_x_stop_cell} \unexpanded\def\tabl_x_begin_of_cell - {\inhibitblank + {%\inhibitblank % already in framed \everypar{\delayedbegstrut}} \unexpanded\def\tabl_x_end_of_cell diff --git a/tex/context/base/trac-vis.lua b/tex/context/base/trac-vis.lua index d1323698b..81ac0f206 100644 --- a/tex/context/base/trac-vis.lua +++ b/tex/context/base/trac-vis.lua @@ -573,7 +573,8 @@ local function ruledglyph(head,current,previous) setfield(current,"prev",nil) local linewidth = emwidth/20 local baseline - if dp ~= 0 and ht ~= 0 then + -- if dp ~= 0 and ht ~= 0 then + if (dp >= 0 and ht >= 0) or (dp <= 0 and ht <= 0) then baseline = new_rule(wd-2*linewidth,linewidth,0) end local doublelinewidth = 2*linewidth diff --git a/tex/context/base/x-mathml.lua b/tex/context/base/x-mathml.lua index 813f6d78a..5a60fab52 100644 --- a/tex/context/base/x-mathml.lua +++ b/tex/context/base/x-mathml.lua @@ -9,22 +9,50 @@ if not modules then modules = { } end modules ['x-mathml'] = { -- This needs an upgrade to the latest greatest mechanisms. local type, next = type, next -local format, lower, find, gsub = string.format, string.lower, string.find, string.gsub +local formatters, lower, find, gsub, match = string.formatters, string.lower, string.find, string.gsub, string.match local strip = string.strip local xmlsprint, xmlcprint, xmltext, xmlcontent = xml.sprint, xml.cprint, xml.text, xml.content +local lxmlcollected = lxml.collected local getid = lxml.getid local utfchar, utfcharacters, utfvalues = utf.char, utf.characters, utf.values -local lpegmatch = lpeg.match +local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns local mathml = { } moduledata.mathml = mathml lxml.mathml = mathml -- for the moment -local context = context +local context = context -local ctx_enabledelimiter = context.enabledelimiter -local ctx_disabledelimiter = context.disabledelimiter -local ctx_xmlflush = context.xmlflush -- better xmlsprint +local ctx_enabledelimiter = context.enabledelimiter +local ctx_disabledelimiter = context.disabledelimiter +local ctx_xmlflush = context.xmlflush -- better xmlsprint + +local ctx_halign = context.halign +local ctx_noalign = context.noalign +local ctx_bgroup = context.bgroup +local ctx_egroup = context.egroup +local ctx_crcr = context.crcr + +local ctx_bTABLE = context.bTABLE +local ctx_eTABLE = context.eTABLE +local ctx_bTR = context.bTR +local ctx_eTR = context.eTR +local ctx_bTD = context.bTD +local ctx_eTD = context.eTD + +local ctx_mn = context.mn +local ctx_mi = context.mi +local ctx_mo = context.mo +local ctx_startimath = context.startimath +local ctx_ignorespaces = context.ignorespaces +local ctx_removeunwantedspaces = context.removeunwantedspaces +local ctx_stopimath = context.stopimath + +local ctx_mmlapplycsymbol = context.mmlapplycsymbol + +local ctx_mathopnolimits = context.mathopnolimits +local ctx_left = context.left +local ctx_right = context.right -- an alternative is to remap to private codes, where we can have -- different properties .. to be done; this will move and become @@ -68,6 +96,7 @@ local o_replacements = { -- in main table ["{"] = "\\mmlleftdelimiter \\lbrace", ["}"] = "\\mmlrightdelimiter\\rbrace", ["|"] = "\\mmlleftorrightdelimiter\\vert", + -- ["."] = "\\mmlleftorrightdelimiter.", ["/"] = "\\mmlleftorrightdelimiter\\solidus", [doublebar] = "\\mmlleftorrightdelimiter\\Vert", ["("] = "\\mmlleftdelimiter(", @@ -480,7 +509,7 @@ function mathml.mn(id,pattern) local rep = gsub(str,"&.-;","") local rep = gsub(rep,"(%s+)",utfchar(0x205F)) -- medspace e.g.: twenty one (nbsp is not seen) local rep = gsub(rep,".",n_replacements) - context.mn(rep) + ctx_mn(rep) end function mathml.mo(id) @@ -506,7 +535,7 @@ function mathml.mi(id) rep = gsub(str,".",i_replacements) end context(rep) - -- context.mi(rep) + -- ctx_mi(rep) else ctx_xmlflush(id) -- xmlsprint or so end @@ -567,25 +596,6 @@ function mathml.mfenced(id) -- multiple separators ctx_disabledelimiter() end ---~ local function flush(e,tag,toggle) ---~ if toggle then ---~ context("^{") ---~ else ---~ context("_{") ---~ end ---~ if tag == "none" then ---~ context("{}") ---~ else ---~ xmlsprint(e.dt) ---~ end ---~ if not toggle then ---~ context("}") ---~ else ---~ context("}{}") ---~ end ---~ return not toggle ---~ end - local function flush(e,tag,toggle) if tag == "none" then -- if not toggle then @@ -605,7 +615,7 @@ end function mathml.mmultiscripts(id) local done, toggle = false, false - for e in lxml.collected(id,"/*") do + for e in lxmlcollected(id,"/*") do local tag = e.tg if tag == "mprescripts" then context("{}") @@ -615,7 +625,7 @@ function mathml.mmultiscripts(id) end end local done, toggle = false, false - for e in lxml.collected(id,"/*") do + for e in lxmlcollected(id,"/*") do local tag = e.tg if tag == "mprescripts" then break @@ -676,20 +686,20 @@ function mathml.mcolumn(root) -- m[#m+1] = { tag, e } end end - for e in lxml.collected(root,"/*") do + for e in lxmlcollected(root,"/*") do local m = { } matrix[#matrix+1] = m if e.tg == "mrow" then -- only one level - for e in lxml.collected(e,"/*") do + for e in lxmlcollected(e,"/*") do collect(m,e) end else collect(m,e) end end - context.halign() - context.bgroup() + ctx_halign() + ctx_bgroup() context([[\hss\startimath\alignmark\stopimath\aligntab\startimath\alignmark\stopimath\cr]]) for i=1,#matrix do local m = matrix[i] @@ -701,7 +711,7 @@ function mathml.mcolumn(root) end end if mline then - context.noalign([[\obeydepth\nointerlineskip]]) + ctx_noalign([[\obeydepth\nointerlineskip]]) end for j=1,#m do local mm = m[j] @@ -744,9 +754,9 @@ function mathml.mcolumn(root) local nchr = n_replacements[chr] context(nchr or chr) end - context.crcr() + ctx_crcr() end - context.egroup() + ctx_egroup() end local spacesplitter = lpeg.tsplitat(" ") @@ -764,42 +774,47 @@ function mathml.mtable(root) local framespacing = at.framespacing or "0pt" local framespacing = at.framespacing or "-\\ruledlinewidth" -- make this an option - context.bTABLE { frame = frametypes[frame or "none"] or "off", offset = framespacing, background = "" } -- todo: use xtables and definextable - for e in lxml.collected(root,"/(mml:mtr|mml:mlabeledtr)") do - context.bTR() + ctx_bTABLE { frame = frametypes[frame or "none"] or "off", offset = framespacing, background = "" } -- todo: use xtables and definextable + for e in lxmlcollected(root,"/(mml:mtr|mml:mlabeledtr)") do + ctx_bTR() local at = e.at local col = 0 local rfr = at.frame or (frames and frames [#frames]) local rra = at.rowalign or (rowaligns and rowaligns [#rowaligns]) local rca = at.columnalign or (columnaligns and columnaligns[#columnaligns]) local ignorelabel = e.tg == "mlabeledtr" - for e in lxml.collected(e,"/mml:mtd") do -- nested we can use xml.collected + for e in lxmlcollected(e,"/mml:mtd") do -- nested we can use xml.collected col = col + 1 if ignorelabel and col == 1 then -- get rid of label, should happen at the document level else local at = e.at - local rowspan, columnspan = at.rowspan or 1, at.columnspan or 1 + local rowspan = at.rowspan or 1 + local columnspan = at.columnspan or 1 local cra = rowalignments [at.rowalign or (rowaligns and rowaligns [col]) or rra or "center"] or "lohi" local cca = columnalignments[at.columnalign or (columnaligns and columnaligns[col]) or rca or "center"] or "middle" local cfr = frametypes [at.frame or (frames and frames [col]) or rfr or "none" ] or "off" - context.bTD { align = format("{%s,%s}",cra,cca), frame = cfr, nx = columnspan, ny = rowspan } - context.startimath() - context.ignorespaces() - xmlcprint(e) - context.stopimath() - context.removeunwantedspaces() - context.eTD() + ctx_bTD { align = formatters["{%s,%s}"](cra,cca), frame = cfr, nx = columnspan, ny = rowspan } + if xml.empty(e,".") then + -- nothing, else hsize max + else + ctx_startimath() + -- ctx_ignorespaces() + xmlcprint(e) + -- ctx_removeunwantedspaces() + ctx_stopimath() + end + ctx_eTD() end end -- if e.tg == "mlabeledtr" then - -- context.bTD() + -- ctx_bTD() -- xmlcprint(xml.first(e,"/!mml:mtd")) - -- context.eTD() + -- ctx_eTD() -- end - context.eTR() + ctx_eTR() end - context.eTABLE() + ctx_eTABLE() end function mathml.csymbol(root) @@ -810,14 +825,16 @@ function mathml.csymbol(root) local full = hash.original or "" local base = hash.path or "" local text = strip(xmltext(root) or "") - context.mmlapplycsymbol(full,base,encoding,text) + ctx_mmlapplycsymbol(full,base,encoding,text) end +local p = lpeg.Cs(((1-lpegpatterns.whitespace)^1 / "mml:enclose:%0" + (lpegpatterns.whitespace^1)/",")^1) + function mathml.menclosepattern(root) root = getid(root) local a = root.at.notation if a and a ~= "" then - context("mml:enclose:",(gsub(a," +",",mml:enclose:"))) + context(lpegmatch(p,a)) end end @@ -828,8 +845,8 @@ end function mathml.cpolar_a(root) root = getid(root) local dt = root.dt - context.mathopnolimits("Polar") - context.left(false,"(") + ctx_mathopnolimits("Polar") + ctx_left(false,"(") for k=1,#dt do local dk = dt[k] if xml.is_element(dk,"sep") then @@ -838,7 +855,7 @@ function mathml.cpolar_a(root) xmlsprint(dk) end end - context.right(false,")") + ctx_right(false,")") end -- crap .. maybe in char-def a mathml overload diff --git a/tex/context/base/x-mathml.mkiv b/tex/context/base/x-mathml.mkiv index 654d4f914..ac74aa414 100644 --- a/tex/context/base/x-mathml.mkiv +++ b/tex/context/base/x-mathml.mkiv @@ -56,10 +56,10 @@ \xmlregistersetup{xml:mml:define} -\unexpanded\def\MMLhack - {\let\MMLpar\par - \let\par\relax - \everyvbox{\let\par\MMLpar}} +% \unexpanded\def\MMLhack % no longer needed +% {\let\MMLpar\par +% \let\par\relax +% \everyvbox{\let\par\MMLpar}} \xmlmapvalue {mml:math:mode} {display} {\displaymathematics} % we had this already \xmlmapvalue {mml:math:mode} {inline} {\inlinemathematics } @@ -80,7 +80,7 @@ } { \math_fences_checked_start - \MMLhack + %\MMLhack \xmlflush{#1} \math_fences_checked_stop } @@ -90,7 +90,7 @@ \startxmlsetups mml:imath \inlinemathematics { \math_fences_checked_start - \MMLhack + %\MMLhack \xmlflush{#1} \math_fences_checked_stop } @@ -99,7 +99,7 @@ \startxmlsetups mml:dmath \displaymathematics { \math_fences_checked_start - \MMLhack + %\MMLhack \xmlflush{#1} \math_fences_checked_stop } @@ -111,7 +111,10 @@ \edef\mmlformulalabel {\xmlatt{#1}{label}\xmlatt{#1}{id}} \edef\mmlformulasublabel{\xmlatt{#1}{sublabel}\xmlatt{#1}{id}} \doifsomething\mmlformulalabel{\placeformula[\mmlformulalabel]{\mmlformulasublabel}} - \startformula\MMLhack\xmlfirst{#1}{/mml:math}\stopformula + \startformula + %\MMLhack + \xmlfirst{#1}{/mml:math} + \stopformula \stopxmlsetups % old delimiter hacks @@ -1752,7 +1755,7 @@ \startxmlsetups mml:notanumber \mathopnolimits{NaN} \stopxmlsetups \startxmlsetups mml:true \mathopnolimits{true} \stopxmlsetups \startxmlsetups mml:false \mathopnolimits{false} \stopxmlsetups -\startxmlsetups mml:emptyset \mathopnolimits{\O} \stopxmlsetups +\startxmlsetups mml:emptyset \mathopnolimits{Ø} \stopxmlsetups \startxmlsetups mml:pi \pi \stopxmlsetups \startxmlsetups mml:eulergamma \gamma \stopxmlsetups \startxmlsetups mml:infinity \infty \stopxmlsetups @@ -2018,7 +2021,7 @@ \overline{\left)\strut\xmlflush{#1}\right.} } { \doifelse \mmlmenclosenotation {mml:enclose:actuarial} { - \overline{\left.\strut\xmlflush{#1}\right|} + \overline{\left.\strut\xmlflush{#1}\right\vert} } { \doifelse \mmlmenclosenotation {mml:enclose:radical} { \sqrt{\xmlflush{#1}} @@ -2032,7 +2035,7 @@ \overline{\left)\strut\xmlflush{#1}\right.} } { \expanded{\doifelseinset {mml:enclose:actuarial} {\mmlmenclosenotation}} { - \overline{\left.\strut\xmlflush{#1}\right|} + \overline{\left.\strut\xmlflush{#1}\right\vert} } { \expanded{\doifelseinset {mml:enclose:radical} {\mmlmenclosenotation}} { \sqrt{\xmlflush{#1}} @@ -2418,7 +2421,11 @@ % tables (mml:mtable, mml:mtr, mml:mlabledtr, mml:mtd) \startxmlsetups mml:mtable % some more attributes need to be supported - \vcenter{\ctxmodulemathml{mtable("#1")}} + \vcenter { + \hbox {% needed because otherwise positions makr the vcenter wide + \ctxmodulemathml{mtable("#1")} + } + } \stopxmlsetups \startxmlsetups mml:mcolumn diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 56687d5db..9c2f4732b 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 : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 04/08/15 21:31:36 +-- merge date : 04/09/15 20:56:25 do -- begin closure to overcome local limits and interference @@ -4393,7 +4393,8 @@ function constructors.scale(tfmdata,specification) local stackmath=not properties.nostackmath local nonames=properties.noglyphnames local haskerns=properties.haskerns or properties.mode=="base" - local hasligatures=properties.hasligatures or properties.mode=="base" + local hasligatures=properties.hasligatures or properties.mode=="base" + local realdimensions=properties.realdimensions if changed and not next(changed) then changed=false end @@ -4474,6 +4475,26 @@ function constructors.scale(tfmdata,specification) local width=description.width local height=description.height local depth=description.depth + if realdimensions then + if not height or height==0 then + local bb=description.boundingbox + local ht=bb[4] + if ht~=0 then + height=ht + end + if not depth or depth==0 then + local dp=-bb[2] + if dp~=0 then + depth=dp + end + end + elseif not depth or depth==0 then + local dp=-description.boundingbox[2] + if dp~=0 then + depth=dp + end + end + end if width then width=hdelta*width else width=scaledwidth end if height then height=vdelta*height else height=scaledheight end if depth and depth~=0 then @@ -7609,15 +7630,16 @@ actions["add dimensions"]=function(data,filename) report_otf("mark %a with width %b found in %a",d.name or "",wd,basename) end if bb then - local ht,dp=bb[4],-bb[2] - if ht==0 or ht<0 then - else - d.height=ht - end - if dp==0 or dp<0 then - else - d.depth=dp - end + local ht=bb[4] + local dp=-bb[2] + if ht==0 or ht<0 then + else + d.height=ht + end + if dp==0 or dp<0 then + else + d.depth=dp + end end end end -- cgit v1.2.3