summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context.mkiv3
-rw-r--r--tex/context/base/font-syn.lua88
-rw-r--r--tex/context/base/lpdf-ano.lua2
-rw-r--r--tex/context/base/lpdf-ini.lua36
-rw-r--r--tex/context/base/math-def.mkiv2
-rw-r--r--tex/context/base/math-dim.lua5
-rw-r--r--tex/context/base/strc-bkm.lua2
-rw-r--r--tex/context/base/strc-bkm.mkiv3
-rw-r--r--tex/context/base/strc-mat.mkiv6
-rw-r--r--tex/context/base/strc-ref.lua8
-rw-r--r--tex/context/base/strc-ref.mkii3
-rw-r--r--tex/context/base/strc-ref.mkiv3
-rw-r--r--tex/context/base/tabl-tbl.mkiv47
-rw-r--r--tex/context/base/trac-log.lua6
15 files changed, 134 insertions, 82 deletions
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index fb5112020..a4157ada6 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -25,7 +25,7 @@
%
% \setbreakpoints[compound]
-\ctxlua{logs.report=function(s,...) commands.writestatus("!"..s,...) end}
+\ctxlua{logs.report=function(s,t,...) commands.writestatus("!"..s,string.format(t,...)) end}
\unprotect
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 51f5d92d4..173e6a3d9 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -20,7 +20,8 @@
\loadcorefile{syst-ini}
-\ifnum\luatexversion<47 % also change message
+% \ifnum\luatexversion<47 % also change message
+\ifnum\luatexversion<46 % also change message
\writestatus{!!!!}{Your luatex binary is too old, you need at least version 0.47!}
\expandafter\end
\fi
diff --git a/tex/context/base/font-syn.lua b/tex/context/base/font-syn.lua
index c331d6065..e80df71ea 100644
--- a/tex/context/base/font-syn.lua
+++ b/tex/context/base/font-syn.lua
@@ -192,6 +192,7 @@ for combination with the weight of a font.</p>
filters.list = {
"otf", "ttf", "ttc", "dfont", "afm",
+--~ "ttc", "otf", "ttf", "dfont", "afm",
}
names.xml_configuration_file = "fonts.conf" -- a bit weird format, bonus feature
@@ -499,7 +500,7 @@ local function checkduplicates()
end
local sorter = function(a,b)
- return #a < #b and a < b
+ return a > b -- to be checked
end
local function sorthashes()
@@ -810,53 +811,64 @@ here is for testing purposes only (it deals with names prefixed by an
encoding name).</p>
--ldx]]--
--- if names.be_clever then -- this will become obsolete
--- local encoding, tag = match(name,"^(.-)[%-%:](.+)$")
--- local mt = mapping[tag]
--- if tag and fonts.enc.is_known(encoding) and mt then
--- return mt[1], encoding .. "-" .. mt[3], mt[4]
--- end
--- end
-
--- simple search
-
-local function found(mapping,sorted,name,sub)
- local found = mapping[name]
- -- obsolete: old encoding test
- if not found then
- for k,v in next, mapping do
- if find(k,name) then
- found = v
- break
- end
- end
- if not found then
- local condensed = gsub(name,"[^%a%d]","")
- found = mapping[condensed]
- if not found then
- for k=1,#sorted do
- local v = sorted[k]
- if find(v,condensed) then
- found = mapping[v]
- break
- end
- end
- end
+local function fuzzy(mapping,sorted,name,sub)
+ local condensed = gsub(name,"[^%a%d]","")
+ for k=1,#sorted do
+ local v = sorted[k]
+ if find(v,condensed) then
+ return mapping[v], v
end
end
- return found
end
-local function foundname(name,sub)
+-- we could cache a lookup .. maybe some day ... (only when auto loaded!)
+
+local function foundname(name,sub) -- sub is not used currently
local data = names.data
local mappings, sorted_mappings = data.mappings, data.sorted_mappings
local fallbacks, sorted_fallbacks = data.fallbacks, data.sorted_fallbacks
local list = filters.list
+ -- dilemma: we lookup in the order otf ttf ttc ... afm but now an otf fallback
+ -- can come after an afm match ... well, one should provide nice names anyway
+ -- and having two lists is not an option
for i=1,#list do
local l = list[i]
- local okay = found(mappings[l],sorted_mappings[l],name,sub) or found(fallbacks[l],sorted_fallbacks[l],name,sub)
- if okay then
- return okay
+ local found = mappings[l][name]
+ if found then
+ if trace_names then
+ logs.report("fonts","resolved via direct name match: '%s'",name)
+ end
+ return found
+ end
+ end
+ for i=1,#list do
+ local l = list[i]
+ local found, fname = fuzzy(mappings[l],sorted_mappings[l],name,sub)
+ if found then
+ if trace_names then
+ logs.report("fonts","resolved via fuzzy name match: '%s' => '%s'",name,fname)
+ end
+ return found
+ end
+ end
+ for i=1,#list do
+ local l = list[i]
+ local found = fallbacks[l][name]
+ if found then
+ if trace_names then
+ logs.report("fonts","resolved via direct fallback match: '%s'",name)
+ end
+ return found
+ end
+ end
+ for i=1,#list do
+ local l = list[i]
+ local found, fname = fuzzy(sorted_mappings[l],sorted_fallbacks[l],name,sub)
+ if found then
+ if trace_names then
+ logs.report("fonts","resolved via fuzzy fallback match: '%s' => '%s'",name,fname)
+ end
+ return found
end
end
end
diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua
index 0bbef0e49..2ebb98bb6 100644
--- a/tex/context/base/lpdf-ano.lua
+++ b/tex/context/base/lpdf-ano.lua
@@ -549,7 +549,7 @@ local function build(levels,start,parent,method)
local level, title, reference, open = li[1], li[2], li[3], li[4]
if level == startlevel then
if trace_bookmarks then
- logs.report("bookmark","%3i %s%s %s",realpage,rep(" ",level-1),(open and "+") or "-",title)
+ logs.report("bookmark","%3i %s%s %s",reference.realpage,rep(" ",level-1),(open and "+") or "-",title)
end
local prev = child
child = pdfreserveobj()
diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua
index 526a3a4d2..437fa4c8a 100644
--- a/tex/context/base/lpdf-ini.lua
+++ b/tex/context/base/lpdf-ini.lua
@@ -15,6 +15,7 @@ local texwrite = tex.write
local sind, cosd = math.sind, math.cosd
local trace_finalizers = false trackers.register("backend.finalizers", function(v) trace_finalizers = v end)
+local trace_resources = false trackers.register("backend.resources", function(v) trace_resources = v end)
lpdf = lpdf or { }
@@ -471,11 +472,24 @@ function lpdf.finalizedocument()
end
end
+-- some minimal tracing, handy for checking the order
+
+local function trace_set(what,key)
+ if trace_resources then
+ logs.report("backend", "setting key '%s' in '%s'",key,what)
+ end
+end
+local function trace_flush(what)
+ if trace_resources then
+ logs.report("backend", "flushing '%s'",what)
+ end
+end
+
local catalog, info, names = pdfdictionary(), pdfdictionary(), pdfdictionary()
-local function flushcatalog() if not environment.initex then pdf.pdfcatalog = catalog() end end
-local function flushinfo () if not environment.initex then pdf.pdfinfo = info () end end
-local function flushnames () if not environment.initex then pdf.pdfnames = names () end end
+local function flushcatalog() if not environment.initex then trace_flush("catalog") pdf.pdfcatalog = catalog() end end
+local function flushinfo () if not environment.initex then trace_flush("info") pdf.pdfinfo = info () end end
+local function flushnames () if not environment.initex then trace_flush("names") pdf.pdfnames = names () end end
if not pdf.pdfcatalog then
@@ -489,9 +503,9 @@ end
lpdf.protectresources = true
-function lpdf.addtocatalog(k,v) if not (lpdf.protectresources and catalog[k]) then catalog[k] = v end end
-function lpdf.addtoinfo (k,v) if not (lpdf.protectresources and info [k]) then info [k] = v end end
-function lpdf.addtonames (k,v) if not (lpdf.protectresources and names [k]) then names [k] = v end end
+function lpdf.addtocatalog(k,v) if not (lpdf.protectresources and catalog[k]) then trace_set("catalog",k) catalog[k] = v end end
+function lpdf.addtoinfo (k,v) if not (lpdf.protectresources and info [k]) then trace_set("info", k) info [k] = v end end
+function lpdf.addtonames (k,v) if not (lpdf.protectresources and names [k]) then trace_set("names", k) names [k] = v end end
local r_extgstates, d_extgstates = pdfreserveobj(), pdfdictionary() local p_extgstates = pdfreference(r_extgstates)
local r_colorspaces, d_colorspaces = pdfreserveobj(), pdfdictionary() local p_colorspaces = pdfreference(r_colorspaces)
@@ -503,10 +517,10 @@ local function checkcolorspaces() if next(d_colorspaces) then lpdf.addtopagereso
local function checkpatterns () if next(d_patterns ) then lpdf.addtopageresources("Pattern", p_patterns ) end end
local function checkshades () if next(d_shades ) then lpdf.addtopageresources("Shading", p_shades ) end end
-local function flushextgstates () if next(d_extgstates ) then pdfimmediateobj(r_extgstates, tostring(d_extgstates )) end end
-local function flushcolorspaces() if next(d_colorspaces) then pdfimmediateobj(r_colorspaces,tostring(d_colorspaces)) end end
-local function flushpatterns () if next(d_patterns ) then pdfimmediateobj(r_patterns, tostring(d_patterns )) end end
-local function flushshades () if next(d_shades ) then pdfimmediateobj(r_shades, tostring(d_shades )) end end
+local function flushextgstates () if next(d_extgstates ) then trace_flush("extgstates") pdfimmediateobj(r_extgstates, tostring(d_extgstates )) end end
+local function flushcolorspaces() if next(d_colorspaces) then trace_flush("colorspaces") pdfimmediateobj(r_colorspaces,tostring(d_colorspaces)) end end
+local function flushpatterns () if next(d_patterns ) then trace_flush("patterns") pdfimmediateobj(r_patterns, tostring(d_patterns )) end end
+local function flushshades () if next(d_shades ) then trace_flush("shades") pdfimmediateobj(r_shades, tostring(d_shades )) end end
local collected = pdfdictionary {
ExtGState = p_extgstates,
@@ -538,7 +552,7 @@ lpdf.registerpagefinalizer(checkcolorspaces,3)
lpdf.registerpagefinalizer(checkpatterns,3)
lpdf.registerpagefinalizer(checkshades,3)
---
+-- in strc-bkm: lpdf.registerdocumentfinalizer(function() structure.bookmarks.place() end,1)
function lpdf.rotationcm(a)
local s, c = sind(a), cosd(a)
diff --git a/tex/context/base/math-def.mkiv b/tex/context/base/math-def.mkiv
index e9291893b..79c832b4f 100644
--- a/tex/context/base/math-def.mkiv
+++ b/tex/context/base/math-def.mkiv
@@ -87,7 +87,7 @@
\definemathcommand [max] [limop] {\mfunction{max}}
\definemathcommand [min] [limop] {\mfunction{min}}
\definemathcommand [mod] [limop] {\mfunction{mod}}
-\definemathcommand [div] [limop] {\mfunction{div}}
+%definemathcommand [div] [limop] {\mfunction{div}} % overloads \div symbol
\definemathcommand [projlim] [limop] {\mfunction{proj\,lim}}
\definemathcommand [Pr] [limop] {\mfunction{Pr}}
\definemathcommand [sec] [nolop] {\mfunction{sec}}
diff --git a/tex/context/base/math-dim.lua b/tex/context/base/math-dim.lua
index 754ca8314..76d7a33dc 100644
--- a/tex/context/base/math-dim.lua
+++ b/tex/context/base/math-dim.lua
@@ -248,6 +248,7 @@ function mathematics.dimensions(dimens)
end
t[variable] = tt
end
+logs.report("warning", "version 0.47 is needed for proper delimited math")
local d = {
AxisHeight = t . axis . text_style,
AccentBaseHeight = t . accent_base_height . text_style,
@@ -260,8 +261,8 @@ function mathematics.dimensions(dimens)
FractionNumeratorGapMin = t . fraction_num_vgap . text_style,
FractionNumeratorShiftUp = t . fraction_num_up . text_style,
FractionRuleThickness = t . fraction_rule . text_style,
- FractionDelimiterSize = t . fraction_del_size . text_style,
- FractionDelimiterDisplayStyleSize = t . fraction_del_size . display_style,
+-- FractionDelimiterSize = t . fraction_del_size . text_style,
+-- FractionDelimiterDisplayStyleSize = t . fraction_del_size . display_style,
LowerLimitBaselineDropMin = t . limit_below_bgap . text_style,
LowerLimitGapMin = t . limit_below_vgap . text_style,
OverbarExtraAscender = t . overbar_kern . text_style,
diff --git a/tex/context/base/strc-bkm.lua b/tex/context/base/strc-bkm.lua
index f098ea864..286169153 100644
--- a/tex/context/base/strc-bkm.lua
+++ b/tex/context/base/strc-bkm.lua
@@ -86,6 +86,8 @@ function bookmarks.place()
end
end
+lpdf.registerdocumentfinalizer(function() structure.bookmarks.place() end,1)
+
-- bkm
--~ function nodes.toutf(list)
--~ local t= { }
diff --git a/tex/context/base/strc-bkm.mkiv b/tex/context/base/strc-bkm.mkiv
index 9298a9d8e..85d41f327 100644
--- a/tex/context/base/strc-bkm.mkiv
+++ b/tex/context/base/strc-bkm.mkiv
@@ -67,7 +67,8 @@
\fi
\fi}
-\appendtoks\ctxlua{structure.bookmarks.place()}\to\everystoptext
+% \prependtoks\ctxlua{structure.bookmarks.place()}\to\everystoptext % too late
+% \prependtoks\ctxlua{structure.bookmarks.place()}\to\everylastbackendshipout % okay but not nice
\protect \endinput
diff --git a/tex/context/base/strc-mat.mkiv b/tex/context/base/strc-mat.mkiv
index a7b07f083..038c5cb34 100644
--- a/tex/context/base/strc-mat.mkiv
+++ b/tex/context/base/strc-mat.mkiv
@@ -496,8 +496,10 @@
\newif\ifclipdisplaymath \clipdisplaymathtrue
\def\displaymathclipfactor{1.1}
-\let\startinnermath\empty
-\let\stopinnermath \empty
+% already defined
+%
+% \let\startinnermath\empty
+% \let\stopinnermath \empty
% \defineformulaalternative[multi][\begindmath][\enddmath]
%
diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua
index 8cc63d50e..4c94fbbe7 100644
--- a/tex/context/base/strc-ref.lua
+++ b/tex/context/base/strc-ref.lua
@@ -235,6 +235,10 @@ function jobreferences.urls.get(name,method,space) -- method: none, before, afte
end
end
+function commands.doifurldefinedelse(name)
+ commands.doifelse(urls[name])
+end
+
-- files
jobreferences.files = jobreferences.files or { }
@@ -255,6 +259,10 @@ function jobreferences.files.get(name,method,space) -- method: none, before, aft
end
end
+function commands.doiffiledefinedelse(name)
+ commands.doifelse(files[name])
+end
+
-- programs
jobreferences.programs = jobreferences.programs or { }
diff --git a/tex/context/base/strc-ref.mkii b/tex/context/base/strc-ref.mkii
index d06319d07..1df5d09d8 100644
--- a/tex/context/base/strc-ref.mkii
+++ b/tex/context/base/strc-ref.mkii
@@ -2296,6 +2296,9 @@
\doexternaldocument{#1}{#2}{\url[#3]}%
\egroup}
+\def\doifurldefinedelse #1{\doifdefinedelse{\v!file:::#1}}
+\def\doiffiledefinedelse#1{\doifdefinedelse{\v!file:::#1}}
+
%D \macros
%D {url,setupurl}
%D
diff --git a/tex/context/base/strc-ref.mkiv b/tex/context/base/strc-ref.mkiv
index cbed71d68..91643fc72 100644
--- a/tex/context/base/strc-ref.mkiv
+++ b/tex/context/base/strc-ref.mkiv
@@ -1201,6 +1201,9 @@
\def\dousefile[#1][#2][#3]%
{\ctxlua{jobreferences.files.define("#1",\!!bs\detokenize{#2}\!!es,\!!bs\detokenize{#3}\!!es)}}
+\def\doifurldefinedelse #1{\ctxlua{commands.doifurldefinedelse ("#1")}}
+\def\doiffiledefinedelse#1{\ctxlua{commands.doiffiledefinedelse("#1")}}
+
%D \macros
%D {url,setupurl}
%D
diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv
index 6942327fe..8e4505977 100644
--- a/tex/context/base/tabl-tbl.mkiv
+++ b/tex/context/base/tabl-tbl.mkiv
@@ -947,7 +947,7 @@
%D When set to true, no (less) break optimization is done.
-\newif\iftolerantTABLEbreak
+\newif\iftolerantTABLEbreak % used in styles !
%D The main processing macro is large but splitting it up
%D would make things less clear.
@@ -1042,26 +1042,31 @@
\global\tabulatecolumn\zerocount
\resettabulatepheight
\unskip\unskip\crcr\flushtabulated
- \TABLEnoalign
- {\the\everyaftertabulaterow}%
- \TABLEnoalign
- {\iftolerantTABLEbreak\else
- \ifconditional\tabulatesomeamble \ifcase\tabulaterepeathead \else
- \allowbreak
- \fi \fi
- \ifnum\noftabulatelines=\plusone
- \dotabulatenobreak
- \else\ifnum\noftabulatelines=\minusnoftabulatelines
- \ifnum\tabulatemaxplines<\plustwo
- \dotabulatenobreak
- \else
- \allowbreak % needed with pbreak prevention
- \fi
- \else
- \allowbreak % needed with pbreak prevention
- \fi\fi
- \fi
- \global\tabulatefirstflushedfalse}}
+ \TABLEnoalign{\the\everyaftertabulaterow}%
+ \TABLEnoalign{\checktabulatepenaltiesa}}
+
+\def\checktabulatepenaltiesa
+ {\iftolerantTABLEbreak\else
+ \ifnum\totalnoftabulatelines=\plusone
+ % \allowbreak
+ \else
+ \ifconditional\tabulatesomeamble \ifcase\tabulaterepeathead \else
+ \allowbreak
+ \fi \fi
+ \ifnum\noftabulatelines=\plusone
+ \dotabulatenobreak
+ \else\ifnum\noftabulatelines=\minusnoftabulatelines
+ \ifnum\tabulatemaxplines<\plustwo
+ \dotabulatenobreak
+ \else
+ \allowbreak % needed with pbreak prevention
+ \fi
+ \else
+ \allowbreak % needed with pbreak prevention
+ \fi\fi
+ \fi
+ \fi
+ \global\tabulatefirstflushedfalse}
\def\tabulatebbskiptwo
{\ifvoid\tablebox\tabulatecolumn
diff --git a/tex/context/base/trac-log.lua b/tex/context/base/trac-log.lua
index d50dadf6e..b68660a8e 100644
--- a/tex/context/base/trac-log.lua
+++ b/tex/context/base/trac-log.lua
@@ -123,12 +123,12 @@ function logs.tex.stop_page_number()
if real > 0 then
if user > 0 then
if sub > 0 then
- logs.report("pages", "flushing page, realpage %s, userpage %s, subpage %s",real,user,sub)
+ logs.report("pages", "flushing realpage %s, userpage %s, subpage %s",real,user,sub)
else
- logs.report("pages", "flushing page, realpage %s, userpage %s",real,user)
+ logs.report("pages", "flushing realpage %s, userpage %s",real,user)
end
else
- logs.report("pages", "flushing page, realpage %s",real)
+ logs.report("pages", "flushing realpage %s",real)
end
else
logs.report("pages", "flushing page")