diff options
Diffstat (limited to 'tex')
38 files changed, 405 insertions, 118 deletions
diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index b9755ea44..7a86cbd8c 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -93,7 +93,6 @@ local disc_code = nodecodes.disc local insert_code = nodecodes.insert local whatsit_code = nodecodes.whatsit local refximage_code = whatsitcodes.pdfrefximage -local localpar_code = whatsitcodes.localpar local userskip_code = skipcodes.userskip local rightskip_code = skipcodes.rightskip @@ -2536,8 +2535,6 @@ local function finishexport() end end --- whatsit_code localpar_code - local function collectresults(head,list,pat,pap) -- is last used (we also have currentattribute) local p for n in traverse_nodes(head) do diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 9d763b448..2d1b140d2 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,16 +11,21 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2015.10.07 12:03} +\newcontextversion{2015.10.09 10:59} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. % \usemodule[newotf] -\usemodule[oldotf] +% \usemodule[oldotf] \unprotect +\ifdefined\pdfxform \else \let\pdfxform \saveboxresource \fi +\ifdefined\pdfrefxform \else \let\pdfrefxform \useboxresource \fi +\ifdefined\pdfrefximage \else \let\pdfrefximage\useimageresource \fi +\ifdefined\pdfximage \else \let\pdfximage \saveimageresource \fi + % \writestatus\m!system{beware: some patches loaded from cont-new.mkiv} % \attribute152\zerocount : marks ... lots of sweeps so best early in list diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 4968bcbbe..4c3d3fd14 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 0fcb7ba97..70a538f7d 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.10.07 12:03} +\edef\contextversion{2015.10.09 10:59} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/font-inj.lua b/tex/context/base/font-inj.lua index da1364d9d..36781f72f 100644 --- a/tex/context/base/font-inj.lua +++ b/tex/context/base/font-inj.lua @@ -462,7 +462,11 @@ local function collect_glyphs(head,offsets) local f = getfont(n) if f ~= nf then nf = f - tm = fontdata[nf].resources.marks -- other hash in ctx + -- other hash in ctx: + tm = fontdata[nf].resources + if tm then + tm = tm.marks + end end if tm and tm[getchar(n)] then nofmarks = nofmarks + 1 diff --git a/tex/context/base/font-mis.lua b/tex/context/base/font-mis.lua index 8219cd234..750e08ae8 100644 --- a/tex/context/base/font-mis.lua +++ b/tex/context/base/font-mis.lua @@ -22,7 +22,7 @@ local handlers = fonts.handlers handlers.otf = handlers.otf or { } local otf = handlers.otf -otf.version = otf.version or 2.818 +otf.version = otf.version or 2.819 otf.cache = otf.cache or containers.define("fonts", "otf", otf.version, true) local fontloader = fontloader diff --git a/tex/context/base/font-nod.lua b/tex/context/base/font-nod.lua index 8d199f868..240ea7057 100644 --- a/tex/context/base/font-nod.lua +++ b/tex/context/base/font-nod.lua @@ -51,11 +51,10 @@ local disc_code = nodecodes.disc local glue_code = nodecodes.glue local kern_code = nodecodes.kern local rule_code = nodecodes.rule +local dir_code = nodecodes.dir or whatcodes.dir +local localpar_code = nodecodes.localpar or whatcodes.localpar local whatsit_code = nodecodes.whatsit -local localpar_code = whatcodes.localpar -local dir_code = whatcodes.dir - local nuts = nodes.nuts local tonut = nuts.tonut local tonode = nuts.tonode @@ -394,6 +393,8 @@ function step_tracers.codes(i,command,space) local id = getid(c) if id == glyph_code then showchar(c) + elseif id == dir_code or id == localpar_code then + context("[%s]",getfield(c,"dir")) elseif id == whatsit_code and (getsubtype(c) == localpar_code or getsubtype(c) == dir_code) then context("[%s]",getfield(c,"dir")) elseif id == disc_code then diff --git a/tex/context/base/font-off.lua b/tex/context/base/font-off.lua index 34a4d963b..5fe68dc2a 100644 --- a/tex/context/base/font-off.lua +++ b/tex/context/base/font-off.lua @@ -160,7 +160,7 @@ local function check_names(names) if names then for i=1,#names do local name = names[i] - if name.lang == "English (US)" then + if lower(name.lang) == "english (us)" then -- lower added return name.names end end diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua index 851a25cca..0ca1e98ba 100644 --- a/tex/context/base/font-otf.lua +++ b/tex/context/base/font-otf.lua @@ -58,7 +58,7 @@ local otf = fonts.handlers.otf otf.glists = { "gsub", "gpos" } -otf.version = 2.818 -- beware: also sync font-mis.lua and in mtx-fonts +otf.version = 2.819 -- beware: also sync font-mis.lua and in mtx-fonts otf.cache = containers.define("fonts", "otf", otf.version, true) local hashes = fonts.hashes @@ -2130,18 +2130,21 @@ actions["check metadata"] = function(data,filename,raw) end end -- + local names = raw.names + -- if metadata.validation_state and table.contains(metadata.validation_state,"bad_ps_fontname") then -- the ff library does a bit too much (and wrong) checking ... so we need to catch this -- at least for now local function valid(what) - local names = raw.names - for i=1,#names do - local list = names[i] - local names = list.names - if names then - local name = names[what] - if name and valid_ps_name(name) then - return name + if names then + for i=1,#names do + local list = names[i] + local names = list.names + if names then + local name = names[what] + if name and valid_ps_name(name) then + return name + end end end end @@ -2165,6 +2168,33 @@ actions["check metadata"] = function(data,filename,raw) check("fullname") end -- + if names then + local psname = metadata.psname + if not psname or psname == "" then + for i=1,#names do + local name = names[i] + -- Currently we use the same restricted search as in the new context (specific) font loader + -- but we might add more lang checks (it worked ok in the new loaded so now we're in sync) + -- This check here is also because there are (esp) cjk fonts out there with psnames different + -- from fontnames (gives a bad lookup in backend). + if lower(name.lang) == "english (us)" then + local specification = name.names + if specification then + local postscriptname = specification.postscriptname + if postscriptname then + psname = postscriptname + end + end + end + break + end + end + if psname ~= metadata.fontname then + report_otf("fontname %a, fullname %a, psname %a",metadata.fontname,metadata.fullname,psname) + end + metadata.psname = psname + end + -- end actions["cleanup tables"] = function(data,filename,raw) @@ -2617,7 +2647,7 @@ local function copytotfm(data,cache_id) local filename = constructors.checkedfilename(resources) local fontname = metadata.fontname local fullname = metadata.fullname or fontname - local psname = fontname or fullname + local psname = metadata.psname or fontname or fullname local units = metadata.units or metadata.units_per_em or 1000 -- if units == 0 then -- catch bugs in fonts diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua index 1b99c56de..9ccd19d75 100644 --- a/tex/context/base/font-otn.lua +++ b/tex/context/base/font-otn.lua @@ -252,9 +252,9 @@ local glue_code = nodecodes.glue local disc_code = nodecodes.disc local whatsit_code = nodecodes.whatsit local math_code = nodecodes.math +local dir_code = nodecodes.dir or whatcodes.dir +local localpar_code = nodecodes.localpar or whatcodes.localpar -local dir_code = whatcodes.dir -local localpar_code = whatcodes.localpar local discretionary_code = disccodes.discretionary local ligature_code = glyphcodes.ligature @@ -3320,7 +3320,7 @@ local function featuresprocessor(head,font,attr) comprun(start,c_run) start = getnext(start) end - elseif id == whatsit_code then -- will be function + elseif id == whatsit_code then local subtype = getsubtype(start) if subtype == dir_code then local dir = getfield(start,"dir") @@ -3359,6 +3359,41 @@ local function featuresprocessor(head,font,attr) start = getnext(start) elseif id == math_code then start = getnext(end_of_math(start)) + elseif id == dir_code then + local dir = getfield(start,"dir") + if dir == "+TLT" then + topstack = topstack + 1 + dirstack[topstack] = dir + rlmode = 1 + elseif dir == "+TRT" then + topstack = topstack + 1 + dirstack[topstack] = dir + rlmode = -1 + elseif dir == "-TLT" or dir == "-TRT" then + topstack = topstack - 1 + rlmode = dirstack[topstack] == "+TRT" and -1 or 1 + else + rlmode = rlparmode + end + if trace_directions then + report_process("directions after txtdir %a: parmode %a, txtmode %a, # stack %a, new dir %a",dir,rlparmode,rlmode,topstack,newdir) + end + start = getnext(start) + elseif id == localpar_code then + local dir = getfield(start,"dir") + if dir == "TRT" then + rlparmode = -1 + elseif dir == "TLT" then + rlparmode = 1 + else + rlparmode = 0 + end + -- one might wonder if the par dir should be looked at, so we might as well drop the next line + rlmode = rlparmode + if trace_directions then + report_process("directions after pardir %a: parmode %a, txtmode %a",dir,rlparmode,rlmode) + end + start = getnext(start) else start = getnext(start) end @@ -3630,6 +3665,40 @@ local function featuresprocessor(head,font,attr) start = getnext(start) elseif id == math_code then start = getnext(end_of_math(start)) + elseif id == dir_code then + local dir = getfield(start,"dir") + if dir == "+TLT" then + topstack = topstack + 1 + dirstack[topstack] = dir + rlmode = 1 + elseif dir == "+TRT" then + topstack = topstack + 1 + dirstack[topstack] = dir + rlmode = -1 + elseif dir == "-TLT" or dir == "-TRT" then + topstack = topstack - 1 + rlmode = dirstack[topstack] == "+TRT" and -1 or 1 + else + rlmode = rlparmode + end + if trace_directions then + report_process("directions after txtdir %a: parmode %a, txtmode %a, # stack %a, new dir %a",dir,rlparmode,rlmode,topstack,newdir) + end + start = getnext(start) + elseif id == localpar_code then + local dir = getfield(start,"dir") + if dir == "TRT" then + rlparmode = -1 + elseif dir == "TLT" then + rlparmode = 1 + else + rlparmode = 0 + end + rlmode = rlparmode + if trace_directions then + report_process("directions after pardir %a: parmode %a, txtmode %a",dir,rlparmode,rlmode) + end + start = getnext(start) else start = getnext(start) end diff --git a/tex/context/base/font-ots.lua b/tex/context/base/font-ots.lua index 6826ae849..5dbb25ab2 100644 --- a/tex/context/base/font-ots.lua +++ b/tex/context/base/font-ots.lua @@ -194,9 +194,9 @@ local glue_code = nodecodes.glue local disc_code = nodecodes.disc local whatsit_code = nodecodes.whatsit local math_code = nodecodes.math +local dir_code = nodecodes.dir or whatcodes.dir +local localpar_code = nodecodes.localpar or whatcodes.localpar -local dir_code = whatcodes.dir -local localpar_code = whatcodes.localpar local discretionary_code = disccodes.discretionary local ligature_code = glyphcodes.ligature @@ -3292,7 +3292,7 @@ if not a or (a == attr) then comprun(start,c_run) start = getnext(start) end - elseif id == whatsit_code then -- will be function + elseif id == whatsit_code then local subtype = getsubtype(start) if subtype == dir_code then local dir = getfield(start,"dir") @@ -3331,6 +3331,41 @@ if not a or (a == attr) then start = getnext(start) elseif id == math_code then start = getnext(end_of_math(start)) + elseif id == dir_code then + local dir = getfield(start,"dir") + if dir == "+TLT" then + topstack = topstack + 1 + dirstack[topstack] = dir + rlmode = 1 + elseif dir == "+TRT" then + topstack = topstack + 1 + dirstack[topstack] = dir + rlmode = -1 + elseif dir == "-TLT" or dir == "-TRT" then + topstack = topstack - 1 + rlmode = dirstack[topstack] == "+TRT" and -1 or 1 + else + rlmode = rlparmode + end + if trace_directions then + report_process("directions after txtdir %a: parmode %a, txtmode %a, # stack %a, new dir %a",dir,mref(rlparmode),mref(rlmode),topstack,mref(newdir)) + end + start = getnext(start) + elseif id == localpar_code then + local dir = getfield(start,"dir") + if dir == "TRT" then + rlparmode = -1 + elseif dir == "TLT" then + rlparmode = 1 + else + rlparmode = 0 + end + -- one might wonder if the par dir should be looked at, so we might as well drop the next line + rlmode = rlparmode + if trace_directions then + report_process("directions after pardir %a: parmode %a, txtmode %a",dir,mref(rlparmode),mref(rlmode)) + end + start = getnext(start) else start = getnext(start) end @@ -3606,6 +3641,40 @@ if not a or (a == attr) then start = getnext(start) elseif id == math_code then start = getnext(end_of_math(start)) + elseif id == dir_code then + local dir = getfield(start,"dir") + if dir == "+TLT" then + topstack = topstack + 1 + dirstack[topstack] = dir + rlmode = 1 + elseif dir == "+TRT" then + topstack = topstack + 1 + dirstack[topstack] = dir + rlmode = -1 + elseif dir == "-TLT" or dir == "-TRT" then + topstack = topstack - 1 + rlmode = dirstack[topstack] == "+TRT" and -1 or 1 + else + rlmode = rlparmode + end + if trace_directions then + report_process("directions after txtdir %a: parmode %a, txtmode %a, # stack %a, new dir %a",dir,mref(rlparmode),mref(rlmode),topstack,mref(newdir)) + end + start = getnext(start) + elseif id == localpar_code then + local dir = getfield(start,"dir") + if dir == "TRT" then + rlparmode = -1 + elseif dir == "TLT" then + rlparmode = 1 + else + rlparmode = 0 + end + rlmode = rlparmode + if trace_directions then + report_process("directions after pardir %a: parmode %a, txtmode %a",dir,mref(rlparmode),mref(rlmode)) + end + start = getnext(start) else start = getnext(start) end diff --git a/tex/context/base/font-sol.lua b/tex/context/base/font-sol.lua index 0761724f1..3e138f10f 100644 --- a/tex/context/base/font-sol.lua +++ b/tex/context/base/font-sol.lua @@ -95,12 +95,13 @@ local glyph_code = nodecodes.glyph local disc_code = nodecodes.disc local kern_code = nodecodes.kern local hlist_code = nodecodes.hlist +local dir_code = nodecodes.dir or whatsitcodes.dir +local localpar_code = nodecodes.localpar or whatsitcodes.localpar + local whatsit_code = nodecodes.whatsit local fontkern_code = kerncodes.fontkern -local localpar_code = whatsitcodes.localpar -local dir_code = whatsitcodes.dir local userdefined_code = whatsitcodes.userdefined local nodepool = nuts.pool @@ -414,6 +415,11 @@ function splitters.split(head) else start, stop = nil, nil end + elseif id == dir_code or id == localpar_code then + if start then + flush() + end + rlmode = getfield(current,"dir") elseif id == whatsit_code then if start then flush() diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index c161446d8..03557e370 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -1602,7 +1602,7 @@ directives.register("graphics.conversion.eps.cleanup.ai",function(v) cleanups.ai cleaners.ai = function(name) local tmpname = name .. ".tmp" - io.savedata(tmpname,lpegmatch(pattern,io.loaddata(name))) + io.savedata(tmpname,lpegmatch(pattern,io.loaddata(name) or "")) return tmpname end @@ -1611,6 +1611,9 @@ function epsconverter.pdf(oldname,newname,resolution,colorspace) -- the resoluti local presets = epstopdf.resolutions[resolution or "high"] or epstopdf.resolutions.high local level = codeinjections.getformatoption("pdf_level") or "1.3" local tmpname = oldname + if not tmpname or tmpname == "" or not lfs.isfile(tmpname) then + return + end if cleanups.ai then tmpname = cleaners.ai(oldname) end diff --git a/tex/context/base/m-nodechart.lua b/tex/context/base/m-nodechart.lua index 612b73767..1413cd8f1 100644 --- a/tex/context/base/m-nodechart.lua +++ b/tex/context/base/m-nodechart.lua @@ -66,6 +66,14 @@ function formatters.whatsit(n,comment) end end +function formatters.dir(n,comment) + return format("\\doFLOWdirnode{%s}{%s}{%s}",comment,"dir",n.dir) +end + +function formatters.localpar(n,comment) + return format("\\doFLOWdirnode{%s}{%s}{%s}",comment,"localpar",n.dir) +end + -- I will make a dedicated set of shapes for this. local shapes = { diff --git a/tex/context/base/mult-prm.lua b/tex/context/base/mult-prm.lua index bf61683ee..8928779cc 100644 --- a/tex/context/base/mult-prm.lua +++ b/tex/context/base/mult-prm.lua @@ -366,7 +366,6 @@ return { "pdflastobj", "pdflastxform", "pdflastximage", - "pdflastximagecolordepth", "pdflastximagepages", "pdflastxpos", "pdflastypos", @@ -423,7 +422,6 @@ return { "pdfxformname", "pdfxformresources", "pdfximage", - "pdfximagebbox", "quitvmode", "rightmarginkern", "rpcode", @@ -948,7 +946,6 @@ return { "pdflastobj", "pdflastxform", "pdflastximage", - "pdflastximagecolordepth", "pdflastximagepages", "pdflastxpos", "pdflastypos", @@ -1005,7 +1002,6 @@ return { "pdfxformname", "pdfxformresources", "pdfximage", - "pdfximagebbox", "penalty", "postdisplaypenalty", "postexhyphenchar", diff --git a/tex/context/base/node-ini.lua b/tex/context/base/node-ini.lua index 87d97c648..2c187b624 100644 --- a/tex/context/base/node-ini.lua +++ b/tex/context/base/node-ini.lua @@ -271,3 +271,12 @@ function nodes.showcodes() end trackers.register("system.showcodes", nodes.showcodes) + +-- new: + +nodes.nativedir = nodecodes.dir and true or false + +nodecodes.dir = 98 +nodecodes[98] = "dir" +nodecodes.localpar = 99 +nodecodes[99] = "localpar" diff --git a/tex/context/base/node-ltp.lua b/tex/context/base/node-ltp.lua index 3c539bcfa..29846ae08 100644 --- a/tex/context/base/node-ltp.lua +++ b/tex/context/base/node-ltp.lua @@ -247,11 +247,11 @@ local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist local unset_code = nodecodes.unset local marginkern_code = nodecodes.marginkern +local dir_code = nodecodes.dir or whatcodes.dir local leaders_code = gluecodes.leaders -local localpar_code = whatcodes.localpar -local dir_code = whatcodes.dir +local localpar_code = nodecodes.localpar or whatcodes.localpar local pdfrefximage_code = whatcodes.pdfrefximage local pdfrefxform_code = whatcodes.pdfrefxform @@ -355,7 +355,8 @@ local function inject_dirs_at_end_of_line(stack,current,start,stop) local n = stack.n local h = nil while start and start ~= stop do - if getid(start) == whatsit_code and getsubtype(start) == dir_code then + local id = getid(start) + if id == dir_code or (id == whatsit_code and getsubtype(start) == dir_code) then if not dir_pops[getfield(start,"dir")] then -- weird, what is this # n = n + 1 stack[n] = start @@ -1428,7 +1429,7 @@ local function post_line_break(par) end local id = getid(next) local subtype = getsubtype(next) - if id == whatsit_code and subtype == localpar_code then + if (id == localpar_code) or (id == whatsit_code and subtype == localpar_code) then -- nothing elseif id < math_code then -- messy criterium @@ -2160,15 +2161,18 @@ function constructors.methods.basic(head,d) par.font_in_short_display = 0 - if current and getid(current) == whatsit_code and getsubtype(current) == localpar_code then - par.init_internal_left_box = getfield(current,"box_left") - par.init_internal_left_box_width = getfield(current,"box_left_width") - par.internal_pen_inter = getfield(current,"pen_inter") - par.internal_pen_broken = getfield(current,"pen_broken") - par.internal_left_box = par.init_internal_left_box - par.internal_left_box_width = par.init_internal_left_box_width - par.internal_right_box = getfield(current,"box_right") - par.internal_right_box_width = getfield(current,"box_right_width") + if current then + local id = getid(current) + if (id == localpar_code) or (id == whatsit_code and getsubtype(current) == localpar_code) then + par.init_internal_left_box = getfield(current,"box_left") + par.init_internal_left_box_width = getfield(current,"box_left_width") + par.internal_pen_inter = getfield(current,"pen_inter") + par.internal_pen_broken = getfield(current,"pen_broken") + par.internal_left_box = par.init_internal_left_box + par.internal_left_box_width = par.init_internal_left_box_width + par.internal_right_box = getfield(current,"box_right") + par.internal_right_box_width = getfield(current,"box_right_width") + end end -- all passes are combined in this loop so maybe we should split this into @@ -2227,7 +2231,7 @@ function constructors.methods.basic(head,d) local prev_p = getprev(current) if prev_p and prev_p ~= temp_head then local id = getid(prev_p) - if id == glyph_code or + if id == glyph_code or -- dir_code is < math (id < math_code and (id ~= whatsit_code or getsubtype(prev_p) ~= dir_code)) or -- was: precedes_break(prev_p) (id == kern_code and getsubtype(prev_p) ~= userkern_code) then p_active, n_active = try_break(0, unhyphenated_code, par, first_p, current, checked_expansion) @@ -2358,6 +2362,15 @@ function constructors.methods.basic(head,d) active_width.size = active_width.size + getfield(current,"width") elseif id == penalty_code then p_active, n_active = try_break(getfield(current,"penalty"), unhyphenated_code, par, first_p, current, checked_expansion) + elseif id == dir_code then + par.line_break_dir = checked_line_dir(dirstack) or par.line_break_dir + elseif id == localpar_code then + par.internal_pen_inter = getfield(current,"pen_inter") + par.internal_pen_broken = getfield(current,"pen_broken") + par.internal_left_box = getfield(current,"box_left") + par.internal_left_box_width = getfield(current,"box_left_width") + par.internal_right_box = getfield(current,"box_right") + par.internal_right_box_width = getfield(current,"box_right_width") elseif id == whatsit_code then local subtype = getsubtype(current) if subtype == localpar_code then @@ -2971,6 +2984,8 @@ local function hpack(head,width,method,direction,firstline,line) -- fast version adjust_head = list end adjust_tail = slide_nodelist(list) -- find_tail(list) + elseif id == dir_code then + hpack_dir = checked_line_dir(stack,current) or hpack_dir elseif id == whatsit_code then local subtype = getsubtype(current) if subtype == dir_code then diff --git a/tex/context/base/node-nut.lua b/tex/context/base/node-nut.lua index ef46d4d13..849715383 100644 --- a/tex/context/base/node-nut.lua +++ b/tex/context/base/node-nut.lua @@ -903,10 +903,13 @@ local whatcodes = nodes.whatcodes local pdfrefximage_code = whatcodes.pdfrefximage local pdfrefxform_code = whatcodes.pdfrefxform -getwidth [pdfrefximage_code] = get_width -getwidth [pdfrefxform_code ] = get_width - -getdimensions[pdfrefximage_code] = get_dimensions -getdimensions[pdfrefxform_code ] = get_dimensions +if pdfrefxform_code then + getwidth [pdfrefxform_code ] = get_width + getdimensions[pdfrefxform_code ] = get_dimensions +end +if pdfrefximage_code then + getwidth [pdfrefximage_code] = get_width + getdimensions[pdfrefximage_code] = get_dimensions +end diff --git a/tex/context/base/node-ppt.lua b/tex/context/base/node-ppt.lua index 5e7abeaae..70233603d 100644 --- a/tex/context/base/node-ppt.lua +++ b/tex/context/base/node-ppt.lua @@ -41,7 +41,7 @@ local whatsit_code = nodecodes.whatsit local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist local userdefined_code = whatsitcodes.userdefined -local localpar_code = whatsitcodes.localpar +local localpar_code = nodecodes.localpar or whatsitcodes.localpar local nodepool = nodes.pool local new_usernumber = nodepool.usernumber diff --git a/tex/context/base/node-ref.lua b/tex/context/base/node-ref.lua index 97c37c74e..e77ea9a11 100644 --- a/tex/context/base/node-ref.lua +++ b/tex/context/base/node-ref.lua @@ -77,14 +77,13 @@ local glue_code = nodecodes.glue local glyph_code = nodecodes.glyph local rule_code = nodecodes.rule local whatsit_code = nodecodes.whatsit +local dir_code = nodecodes.dir or whatcodes.dir +local localpar_code = nodecodes.localpar or whatcodes.localpar local leftskip_code = skipcodes.leftskip local rightskip_code = skipcodes.rightskip local parfillskip_code = skipcodes.parfillskip -local localpar_code = whatcodes.localpar -local dir_code = whatcodes.dir - local line_code = listcodes.line local new_rule = nodepool.rule @@ -351,6 +350,10 @@ local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,tx if r then done[r] = done[r] - 1 end + elseif id == dir_code then + txtdir = getfield(current,"dir") + elseif id == localpar_code then + pardir = getfield(current,"dir") elseif id == whatsit_code then local subtype = getsubtype(current) if subtype == localpar_code then @@ -403,6 +406,10 @@ local function inject_area(head,attribute,make,stack,done,parent,pardir,txtdir) if list then setfield(current,"list",(inject_area(list,attribute,make,stack,done,current,pardir,txtdir))) end + elseif id == dir_code then + txtdir = getfield(current,"dir") + elseif id == localpar_code then + pardir = getfield(current,"dir") elseif id == whatsit_code then local subtype = getsubtype(current) if subtype == localpar_code then diff --git a/tex/context/base/node-res.lua b/tex/context/base/node-res.lua index 43dd3895e..85fb63adf 100644 --- a/tex/context/base/node-res.lua +++ b/tex/context/base/node-res.lua @@ -139,7 +139,15 @@ local penalty = register_nut(new_nut("penalty")) local glue = register_nut(new_nut("glue")) -- glue.spec = nil local glue_spec = register_nut(new_nut("glue_spec")) local glyph = register_nut(new_nut("glyph",0)) -local textdir = register_nut(new_nut("whatsit",whatsitcodes.dir)) + +local textdir = nil + +if nodes.nativedir then + textdir = register_nut(new_nut("dir")) +else + textdir = register_nut(new_nut("whatsit",whatsitcodes.dir)) +end + local latelua = register_nut(new_nut("whatsit",whatsitcodes.latelua)) local special = register_nut(new_nut("whatsit",whatsitcodes.special)) local user_n = register_nut(new_nut("whatsit",whatsitcodes.userdefined)) setfield(user_n,"type",100) -- 44 diff --git a/tex/context/base/node-rul.lua b/tex/context/base/node-rul.lua index 36d56a16c..f023d69c7 100644 --- a/tex/context/base/node-rul.lua +++ b/tex/context/base/node-rul.lua @@ -117,14 +117,13 @@ local kern_code = nodecodes.kern local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist local rule_code = nodecodes.rule +local dir_code = nodecodes.dir or whatcodes.dir local whatsit_code = nodecodes.whatsit local userskip_code = skipcodes.userskip local spaceskip_code = skipcodes.spaceskip local xspaceskip_code = skipcodes.xspaceskip -local dir_code = whatcodes.dir - local kerning_code = kerncodes.kern local nodepool = nuts.pool @@ -207,7 +206,7 @@ local function processwords(attribute,data,flush,head,parent) -- we have hlistdi if list then setfield(n,"list",(processwords(attribute,data,flush,list,n))) -- watch () end - elseif checkdir and id == whatsit_code and getsubtype(n) == dir_code then -- only changes in dir, we assume proper boundaries + elseif checkdir and (id == dir_code or (id == whatsit_code and getsubtype(n) == dir_code)) then -- only changes in dir, we assume proper boundaries if f and a then l = n end diff --git a/tex/context/base/node-tra.lua b/tex/context/base/node-tra.lua index 37e01782f..ae2dd7ddc 100644 --- a/tex/context/base/node-tra.lua +++ b/tex/context/base/node-tra.lua @@ -71,12 +71,11 @@ local disc_code = nodecodes.disc local glue_code = nodecodes.glue local kern_code = nodecodes.kern local rule_code = nodecodes.rule +local dir_code = nodecodes.dir or whatcodes.dir +local localpar_code = nodecodes.localpar or whatcodes.localpar local whatsit_code = nodecodes.whatsit local gluespec_code = nodecodes.gluespec -local localpar_code = whatcodes.localpar -local dir_code = whatcodes.dir - local dimenfactors = number.dimenfactors local fillorders = nodes.fillcodes local formatters = string.formatters @@ -148,7 +147,9 @@ local function tosequence(start,stop,compact) else t[#t+1] = nodecodes[id] end - elseif id == whatsit_code and getsubtype(start) == localpar_code or getsubtype(start) == dir_code then + elseif id == dir_code or id == localpar_code then + t[#t+1] = "[" .. getfield(start,"dir") .. "]" + elseif id == whatsit_code and (getsubtype(start) == localpar_code or getsubtype(start) == dir_code) then t[#t+1] = "[" .. getfield(start,"dir") .. "]" elseif compact then t[#t+1] = "[]" diff --git a/tex/context/base/page-lin.lua b/tex/context/base/page-lin.lua index af6118b05..27f38c3d4 100644 --- a/tex/context/base/page-lin.lua +++ b/tex/context/base/page-lin.lua @@ -52,7 +52,6 @@ local glue_code = nodecodes.glue local glyph_code = nodecodes.glyph local line_code = listcodes.line local leftskip_code = skipcodes.leftskip -local textdir_code = whatcodes.dir local a_displaymath = attributes.private('displaymath') local a_linenumber = attributes.private('linenumber') diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex ce81d5ce7..afdda01cb 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 23f2f42b0..7beb41d66 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/trac-vis.lua b/tex/context/base/trac-vis.lua index 2763b5d6d..a904b513d 100644 --- a/tex/context/base/trac-vis.lua +++ b/tex/context/base/trac-vis.lua @@ -34,6 +34,8 @@ local formatters = string.formatters -- todo: inline concat (more efficient) -- todo: tags can also be numbers (just add to hash) +-- todo: dir and localpar nodes + local nodecodes = nodes.nodecodes local disc_code = nodecodes.disc local kern_code = nodecodes.kern diff --git a/tex/context/base/typo-chr.lua b/tex/context/base/typo-chr.lua index db8579c84..00123ede3 100644 --- a/tex/context/base/typo-chr.lua +++ b/tex/context/base/typo-chr.lua @@ -92,7 +92,7 @@ local nodecodes = nodes.nodecodes local whatsitcodes = nodes.whatsitcodes local glyph_code = nodecodes.glyph local whatsit_code = nodecodes.whatsit -local localpar_code = whatsitcodes.localpar +local localpar_code = nodecodes.localpar or whatsitcodes.localpar local texnest = tex.nest local free_node = node.free @@ -171,7 +171,8 @@ local function pickup(head,tail,str) while true do local prev = first.prev if prev and prev[a_marked] == attr then - if prev.id == whatsit_code and prev.subtype == localpar_code then + local id = prev.id + if (id == localpar_code) or (id == whatsit_code and prev.subtype == localpar_code) then break else first = prev diff --git a/tex/context/base/typo-dha.lua b/tex/context/base/typo-dha.lua index e52751028..84c0d7c3d 100644 --- a/tex/context/base/typo-dha.lua +++ b/tex/context/base/typo-dha.lua @@ -83,9 +83,8 @@ local kern_code = nodecodes.kern local glue_code = nodecodes.glue local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist - -local localpar_code = whatcodes.localpar -local dir_code = whatcodes.dir +local dir_code = nodecodes.dir or whatcodes.dir +local localpar_code = nodecodes.localpar or whatcodes.localpar local new_textdir = nodepool.textdir @@ -313,6 +312,33 @@ local function process(start) setprop(current,"direction",'g') elseif id == kern_code then setprop(current,"direction",'k') + elseif id == dir_code then + local dir = getfield(current,"dir") + if dir == "+TRT" then + autodir = -1 + elseif dir == "+TLT" then + autodir = 1 + elseif dir == "-TRT" or dir == "-TLT" then + if embedded and embedded~= 0 then + autodir = embedded + else + autodir = 0 + end + else + -- message + end + textdir = autodir + setprop(current,"direction",true) + elseif id == localpar_code then + local dir = getfield(current,"dir") + if dir == 'TRT' then + autodir = -1 + elseif dir == 'TLT' then + autodir = 1 + end + pardir = autodir + textdir = pardir + setprop(current,"direction",true) elseif id == whatsit_code then local subtype = getsubtype(current) if subtype == localpar_code then diff --git a/tex/context/base/typo-drp.lua b/tex/context/base/typo-drp.lua index 4bbf0b8e9..36b873081 100644 --- a/tex/context/base/typo-drp.lua +++ b/tex/context/base/typo-drp.lua @@ -67,7 +67,7 @@ local hlist_code = nodecodes.hlist local glue_code = nodecodes.glue local kern_code = nodecodes.kern local whatsit_code = nodecodes.whatsit -local localpar_code = whatsitcodes.localpar +local localpar_code = nodecodes.localpar or whatsitcodes.localpar local actions = { } initials.actions = actions @@ -129,7 +129,8 @@ interfaces.implement { -- actions[v_default] = function(head,setting) -- local done = false --- if getid(head) == whatsit_code and getsubtype(head) == localpar_code then +-- local id = getid(head) +-- if (id == localpar_code) or (id == whatsit_code and getsubtype(head) == localpar_code) then -- -- begin of par -- local first = getnext(head) -- -- parbox .. needs to be set at 0 @@ -222,7 +223,8 @@ interfaces.implement { actions[v_default] = function(head,setting) local done = false - if getid(head) == whatsit_code and getsubtype(head) == localpar_code then + local id = getid(head) + if (id == localpar_code) or (id == whatsit_code and getsubtype(head) == localpar_code) then -- begin of par local first = getnext(head) local indent = false diff --git a/tex/context/base/typo-dua.lua b/tex/context/base/typo-dua.lua index 635ea6146..0cf84847d 100644 --- a/tex/context/base/typo-dua.lua +++ b/tex/context/base/typo-dua.lua @@ -98,9 +98,9 @@ local glue_code = nodecodes.glue local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist local math_code = nodecodes.math +local dir_code = nodecodes.dir or whatsitcodes.dir +local localpar_code = nodecodes.localpar or whatcodes.localpar local whatsit_code = nodecodes.whatsit -local dir_code = whatsitcodes.dir -local localpar_code = whatsitcodes.localpar local parfillskip_code = skipcodes.skipcodes ----- object_replacement = 0xFFFC -- object replacement character @@ -233,7 +233,7 @@ local function build_list(head) -- todo: store node pointer ... saves loop elseif id == glue_code then -- and how about kern list[size] = { char = 0x0020, direction = "ws", original = "ws", level = 0 } current = getnext(current) - elseif id == whatsit_code and getsubtype(current) == dir_code then + elseif id == dir_code or (id == whatsit_code and getsubtype(current) == dir_code) then local dir = getfield(current,"dir") if dir == "+TLT" then list[size] = { char = 0x202A, direction = "lre", original = "lre", level = 0 } @@ -261,7 +261,7 @@ local function build_list(head) -- todo: store node pointer ... saves loop current = getnext(current) while n do local id = getid(current) - if id ~= glyph_code and id ~= glue_code and not (id == whatsit_code and getsubtype(current) == dir_code) then + if id ~= glyph_code and id ~= glue_code and id ~= dir_code and not (id == whatsit_code and getsubtype(current) == dir_code) then skip = skip + 1 last = id current = getnext(current) @@ -323,8 +323,9 @@ local function find_run_limit_b_s_ws_on(list,start,limit) return start end -local function get_baselevel(head,list,size) -- todo: skip if first is object (or pass head and test for local_par) - if getid(head) == whatsit_code and getsubtype(head) == localpar_code then +local function get_baselevel(head,list,size) -- todo: skip if first is object (or pass head and test for localpar) + local id = getid(head) + if (id == localpar_code) or (id == whatsit_code and getsubtype(head) == localpar_code) then if getfield(head,"dir") == "TRT" then return 1, "TRT", true else @@ -759,9 +760,9 @@ local function apply_to_list(list,size,head,pardir) enddir = false done = true end - elseif id == whatsit_code then - if begindir and getsubtype(current) == localpar_code then - -- local_par should always be the 1st node + elseif begindir then + if (id == localpar_code) or (id == whatsit_code and getsubtype(current) == localpar_code) then + -- localpar should always be the 1st node local d = new_textdir(begindir) setprop(d,"directions",true) -- setfield(d,"attr",getfield(current,"attr")) diff --git a/tex/context/base/typo-dub.lua b/tex/context/base/typo-dub.lua index 0f23f0b20..789168a23 100644 --- a/tex/context/base/typo-dub.lua +++ b/tex/context/base/typo-dub.lua @@ -87,9 +87,9 @@ local glue_code = nodecodes.glue local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist local math_code = nodecodes.math +local dir_code = nodecodes.dir or whatsitcodes.dir +local localpar_code = nodecodes.localpar or whatcodes.localpar local whatsit_code = nodecodes.whatsit -local dir_code = whatsitcodes.dir -local localpar_code = whatsitcodes.localpar local parfillskip_code = skipcodes.skipcodes local maximum_stack = 0xFF -- unicode: 60, will be jumped to 125, we don't care too much @@ -288,7 +288,7 @@ local function build_list(head) -- todo: store node pointer ... saves loop elseif id == glue_code then -- and how about kern list[size] = { char = 0x0020, direction = "ws", original = "ws", level = 0 } current = getnext(current) - elseif id == whatsit_code and getsubtype(current) == dir_code then + elseif id == dir_code or (id == whatsit_code and getsubtype(current) == dir_code) then local dir = getfield(current,"dir") if dir == "+TLT" then list[size] = { char = 0x202A, direction = "lre", original = "lre", level = 0 } @@ -316,7 +316,7 @@ local function build_list(head) -- todo: store node pointer ... saves loop current = getnext(current) while n do local id = getid(current) - if id ~= glyph_code and id ~= glue_code and not (id == whatsit_code and getsubtype(current) == dir_code) then + if id ~= glyph_code and id ~= glue_code and id ~= dir_code and not (id == whatsit_code and getsubtype(current) == dir_code) then skip = skip + 1 last = id current = getnext(current) @@ -401,8 +401,9 @@ end -- the action -local function get_baselevel(head,list,size) -- todo: skip if first is object (or pass head and test for local_par) - if getid(head) == whatsit_code and getsubtype(head) == localpar_code then +local function get_baselevel(head,list,size) -- todo: skip if first is object (or pass head and test for localpar) + local id = getid(head) + if (id == localpar_code) or (id == whatsit_code and getsubtype(head) == localpar_code) then if getfield(head,"dir") == "TRT" then return 1, "TRT", true else @@ -885,9 +886,9 @@ local function apply_to_list(list,size,head,pardir) enddir = false done = true end - elseif id == whatsit_code then - if begindir and getsubtype(current) == localpar_code then - -- local_par should always be the 1st node + elseif begindir then + if (id == localpar_code) or (id == whatsit_code and getsubtype(current) == localpar_code) then + -- localpar should always be the 1st node local d = new_textdir(begindir) setprop(d,"directions",true) -- setfield(d,"attr",getfield(current,"attr")) diff --git a/tex/context/base/typo-lin.lua b/tex/context/base/typo-lin.lua index aabc39b17..3bc18bd52 100644 --- a/tex/context/base/typo-lin.lua +++ b/tex/context/base/typo-lin.lua @@ -71,8 +71,7 @@ local userskip_code = gluecodes.userskip local leftskip_code = gluecodes.leftskip local rightskip_code = gluecodes.rightskip local parfillskip_code = gluecodes.parfillskip -local textdir_code = whatcodes.textdir -local localpar_code = whatcodes.localpar +local localpar_code = nodecodes.localpar or whatcodes.localpar local tonut = nodes.tonut local tonode = nodes.tonode @@ -189,10 +188,8 @@ local function normalize(line,islocal) -- assumes prestine lines, nothing pre/ap current = getnext(head) id = getid(current) end - if id == whatsit_code then - if getsubtype(head) == localpar_code then - head = remove_node(head,head,true) - end + if (id == localpar_code) or (id == whatsit_code and getsubtype(head) == localpar_code) then + head = remove_node(head,head,true) end local tail = find_tail(head) local current = tail diff --git a/tex/context/base/typo-mar.lua b/tex/context/base/typo-mar.lua index c930e2712..605ddfc41 100644 --- a/tex/context/base/typo-mar.lua +++ b/tex/context/base/typo-mar.lua @@ -162,9 +162,6 @@ local cell_code = listcodes.cell local alignment_code = listcodes.alignment local userdefined_code = whatsitcodes.userdefined -local dir_code = whatsitcodes.dir -local localpar_code = whatsitcodes.localpar - local nodepool = nuts.pool local new_kern = nodepool.kern diff --git a/tex/context/base/typo-pag.lua b/tex/context/base/typo-pag.lua index 53f79fcfc..50b156e1c 100644 --- a/tex/context/base/typo-pag.lua +++ b/tex/context/base/typo-pag.lua @@ -49,7 +49,7 @@ local enabled = false trackers.register("parbuilders.keeptogether", function(v) trace_keeptogether = v end) -- todo: also support lines = 3 etc (e.g. dropped caps) but how to set that --- when no hlists are there ? ... maybe the local_par +-- when no hlists are there ? function parbuilders.registertogether(line,specification) -- might change if not specification then diff --git a/tex/generic/context/luatex/luatex-fonts-inj.lua b/tex/generic/context/luatex/luatex-fonts-inj.lua index da1364d9d..36781f72f 100644 --- a/tex/generic/context/luatex/luatex-fonts-inj.lua +++ b/tex/generic/context/luatex/luatex-fonts-inj.lua @@ -462,7 +462,11 @@ local function collect_glyphs(head,offsets) local f = getfont(n) if f ~= nf then nf = f - tm = fontdata[nf].resources.marks -- other hash in ctx + -- other hash in ctx: + tm = fontdata[nf].resources + if tm then + tm = tm.marks + end end if tm and tm[getchar(n)] then nofmarks = nofmarks + 1 diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 118fde56b..1504a0ee7 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 : 10/07/15 12:03:10 +-- merge date : 10/09/15 10:59:21 do -- begin closure to overcome local limits and interference @@ -7126,7 +7126,7 @@ local report_otf=logs.reporter("fonts","otf loading") local fonts=fonts local otf=fonts.handlers.otf otf.glists={ "gsub","gpos" } -otf.version=2.818 +otf.version=2.819 otf.cache=containers.define("fonts","otf",otf.version,true) local hashes=fonts.hashes local definers=fonts.definers @@ -8770,16 +8770,18 @@ actions["check metadata"]=function(data,filename,raw) ttftables[i].data="deleted" end end + local names=raw.names if metadata.validation_state and table.contains(metadata.validation_state,"bad_ps_fontname") then local function valid(what) - local names=raw.names - for i=1,#names do - local list=names[i] - local names=list.names - if names then - local name=names[what] - if name and valid_ps_name(name) then - return name + if names then + for i=1,#names do + local list=names[i] + local names=list.names + if names then + local name=names[what] + if name and valid_ps_name(name) then + return name + end end end end @@ -8802,6 +8804,28 @@ actions["check metadata"]=function(data,filename,raw) check("fontname") check("fullname") end + if names then + local psname=metadata.psname + if not psname or psname=="" then + for i=1,#names do + local name=names[i] + if lower(name.lang)=="english (us)" then + local specification=name.names + if specification then + local postscriptname=specification.postscriptname + if postscriptname then + psname=postscriptname + end + end + end + break + end + end + if psname~=metadata.fontname then + report_otf("fontname %a, fullname %a, psname %a",metadata.fontname,metadata.fullname,psname) + end + metadata.psname=psname + end end actions["cleanup tables"]=function(data,filename,raw) local duplicates=data.resources.duplicates @@ -9166,7 +9190,7 @@ local function copytotfm(data,cache_id) local filename=constructors.checkedfilename(resources) local fontname=metadata.fontname local fullname=metadata.fullname or fontname - local psname=fontname or fullname + local psname=metadata.psname or fontname or fullname local units=metadata.units or metadata.units_per_em or 1000 if units==0 then units=1000 @@ -10510,7 +10534,10 @@ local function collect_glyphs(head,offsets) local f=getfont(n) if f~=nf then nf=f - tm=fontdata[nf].resources.marks + tm=fontdata[nf].resources + if tm then + tm=tm.marks + end end if tm and tm[getchar(n)] then nofmarks=nofmarks+1 diff --git a/tex/generic/context/luatex/luatex-fonts.lua b/tex/generic/context/luatex/luatex-fonts.lua index dab3025e0..f18ba35db 100644 --- a/tex/generic/context/luatex/luatex-fonts.lua +++ b/tex/generic/context/luatex/luatex-fonts.lua @@ -215,9 +215,9 @@ if non_generic_context.luatex_fonts.skip_loading ~= true then loadmodule('font-oti.lua') loadmodule('font-otf.lua') loadmodule('font-otb.lua') - loadmodule('luatex-fonts-inj.lua') + loadmodule('luatex-fonts-inj.lua') -- normally the same as font-inj.lua loadmodule('luatex-fonts-ota.lua') - loadmodule('luatex-fonts-otn.lua') + loadmodule('luatex-fonts-otn.lua') -- normally the same as font-otn.lua loadmodule('font-otp.lua') loadmodule('luatex-fonts-lua.lua') loadmodule('font-def.lua') -- this code (stripped) might end up in luatex-fonts-def.lua |