diff options
Diffstat (limited to 'tex/context')
37 files changed, 442 insertions, 242 deletions
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex a1a04de92..4cae0a462 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/mkiv/back-pdf.lua b/tex/context/base/mkiv/back-pdf.lua index 0821abb28..323f1d57f 100644 --- a/tex/context/base/mkiv/back-pdf.lua +++ b/tex/context/base/mkiv/back-pdf.lua @@ -25,6 +25,8 @@ local scankeyword = scanners.keyword local scanners = interfaces.scanners local implement = interfaces.implement +local report = logs.reporter("backend") + local outputfilename function codeinjections.getoutputfilename() @@ -145,6 +147,15 @@ scanners.pdfstartmirroring = function() context(pdfsetmatrix(-1,0,0,1)) end +if environment.arguments.nocompression then + pdf.setcompresslevel(0) + pdf.setobjcompresslevel(0) + function pdf.setcompresslevel() + -- blocked from now on + end + pdf.setobjcompresslevel = pdf.setcompresslevel +end + scanners.pdfstopmirroring = scanners.pdfstartmirroring -- todo, change the above to implement too -- diff --git a/tex/context/base/mkiv/char-ini.lua b/tex/context/base/mkiv/char-ini.lua index ad53cae8f..63328a177 100644 --- a/tex/context/base/mkiv/char-ini.lua +++ b/tex/context/base/mkiv/char-ini.lua @@ -1083,8 +1083,8 @@ if not characters.lhash then lhash[utfchar(k)] = utfchar(l) elseif #l == 2 then lhash[utfchar(k)] = utfchar(l[1]) .. utfchar(l[2]) - else - inspect(v) + -- else + -- inspect(v) end else local u = v.uccode @@ -1094,8 +1094,8 @@ if not characters.lhash then uhash[utfchar(k)] = utfchar(u) elseif #u == 2 then uhash[utfchar(k)] = utfchar(u[1]) .. utfchar(u[2]) - else - inspect(v) + -- else + -- inspect(v) end end end @@ -1105,8 +1105,8 @@ if not characters.lhash then shash[utfchar(k)] = utfchar(s) elseif #s == 2 then shash[utfchar(k)] = utfchar(s[1]) .. utfchar(s[2]) - else - inspect(v) + -- else + -- inspect(v) end end -- end diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 3e5ff1ffc..975d8dc5c 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{2016.05.01 09:52} +\newcontextversion{2016.05.07 14:37} %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-todo.tex b/tex/context/base/mkiv/context-todo.tex index 0674ad9fb..66889c4d3 100644 --- a/tex/context/base/mkiv/context-todo.tex +++ b/tex/context/base/mkiv/context-todo.tex @@ -18,6 +18,13 @@ \startitem add \type {--output-filename} for \PDF\ filename \stopitem + \startitem + more consistent \type {lang_variables} and \type {tex_language} in \type + {texlang.w} and also store the \type {*mins} + \stopitem + \startitem + get rid of \type {temp} node in hyphenator i.e. postpone to when needed + \stopitem \stopitemize \subsubject{\CONTEXT} @@ -33,7 +40,7 @@ play with box attributes \stopitem \startitem - check consistency between foonotes and running text (main color, + check consistency between footnotes and running text (main color, styles, properties) \stopitem \startitem diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 7ec285ed1..ab8eafd4d 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2016.05.01 09:52} +\edef\contextversion{2016.05.07 14:37} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/core-con.lua b/tex/context/base/mkiv/core-con.lua index bfe5357a6..6913ac569 100644 --- a/tex/context/base/mkiv/core-con.lua +++ b/tex/context/base/mkiv/core-con.lua @@ -19,8 +19,9 @@ slower but look nicer this way.</p> local floor, date, time, concat = math.floor, os.date, os.time, table.concat local lower, upper, rep, match, gsub = string.lower, string.upper, string.rep, string.match, string.gsub local utfchar, utfbyte = utf.char, utf.byte -local tonumber, tostring = tonumber, tostring -local P, C, Cs, lpegmatch = lpeg.P, lpeg.C, lpeg.Cs, lpeg.match +local tonumber, tostring, type, rawset = tonumber, tostring, type, rawset +local P, S, R, Cc, Cf, Cg, Ct, Cs, C = lpeg.P, lpeg.S, lpeg.R, lpeg.Cc, lpeg.Cf, lpeg.Cg, lpeg.Ct, lpeg.Cs, lpeg.C +local lpegmatch = lpeg.match local context = context local commands = commands @@ -33,6 +34,8 @@ local formatters = string.formatters local variables = interfaces.variables local constants = interfaces.constants +local texset = tex.set + converters = converters or { } local converters = converters @@ -1355,3 +1358,39 @@ implement { actions = { formatters["U+%05X"], context }, arguments = "integer" } + +local n = lpeg.R("09")^1 / tonumber + +local p = Cf( Ct("") + * Cg(Cc("year") * (n )) * P("-")^-1 + * Cg(Cc("month") * (n + Cc( 1))) * P("-")^-1 + * Cg(Cc("day") * (n + Cc( 1))) * lpeg.patterns.whitespace^-1 + * Cg(Cc("hour") * (n + Cc( 0))) * P(":")^-1 + * Cg(Cc("min") * (n + Cc( 0))) + , rawset) + +function converters.totime(s) + if not s then + return + elseif type(s) == "table" then + return s + elseif type(s) == "string" then + return lpegmatch(p,s) + end + local n = tonumber(s) + if n and n >= 0 then + return date("*t",n) + end +end + +function converters.settime(t) + if type(t) ~= "table" then + t = converters.totime(t) + end + if t then + texset("year", t.year or 1000) + texset("month", t.month or 1) + texset("day", t.day or 1) + texset("time", (t.hour or 0) * 60 + (t.min or 0)) + end +end diff --git a/tex/context/base/mkiv/font-chk.lua b/tex/context/base/mkiv/font-chk.lua index 5b1ad9920..15291052f 100644 --- a/tex/context/base/mkiv/font-chk.lua +++ b/tex/context/base/mkiv/font-chk.lua @@ -437,7 +437,7 @@ local function adddummysymbols(tfmdata,...) -- end end -registerotffeature { +local dummies_specification = { name = "dummies", description = "dummy symbols", default = true, @@ -447,15 +447,8 @@ registerotffeature { } } -registerafmfeature { - name = "dummies", - description = "dummy symbols", - default = true, - manipulators = { - base = adddummysymbols, - node = adddummysymbols, - } -} +registerotffeature(dummies_specification) +registerafmfeature(dummies_specification) -- callback.register("char_exists",function(f,c) -- to slow anyway as called often so we should flag in tfmdata -- return true diff --git a/tex/context/base/mkiv/font-enh.lua b/tex/context/base/mkiv/font-enh.lua index 3439a434a..f3209f5ee 100644 --- a/tex/context/base/mkiv/font-enh.lua +++ b/tex/context/base/mkiv/font-enh.lua @@ -173,7 +173,7 @@ local function initializeunicoding(tfmdata) end end -registerafmfeature { +local unicoding_specification = { name = "unicoding", description = "adapt unicode table", initializers = { @@ -186,15 +186,5 @@ registerafmfeature { -- } } -registerotffeature { - name = "unicoding", - description = "adapt unicode table", - initializers = { - base = initializeunicoding, - node = initializeunicoding, - }, - -- manipulators = { - -- base = finalizeunicoding, - -- node = finalizeunicoding, - -- } -} +registerotffeature(unicoding_specification) +registerafmfeature(unicoding_specification) diff --git a/tex/context/base/mkiv/font-ext.lua b/tex/context/base/mkiv/font-ext.lua index 79144aa70..189a588f1 100644 --- a/tex/context/base/mkiv/font-ext.lua +++ b/tex/context/base/mkiv/font-ext.lua @@ -149,7 +149,7 @@ local function initializeexpansion(tfmdata,value) end end -registerotffeature { +local expansion_specification = { name = "expansion", description = "apply hz optimization", initializers = { @@ -158,14 +158,8 @@ registerotffeature { } } -registerafmfeature { - name = "expansion", - description = "apply hz optimization", - initializers = { - base = initializeexpansion, - node = initializeexpansion, - } -} +registerotffeature(expansion_specification) +registerafmfeature(expansion_specification) fonts.goodies.register("expansions", function(...) return fonts.goodies.report("expansions", trace_expansion, ...) end) @@ -466,7 +460,7 @@ local function initializeprotrusion(tfmdata,value) end end -registerotffeature { +local protrusion_specification = { name = "protrusion", description = "l/r margin character protrusion", initializers = { @@ -475,14 +469,8 @@ registerotffeature { } } -registerafmfeature { - name = "protrusion", - description = "shift characters into the left and or right margin", - initializers = { - base = initializeprotrusion, - node = initializeprotrusion, - } -} +registerotffeature(protrusion_specification) +registerafmfeature(protrusion_specification) fonts.goodies.register("protrusions", function(...) return fonts.goodies.report("protrusions", trace_protrusion, ...) end) @@ -534,7 +522,7 @@ local function initializeitlc(tfmdata,value) -- hm, always value end end -registerotffeature { +local italic_specification = { name = "itlc", description = "italic correction", initializers = { @@ -543,20 +531,14 @@ registerotffeature { } } -registerafmfeature { - name = "itlc", - description = "italic correction", - initializers = { - base = initializeitlc, - node = initializeitlc, - } -} +registerotffeature(italic_specification) +registerafmfeature(italic_specification) local function initializetextitalics(tfmdata,value) -- yes no delay tfmdata.properties.textitalics = toboolean(value) end -registerotffeature { +local textitalics_specification = { name = "textitalics", description = "use alternative text italic correction", initializers = { @@ -565,20 +547,14 @@ registerotffeature { } } -registerafmfeature { - name = "textitalics", - description = "use alternative text italic correction", - initializers = { - base = initializetextitalics, - node = initializetextitalics, - } -} +registerotffeature(textitalics_specification) +registerafmfeature(textitalics_specification) local function initializemathitalics(tfmdata,value) -- yes no delay tfmdata.properties.mathitalics = toboolean(value) end -registerotffeature { +local mathitalics_specification = { name = "mathitalics", description = "use alternative math italic correction", initializers = { @@ -587,14 +563,8 @@ registerotffeature { } } -registerafmfeature { - name = "mathitalics", - description = "use alternative math italic correction", - initializers = { - base = initializemathitalics, - node = initializemathitalics, - } -} +registerotffeature(mathitalics_specification) +registerafmfeature(mathitalics_specification) -- slanting @@ -610,7 +580,7 @@ local function initializeslant(tfmdata,value) tfmdata.parameters.slantfactor = value end -registerotffeature { +local slant_specification = { name = "slant", description = "slant glyphs", initializers = { @@ -619,14 +589,8 @@ registerotffeature { } } -registerafmfeature { - name = "slant", - description = "slant glyphs", - initializers = { - base = initializeslant, - node = initializeslant, - } -} +registerotffeature(slant_specification) +registerafmfeature(slant_specification) local function initializeextend(tfmdata,value) value = tonumber(value) @@ -640,7 +604,7 @@ local function initializeextend(tfmdata,value) tfmdata.parameters.extendfactor = value end -registerotffeature { +local extend_specification = { name = "extend", description = "scale glyphs horizontally", initializers = { @@ -649,14 +613,8 @@ registerotffeature { } } -registerafmfeature { - name = "extend", - description = "scale glyphs horizontally", - initializers = { - base = initializeextend, - node = initializeextend, - } -} +registerotffeature(extend_specification) +registerafmfeature(extend_specification) -- For Wolfgang Schuster: -- @@ -745,7 +703,7 @@ local function manipulatedimensions(tfmdata,key,value) end end -registerotffeature { +local dimensions_specification = { name = "dimensions", description = "force dimensions", manipulators = { @@ -754,6 +712,9 @@ registerotffeature { } } +registerotffeature(dimensions_specification) +registerafmfeature(dimensions_specification) + -- for zhichu chen (see mailing list archive): we might add a few more variants -- in due time -- diff --git a/tex/context/base/mkiv/font-fbk.lua b/tex/context/base/mkiv/font-fbk.lua index 9ef0706d2..3734e8071 100644 --- a/tex/context/base/mkiv/font-fbk.lua +++ b/tex/context/base/mkiv/font-fbk.lua @@ -251,7 +251,7 @@ local function composecharacters(tfmdata) end end -registerotffeature { +local compose_specification = { name = "compose", description = "additional composed characters", manipulators = { @@ -260,14 +260,8 @@ registerotffeature { } } -registerafmfeature { - name = "compose", - description = "additional composed characters", - manipulators = { - base = composecharacters, - node = composecharacters, - } -} +registerotffeature(compose_specification) +registerafmfeature(compose_specification) vf.helpers.composecharacters = composecharacters diff --git a/tex/context/base/mkiv/font-gbn.lua b/tex/context/base/mkiv/font-gbn.lua index daa072b4b..a02406b75 100644 --- a/tex/context/base/mkiv/font-gbn.lua +++ b/tex/context/base/mkiv/font-gbn.lua @@ -126,17 +126,19 @@ function nodes.handlers.nodepass(head) local variant = hash[getchar(p)] if variant then setchar(p,variant) - if not redundant then - redundant = { n } - else - redundant[#redundant+1] = n - end end end end + -- per generic user request we always remove selectors + if not redundant then + redundant = { n } + else + redundant[#redundant+1] = n + end end end end + local nofbasefonts = #basefonts if redundant then for i=1,#redundant do local r = redundant[i] @@ -147,8 +149,8 @@ function nodes.handlers.nodepass(head) else setlink(p,n) end - if b > 0 then - for i=1,b do + if nofbasefonts > 0 then + for i=1,nofbasefonts do local bi = basefonts[i] if r == bi[1] then bi[1] = n @@ -192,8 +194,8 @@ function nodes.handlers.nodepass(head) end end end - if basemodepass and #basefonts > 0 then - for i=1,#basefonts do + if basemodepass and nofbasefonts > 0 then + for i=1,nofbasefonts do local range = basefonts[i] local start = range[1] local stop = range[2] diff --git a/tex/context/base/mkiv/font-gds.lua b/tex/context/base/mkiv/font-gds.lua index 23bbad42f..52bb9c983 100644 --- a/tex/context/base/mkiv/font-gds.lua +++ b/tex/context/base/mkiv/font-gds.lua @@ -465,9 +465,9 @@ local function setextensions(tfmdata) end end --- installation (collected to keep the overview) -- also for type 1 +-- installation -registerotffeature { +local goodies_specification = { name = "goodies", description = "goodies on top of built in features", initializers = { @@ -477,6 +477,12 @@ registerotffeature { } } +registerotffeature(goodies_specification) +registerafmfeature(goodies_specification) +registertfmfeature(goodies_specification) + +-- maybe more of the following could be for type one too + registerotffeature { name = "extrafeatures", description = "extra features", @@ -527,30 +533,6 @@ registerotffeature { } } --- afm - -registerafmfeature { - name = "goodies", - description = "goodies on top of built in features", - initializers = { - position = 1, - base = setgoodies, - node = setgoodies, - } -} - --- tfm - -registertfmfeature { - name = "goodies", - description = "goodies on top of built in features", - initializers = { - position = 1, - base = setgoodies, - node = setgoodies, - } -} - -- experiment, we have to load the definitions immediately as they precede -- the definition so they need to be initialized in the typescript diff --git a/tex/context/base/mkiv/font-lib.mkvi b/tex/context/base/mkiv/font-lib.mkvi index 7bb042a59..90de409d1 100644 --- a/tex/context/base/mkiv/font-lib.mkvi +++ b/tex/context/base/mkiv/font-lib.mkvi @@ -36,9 +36,6 @@ \registerctxluafile{font-tfm}{1.001} -\registerctxluafile{font-afm}{1.001} -\registerctxluafile{font-afk}{1.001} - \registerctxluafile{font-hsh}{1.001} % hashes used by context \registerctxluafile{font-nod}{1.001} @@ -58,6 +55,12 @@ \registerctxluafile{font-oth}{1.001} \registerctxluafile{font-osd}{1.001} +% we use otf code for type one + +\registerctxluafile{font-one}{1.001} +%registerctxluafile{font-afm}{1.001} +\registerctxluafile{font-afk}{1.001} + % so far \registerctxluafile{font-pat}{1.001} % patchers diff --git a/tex/context/base/mkiv/font-otc.lua b/tex/context/base/mkiv/font-otc.lua index 871b6f13c..be9ba8660 100644 --- a/tex/context/base/mkiv/font-otc.lua +++ b/tex/context/base/mkiv/font-otc.lua @@ -61,8 +61,6 @@ local function addfeature(data,feature,specifications) end -- feature has to be unique but the name entry wins eventually - -- todo alse gpos - local fontfeatures = resources.features or everywhere local unicodes = resources.unicodes local splitter = lpeg.splitter(" ",unicodes) @@ -529,6 +527,7 @@ end otf.enhancers.addfeature = addfeature local extrafeatures = { } +local knownfeatures = { } function otf.addfeature(name,specification) if type(name) == "table" then @@ -536,16 +535,31 @@ function otf.addfeature(name,specification) name = specification.name end if type(name) == "string" then - extrafeatures[name] = specification + local slot = knownfeatures[name] + if slot then + -- we overload one + else + slot = #extrafeatures + 1 + knownfeatures[name] = slot + end + specification.name = name -- to be sure + extrafeatures[slot] = specification end end +-- for feature, specification in next, extrafeatures do +-- addfeature(data,feature,specification) +-- end + local function enhance(data,filename,raw) - for feature, specification in next, extrafeatures do - addfeature(data,feature,specification) + for slot=1,#extrafeatures do + local specification = extrafeatures[slot] + addfeature(data,specification.name,specification) end end +-- otf.enhancers.enhance = enhance + otf.enhancers.register("check extra features",enhance) -- tlig -- @@ -574,6 +588,7 @@ local tlig_specification = { otf.addfeature("tlig",tlig_specification) registerotffeature { + -- this makes it a known feature (in tables) name = 'tlig', description = 'tex ligatures', } @@ -598,6 +613,7 @@ local trep_specification = { otf.addfeature("trep",trep_specification) registerotffeature { + -- this makes it a known feature (in tables) name = 'trep', description = 'tex replacements', } @@ -699,6 +715,7 @@ local anum_specification = { otf.addfeature("anum",anum_specification) -- todo: only when there is already an arab script feature registerotffeature { + -- this makes it a known feature (in tables) name = 'anum', description = 'arabic digits', } diff --git a/tex/context/base/mkiv/font-otj.lua b/tex/context/base/mkiv/font-otj.lua index 6ff80d88d..b65a9db66 100644 --- a/tex/context/base/mkiv/font-otj.lua +++ b/tex/context/base/mkiv/font-otj.lua @@ -1255,11 +1255,11 @@ local function inject_everything(head,where) insert_node_after(pre,n,newkern(rightkern)) done = true end - end - if hasmarks then - local pm = i.markbasenode - if pm then - processmark(pm,current,i) + if hasmarks then + local pm = i.markbasenode + if pm then + processmark(pm,current,i) + end end end end @@ -1287,11 +1287,11 @@ local function inject_everything(head,where) insert_node_after(post,n,newkern(rightkern)) done = true end - end - if hasmarks then - local pm = i.markbasenode - if pm then - processmark(pm,current,i) + if hasmarks then + local pm = i.markbasenode + if pm then + processmark(pm,current,i) + end end end end @@ -1319,11 +1319,11 @@ local function inject_everything(head,where) insert_node_after(replace,n,newkern(rightkern)) done = true end - end - if hasmarks then - local pm = i.markbasenode - if pm then - processmark(pm,current,i) + if hasmarks then + local pm = i.markbasenode + if pm then + processmark(pm,current,i) + end end end end diff --git a/tex/context/base/mkiv/font-otl.lua b/tex/context/base/mkiv/font-otl.lua index f7b6eb5ae..01342a9be 100644 --- a/tex/context/base/mkiv/font-otl.lua +++ b/tex/context/base/mkiv/font-otl.lua @@ -101,6 +101,12 @@ registerdirective("fonts.otf.loader.forcenotdef", function(v) forcenotdef = -- end -- end +-- Enhancers are used to apply fixes and extensions to fonts. For instance, we use them +-- to implement tlig and trep features. They are not neccessarily bound to opentype +-- fonts but can also apply to type one fonts, given that they obey the structure of an +-- opentype font. They are not to be confused with format specific features but maybe +-- some are so generic that they might eventually move to this mechanism. + local ordered_enhancers = { "check extra features", } @@ -302,7 +308,7 @@ function otf.load(filename,sub,featurefile) -- second argument (format) is gone -- enhancers.apply(data,filename,data) -- - constructors.addcoreunicodes(unicodes) + -- constructors.addcoreunicodes(data.resources.unicodes) -- still needed ? -- if applyruntimefixes then applyruntimefixes(filename,data) diff --git a/tex/context/base/mkiv/font-oto.lua b/tex/context/base/mkiv/font-oto.lua index b7ee717c9..23beba787 100644 --- a/tex/context/base/mkiv/font-oto.lua +++ b/tex/context/base/mkiv/font-oto.lua @@ -450,3 +450,5 @@ registerotffeature { base = featuresinitializer, } } + +otf.basemodeinitializer = featuresinitializer diff --git a/tex/context/base/mkiv/font-ots.lua b/tex/context/base/mkiv/font-ots.lua index 21225c227..c173de2be 100644 --- a/tex/context/base/mkiv/font-ots.lua +++ b/tex/context/base/mkiv/font-ots.lua @@ -3652,6 +3652,9 @@ registerotffeature { } } +otf.nodemodeinitializer = featuresinitializer +otf.featuresprocessor = featuresprocessor + -- This can be used for extra handlers, but should be used with care! otf.handlers = handlers -- used in devanagari diff --git a/tex/context/base/mkiv/lang-def.mkiv b/tex/context/base/mkiv/lang-def.mkiv index e4906096e..5e40a33b0 100644 --- a/tex/context/base/mkiv/lang-def.mkiv +++ b/tex/context/base/mkiv/lang-def.mkiv @@ -341,7 +341,7 @@ \c!rightquotation=\upperrightdoubleninequote, \c!date={\v!year,.,\space,\v!month,\space,\v!day,.}] -\installlanguage [\s!finish] [\s!fi] +\installlanguage [\s!finnish] [\s!fi] \installlanguage [\s!hungarian] [\s!hu] % Altaic Languages: Uigur, Uzbek, Azeri/Azerbaijani, Chuvash, diff --git a/tex/context/base/mkiv/lang-ini.lua b/tex/context/base/mkiv/lang-ini.lua index eb7e32b89..00fdb3f09 100644 --- a/tex/context/base/mkiv/lang-ini.lua +++ b/tex/context/base/mkiv/lang-ini.lua @@ -40,8 +40,8 @@ local prehyphenchar = lang.prehyphenchar -- global per language local posthyphenchar = lang.posthyphenchar -- global per language local preexhyphenchar = lang.preexhyphenchar -- global per language local postexhyphenchar = lang.postexhyphenchar -- global per language -local lefthyphenmin = lang.lefthyphenmin -local righthyphenmin = lang.righthyphenmin +----- lefthyphenmin = lang.lefthyphenmin +----- righthyphenmin = lang.righthyphenmin local sethjcode = lang.sethjcode local uccodes = characters.uccodes @@ -344,8 +344,8 @@ function languages.prehyphenchar (what) return prehyphenchar (tolang(what)) function languages.posthyphenchar (what) return posthyphenchar (tolang(what)) end function languages.preexhyphenchar (what) return preexhyphenchar (tolang(what)) end function languages.postexhyphenchar(what) return postexhyphenchar(tolang(what)) end -function languages.lefthyphenmin (what) return lefthyphenmin (tolang(what)) end -function languages.righthyphenmin (what) return righthyphenmin (tolang(what)) end +-------- languages.lefthyphenmin (what) return lefthyphenmin (tolang(what)) end +-------- languages.righthyphenmin (what) return righthyphenmin (tolang(what)) end -- e['implementer']= 'imple{m}{-}{-}menter' -- e['manual'] = 'man{}{}{}' diff --git a/tex/context/base/mkiv/lang-ini.mkiv b/tex/context/base/mkiv/lang-ini.mkiv index 8ff41b287..214ce8ca3 100644 --- a/tex/context/base/mkiv/lang-ini.mkiv +++ b/tex/context/base/mkiv/lang-ini.mkiv @@ -518,7 +518,7 @@ \let\dohyphens\relax -\unexpanded\def\lang_basics_synchronize_min_max +\unexpanded\def\lang_basics_synchronize_min_max % maybe store this at the lua end {% these values are stored along with glyph nodes \lefthyphenmin \numexpr0\languageparameter\s!lefthyphenmin +\hyphenminoffset\relax \righthyphenmin\numexpr0\languageparameter\s!righthyphenmin+\hyphenminoffset\relax diff --git a/tex/context/base/mkiv/lpdf-ini.lua b/tex/context/base/mkiv/lpdf-ini.lua index 2149f4729..f0b919d4e 100644 --- a/tex/context/base/mkiv/lpdf-ini.lua +++ b/tex/context/base/mkiv/lpdf-ini.lua @@ -1059,13 +1059,30 @@ do return timestamp end + function lpdf.settime(n) + if n then + n = converters.totime(n) + if n then + converters.settime(n) + timestamp = os.date("%Y-%m-%dT%X",os.time(n)) .. os.timezone(true) + end + end + return timestamp + end + + lpdf.settime(tonumber(resolvers.variable("start_time")) or tonumber(resolvers.variable("SOURCE_DATE_EPOCH"))) -- bah + function lpdf.pdftimestamp(str) local Y, M, D, h, m, s, Zs, Zh, Zm = match(str,"^(%d%d%d%d)%-(%d%d)%-(%d%d)T(%d%d):(%d%d):(%d%d)([%+%-])(%d%d):(%d%d)$") return Y and format("D:%s%s%s%s%s%s%s%s'%s'",Y,M,D,h,m,s,Zs,Zh,Zm) end - function lpdf.id() - return format("%s.%s",tex.jobname,timestamp) + function lpdf.id(nodate) + if nodate then + return tex.jobname + else + return format("%s.%s",tex.jobname,timestamp) + end end end diff --git a/tex/context/base/mkiv/lpdf-xmp.lua b/tex/context/base/mkiv/lpdf-xmp.lua index b8170319c..c8b86d384 100644 --- a/tex/context/base/mkiv/lpdf-xmp.lua +++ b/tex/context/base/mkiv/lpdf-xmp.lua @@ -41,7 +41,7 @@ local mapping = { ["ConTeXt.Time"] = { "date", "rdf:Description/pdfx:ConTeXt.Time" }, ["ConTeXt.Url"] = { "context", "rdf:Description/pdfx:ConTeXt.Url" }, ["ConTeXt.Version"] = { "context", "rdf:Description/pdfx:ConTeXt.Version" }, - ["ID"] = { "date", "rdf:Description/pdfx:ID" }, -- has date + ["ID"] = { "id", "rdf:Description/pdfx:ID" }, -- has date ["PTEX.Fullbanner"] = { "metadata","rdf:Description/pdfx:PTEX.Fullbanner" }, -- Adobe PDF schema ["Keywords"] = { "metadata","rdf:Description/pdf:Keywords" }, @@ -60,8 +60,8 @@ local mapping = { ["ModDate"] = { "date", "rdf:Description/xmp:ModDate" }, -- dummy ["ModifyDate"] = { "date", "rdf:Description/xmp:ModifyDate" }, -- XMP Media Management schema - ["DocumentID"] = { "date", "rdf:Description/xmpMM:DocumentID" }, -- uuid - ["InstanceID"] = { "date", "rdf:Description/xmpMM:InstanceID" }, -- uuid + ["DocumentID"] = { "id", "rdf:Description/xmpMM:DocumentID" }, -- uuid + ["InstanceID"] = { "id", "rdf:Description/xmpMM:InstanceID" }, -- uuid ["RenditionClass"] = { "pdf", "rdf:Description/xmpMM:RenditionClass" }, -- PDF/X-4 ["VersionID"] = { "pdf", "rdf:Description/xmpMM:VersionID" }, -- PDF/X-4 -- additional entries @@ -105,32 +105,66 @@ local included = table.setmetatableindex( { return true end) -directives.register("backend.nodates", function(v) - included.date = not v +function lpdf.settrailerid(v) if v then - report_info("no date/time information will be added to the PDF file") - end -end) - -directives.register("backend.trailerid", function(v) - if v then - if toboolean(v) or v == "" then + local b = toboolean(v) or v == "" + if b then v = "This file is processed by ConTeXt and LuaTeX." else v = tostring(v) end local h = md5.HEX(v) - report_info("using hashed trailer id %a (%a)",v,h) + if b then + report_info("using frozen trailer id") + else + report_info("using hashed trailer id %a (%a)",v,h) + end pdf.settrailerid(format("[<%s> <%s>]",h,h)) end -end) +end + +function lpdf.setdates(v) + local t = type(v) + if t == "number" or t == "string" then + t = converters.totime(v) + if t then + included.date = true + included.id = "fake" + report_info("forced date/time information %a will be used",lpdf.settime(t)) + lpdf.settrailerid(false) + return + end + end + v = toboolean(v) + included.date = v + if v then + included.id = true + else + report_info("no date/time but fake id information will be added") + lpdf.settrailerid(true) + included.id = "fake" + -- maybe: lpdf.settime(231631200) -- 1975-05-05 % first entry of knuth about tex mentioned in DT + end +end + +function lpdf.id() -- overload of ini + local banner = tex.jobname + if included.date then + return format("%s.%s",banner,lpdf.timestamp()) + else + return banner + end +end + +directives.register("backend.trailerid", lpdf.settrailerid) +directives.register("backend.date", lpdf.setdates) local function permitdetail(what) local m = mapping[what] if m then return included[m[1]] and m[2] else - return included[what] + return included[what] and true or false end end @@ -214,22 +248,34 @@ end -- flushing -local t = { } for i=1,24 do t[i] = random() end +local function randomstring(n) + local t = { } + for i=1,n do + t[i] = char(96 + random(26)) + end + return concat(t) +end + +randomstring(26) -- kind of initializes and kicks off random local function flushxmpinfo() commands.pushrandomseed() commands.setrandomseed(os.time()) - local t = { } for i=1,24 do t[i] = char(96 + random(26)) end - local packetid = concat(t) - - local documentid = format("uuid:%s",os.uuid()) - local instanceid = format("uuid:%s",os.uuid()) + local packetid = "no unique packet id here" -- 24 chars + local documentid = "no unique document id here" + local instanceid = "no unique instance id here" local producer = format("LuaTeX-%0.2f.%s",status.luatex_version/100,status.luatex_revision) local creator = "LuaTeX + ConTeXt MkIV" local time = lpdf.timestamp() local fullbanner = status.banner + if included.id ~= "fake" then + packetid = randomstring(24) + documentid = "uuid:%s" .. os.uuid() + instanceid = "uuid:%s" .. os.uuid() + end + pdfaddxmpinfo("DocumentID", documentid) pdfaddxmpinfo("InstanceID", instanceid) pdfaddxmpinfo("Producer", producer) diff --git a/tex/context/base/mkiv/luat-cnf.lua b/tex/context/base/mkiv/luat-cnf.lua index 83622ef53..9d37df7bb 100644 --- a/tex/context/base/mkiv/luat-cnf.lua +++ b/tex/context/base/mkiv/luat-cnf.lua @@ -42,6 +42,7 @@ luatex = luatex or { } texconfig.kpse_init = false texconfig.shell_escape = 't' +---------.start_time = tonumber(os.getenv("SOURCE_DATE_EPOCH")) -- not used in context -- as soon as possible diff --git a/tex/context/base/mkiv/m-oldotf.mkiv b/tex/context/base/mkiv/m-oldotf.mkiv index c7c468d93..313f9f484 100644 --- a/tex/context/base/mkiv/m-oldotf.mkiv +++ b/tex/context/base/mkiv/m-oldotf.mkiv @@ -25,6 +25,7 @@ "font-otc", "font-oth", "font-odv", + "font-one", "font-map", "font-fbk", "font-gds", diff --git a/tex/context/base/mkiv/meta-ini.mkiv b/tex/context/base/mkiv/meta-ini.mkiv index 9f53aea69..d0fff83df 100644 --- a/tex/context/base/mkiv/meta-ini.mkiv +++ b/tex/context/base/mkiv/meta-ini.mkiv @@ -486,6 +486,10 @@ \startMPextensions string contextversion; contextversion:="\contextversion"; % expanded + minute:=\the\normaltime mod 60; + hour:=\the\normaltime div 60; + year:=\the\normalyear; + month:=\the\normalmonth; \stopMPextensions %D \macros diff --git a/tex/context/base/mkiv/mult-sys.mkiv b/tex/context/base/mkiv/mult-sys.mkiv index 01a1674dc..88e956d66 100644 --- a/tex/context/base/mkiv/mult-sys.mkiv +++ b/tex/context/base/mkiv/mult-sys.mkiv @@ -48,7 +48,7 @@ \definesystemconstant {danish} \definesystemconstant {da} \definesystemconstant {dutch} \definesystemconstant {nl} \definesystemconstant {english} \definesystemconstant {en} -\definesystemconstant {finish} \definesystemconstant {fi} +\definesystemconstant {finnish} \definesystemconstant {fi} \definesystemconstant {french} \definesystemconstant {fr} \definesystemconstant {german} \definesystemconstant {de} \definesystemconstant {hungarian} \definesystemconstant {hu} diff --git a/tex/context/base/mkiv/node-fnt.lua b/tex/context/base/mkiv/node-fnt.lua index 7f0d23997..e77280c37 100644 --- a/tex/context/base/mkiv/node-fnt.lua +++ b/tex/context/base/mkiv/node-fnt.lua @@ -17,9 +17,12 @@ local trace_characters = false trackers.register("nodes.characters", function( local trace_fontrun = false trackers.register("nodes.fontrun", function(v) trace_fontrun = v end) local trace_variants = false trackers.register("nodes.variants", function(v) trace_variants = v end) -local force_discrun = true directives.register("nodes.discrun", function(v) force_discrun = v end) -local force_boundaryrun = true directives.register("nodes.boundaryrun", function(v) force_boundaryrun = v end) -local force_basepass = true directives.register("nodes.basepass", function(v) force_basepass = v end) +-- bad namespace for directives + +local force_discrun = true directives.register("nodes.discrun", function(v) force_discrun = v end) +local force_boundaryrun = true directives.register("nodes.boundaryrun", function(v) force_boundaryrun = v end) +local force_basepass = true directives.register("nodes.basepass", function(v) force_basepass = v end) +local keep_redundant = false directives.register("nodes.keepredundant",function(v) keep_redundant = v end) local report_fonts = logs.reporter("fonts","processing") @@ -271,6 +274,12 @@ function handlers.characters(head) end end end + elseif keep_redundant then + -- go on, can be used for tracing + elseif not redundant then + redundant = { n } + else + redundant[#redundant+1] = n end end end diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 5d4c84ce1..169d8e0a3 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 84aba5a7f..469f94361 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/typo-tal.lua b/tex/context/base/mkiv/typo-tal.lua index a67cd0a4b..21c6794c4 100644 --- a/tex/context/base/mkiv/typo-tal.lua +++ b/tex/context/base/mkiv/typo-tal.lua @@ -200,10 +200,10 @@ function characteralign.handler(originalhead,where) while current do local char, id = isglyph(current) if char then - local font = getfont(current) - -- local unicode = unicodes[font][char] - local unicode = fontcharacters[font][char].unicode or char -- ignore tables - if not unicode then + local font = getfont(current) + local data = fontcharacters[font][char] + local unicode = data and data.unicode or char -- ignore tables + if not unicode then -- type(unicode) ~= "number" -- no unicode so forget about it elseif unicode == separator then c = current diff --git a/tex/context/base/mkiv/typo-wrp.mkiv b/tex/context/base/mkiv/typo-wrp.mkiv index 4b18785bd..081349050 100644 --- a/tex/context/base/mkiv/typo-wrp.mkiv +++ b/tex/context/base/mkiv/typo-wrp.mkiv @@ -44,6 +44,7 @@ \spac_crlf_placeholder \ifcase\raggedstatus\hfil\or\or\or\hfil\fi \break + \hskip\zeropoint % new so that the next word also hyphenates \ignorespaces} \unexpanded\def\spac_crlf_placeholder diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex 6d0041d25..c3cc5715c 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 4d61ab7a8..62fd9a034 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/context/modules/mkiv/s-languages-hyphenation.lua b/tex/context/modules/mkiv/s-languages-hyphenation.lua index c5a4f91f1..b8de773a0 100644 --- a/tex/context/modules/mkiv/s-languages-hyphenation.lua +++ b/tex/context/modules/mkiv/s-languages-hyphenation.lua @@ -11,101 +11,182 @@ moduledata.languages.hyphenation = moduledata.languages.hyphenation or { } local a_colormodel = attributes.private('colormodel') +local tex = tex +local context = context + local nodecodes = nodes.nodecodes -local nodepool = nodes.pool +local nuts = nodes.nuts +local nodepool = nuts.pool + local disc_code = nodecodes.disc local glyph_code = nodecodes.glyph + local emwidths = fonts.hashes.emwidths local exheights = fonts.hashes.exheights + local newkern = nodepool.kern local newrule = nodepool.rule local newglue = nodepool.glue -local insert_node_after = node.insert_after -local traverse_by_id = node.traverse_id -local hyphenate = languages.hyphenators.handler -- lang.hyphenate -local find_tail = node.tail -local remove_node = nodes.remove +local insert_node_after = nuts.insert_after +local traverse_by_id = nuts.traverse_id + +local tonut = nodes.tonut +local tonode = nodes.tonode +local getid = nuts.getid +local getnext = nuts.getnext +local getdisc = nuts.getdisc +local getattr = nuts.getattr +local getfont = nuts.getfont +local getfield = nuts.getfield +local setlink = nuts.setlink +local setdisc = nuts.setdisc +local setfield = nuts.setfield +local free_node = nuts.free local tracers = nodes.tracers local colortracers = tracers and tracers.colors local setnodecolor = colortracers.set +-- maybe this will become code code + +local states = table.setmetatableindex(function(t,k) + return { + lefthyphenmin = tex.lefthyphenmin, + righthyphenmin = tex.righthyphenmin, + hyphenationmin = tex.hyphenationmin, + prehyphenchar = tex.prehyphenchar, + posthyphenchar = tex.posthyphenchar, + } +end) + +interfaces.implement { + name = "storelanguagestate", + actions = function() + states[tex.language] = { + lefthyphenmin = tex.lefthyphenmin, + righthyphenmin = tex.righthyphenmin, + hyphenationmin = tex.hyphenationmin, + prehyphenchar = tex.prehyphenchar, + posthyphenchar = tex.posthyphenchar, + } + end +} + +function moduledata.languages.getstate(l) + return states[l] -- code +end + +-- end + local function identify(head,marked) - local current, prev = head, nil + local current = tonut(head) + local prev = nil while current do - local id = current.id - local next = current.next + local id = getid(current) + local next = getnext(current) if id == disc_code then - if prev and next then -- and next.id == glyph_code then -- catch other usage of disc + if prev and next then -- asume glyphs marked[#marked+1] = prev + local pre, post, replace, pre_tail, post_tail, replace_tail = getdisc(current,true) + if replace then + setlink(prev,replace) + setlink(replace_tail,next) + setdisc(pre,post,nil) + prev = tail + else + setlink(prev,next) + end + free_node(current) end elseif id == glyph_code then prev = current + else + prev = nil end current = next end end -local function strip(head,marked) +local function mark(head,marked,w,h,d,how) + head = tonut(head) for i=1,#marked do - local prev = marked[i] - remove_node(head,prev.next,true) + local current = marked[i] + local font = getfont(current) + local em = emwidths[font] + local ex = exheights[font] + local width = w*em + local rule = newrule(width,h*ex,d*ex) + head, current = insert_node_after(head,current,newkern(-width/2)) + head, current = insert_node_after(head,current,rule) + head, current = insert_node_after(head,current,newkern(-width/2)) + head, current = insert_node_after(head,current,newglue(0)) + setnodecolor(rule,how) -- ,getattr(current,a_colormodel)) end end -local function mark(head,marked,w,h,d,how) - for i=1,#marked do - local prev = marked[i] - local font = prev.font - local em = emwidths[font] - local ex = exheights[font] - local width = w*em - local rule = newrule(width,h*ex,d*ex) - head, prev = insert_node_after(head,prev,newkern(-width/2)) - head, prev = insert_node_after(head,prev,rule) - head, prev = insert_node_after(head,prev,newkern(-width/2)) - head, prev = insert_node_after(head,prev,newglue(0)) - setnodecolor(rule,how,prev[a_colormodel]) +local function getlanguage(head,l,left,right) + local t = { } + for n in traverse_by_id(glyph_code,tonut(head)) do + t[n] = { + getfield(n,"lang"), + getfield(n,"left"), + getfield(n,"right"), + } end end -local langs, tags, noflanguages = { }, { }, 0 - -local colorbytag = false +local langs = { } +local tags = { } +local noflanguages = 0 +local colorbytag = false function moduledata.languages.hyphenation.showhyphens(head) if noflanguages > 0 then local marked = { } + local cached = { } + -- somehow assigning -1 fails + for n in traverse_by_id(glyph_code,tonut(head)) do + cached[n] = { + getfield(n,"lang"), + getfield(n,"left"), + getfield(n,"right") + } + end for i=1,noflanguages do local m = { } local l = langs[i] + local s = states[l] marked[i] = m - for n in traverse_by_id(glyph_code,head) do - n.lang = l + local lmin = s.lefthyphenmin + local rmin = s.righthyphenmin + for n in next, cached do + setfield(n,"lang",l) + setfield(n,"left",lmin) + setfield(n,"right",rmin) end languages.hyphenators.methods.original(head) identify(head,m) - strip(head,m) end for i=noflanguages,1,-1 do local l = noflanguages - i + 1 mark(head,marked[i],1/16,l/2,l/4,"hyphenation:"..(colorbytag and tags[i] or i)) end + for n, d in next, cached do + setfield(n,"lang",d[1]) + setfield(n,"left",d[2]) + setfield(n,"right",d[3]) + end return head, true else return head, false end end -local savedlanguage - function moduledata.languages.hyphenation.startcomparepatterns(list) if list and list ~= "" then tags = utilities.parsers.settings_to_array(list) end - savedlanguage = tex.language - tex.language = 0 noflanguages = #tags for i=1,noflanguages do langs[i] = tags[i] and languages.getnumber(tags[i]) @@ -115,7 +196,6 @@ end function moduledata.languages.hyphenation.stopcomparepatterns() noflanguages = 0 - tex.language = savedlanguage or tex.language nodes.tasks.disableaction("processors","moduledata.languages.hyphenation.showhyphens") end diff --git a/tex/context/modules/mkiv/s-languages-hyphenation.mkiv b/tex/context/modules/mkiv/s-languages-hyphenation.mkiv index 6662dbf2f..9ff5720a0 100644 --- a/tex/context/modules/mkiv/s-languages-hyphenation.mkiv +++ b/tex/context/modules/mkiv/s-languages-hyphenation.mkiv @@ -34,6 +34,12 @@ \ctxlua{moduledata.languages.hyphenation.stopcomparepatterns()}% \endgroup} +\appendtoks + \clf_storelanguagestate % global +\to \everylanguage + +\clf_storelanguagestate % initialize + \installmodulecommandluasingle \showcomparepatternslegend {moduledata.languages.hyphenation.showcomparelegend} \protect @@ -42,11 +48,13 @@ \definecolor[hyphenation:2] [g=.8] \definecolor[hyphenation:3] [b=.8] \definecolor[hyphenation:4] [r=.4,g=.4] +\definecolor[hyphenation:5] [r=.4,b=.4] \definecolor[hyphenation:en] [hyphenation:1] \definecolor[hyphenation:de] [hyphenation:2] \definecolor[hyphenation:nl] [hyphenation:3] \definecolor[hyphenation:fr] [hyphenation:4] +\definecolor[hyphenation:sl] [hyphenation:5] \stopmodule @@ -56,10 +64,33 @@ \starttext -\def|#1|{-} + \startcomparepatterns[en,sl] + {For Mojca Miklavec} + {For Mojca Miklavec} + \stopcomparepatterns + + \startcomparepatterns[en] + {For Mojca Miklavec} + {For Mojca Miklavec} + \stopcomparepatterns + + \startcomparepatterns[sl] + {For Mojca Miklavec} + {For Mojca Miklavec} + \stopcomparepatterns + + \startcomparepatterns[en,sl] + {For Mojca Miklavec}\crlf + {For Mojca Miklavec}\crlf + {\de For Mojca Miklavec}\crlf + {For Mojca Miklavec}\crlf + {\fr For Mojca Miklavec} + \stopcomparepatterns + + \page \startsubject{Normal text} - \input tufte + \input tufte \stopsubject \startsubject{Compare hyphenation points of \showcomparepatternslegend[en,de]} |