diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/font-ots.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/font-ots.lua | 127 |
1 files changed, 70 insertions, 57 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-ots.lua b/Master/texmf-dist/tex/context/base/mkiv/font-ots.lua index b9f719a5fd8..c4f89c156be 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/font-ots.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/font-ots.lua @@ -177,7 +177,6 @@ registertracker("otf.sample.silent", "otf.steps=silent","otf.substitutions","otf local nuts = nodes.nuts -local getfield = nuts.getfield local getnext = nuts.getnext local setnext = nuts.setnext local getprev = nuts.getprev @@ -185,8 +184,6 @@ local setprev = nuts.setprev local getboth = nuts.getboth local setboth = nuts.setboth local getid = nuts.getid -local getattr = nuts.getattr -local setattr = nuts.setattr local getprop = nuts.getprop local setprop = nuts.setprop local getsubtype = nuts.getsubtype @@ -195,12 +192,16 @@ local getchar = nuts.getchar local setchar = nuts.setchar local getdisc = nuts.getdisc local setdisc = nuts.setdisc +local getreplace = nuts.getreplace local setlink = nuts.setlink local getcomponents = nuts.getcomponents -- the original one, not yet node-aux local setcomponents = nuts.setcomponents -- the original one, not yet node-aux local getwidth = nuts.getwidth +local getattr = nuts.getattr + +local getglyphdata = nuts.getglyphdata -local ischar = nuts.is_char +local ischar = nuts.ischar local isglyph = nuts.isglyph local usesfont = nuts.uses_font @@ -212,6 +213,7 @@ local find_node_tail = nuts.tail local flush_node_list = nuts.flush_list local flush_node = nuts.flush_node local end_of_math = nuts.end_of_math +local start_of_par = nuts.start_of_par local setmetatable = setmetatable local setmetatableindex = table.setmetatableindex @@ -2089,7 +2091,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck) if keepdisc then keepdisc = false lookaheaddisc = current - local replace = getfield(current,"replace") + local replace = getreplace(current) if not replace then sweepoverflow = true sweepnode = current @@ -2166,7 +2168,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck) lookaheaddisc = current end -- we assume a simple text only replace (we could use nuts.count) - local replace = getfield(current,"replace") + local replace = getreplace(current) while replace and i < s do if getid(replace) == glyph_code then i = i + 1 @@ -2212,7 +2214,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck) backtrackdisc = current end -- we assume a simple text only replace (we could use nuts.count) - local replace = getfield(current,"replace") + local replace = getreplace(current) while replace and i > 1 do if getid(replace) == glyph_code then i = i - 1 @@ -3177,7 +3179,7 @@ local function testrun(disc,t_run,c_run,...) end local pre, post, replace, pretail, posttail, replacetail = getdisc(disc,true) local renewed = false - if (post or replace) and prev then + if (post or replace) then -- and prev then -- hm, we can start with a disc if post then setlink(posttail,next) else @@ -3291,7 +3293,7 @@ end -- discretionaries (maybe we need to tag those some day). So, at least for now, we don't -- have the following test in the sub runs: -- --- -- local a = getattr(start,0) +-- -- local a = getglyhpdata(start) -- -- if a then -- -- a = (a == attr) and (not attribute or getprop(start,a_state) == attribute) -- -- else @@ -3301,7 +3303,7 @@ end -- -- but use this instead: -- --- -- local a = getattr(start,0) +-- -- local a = getglyphdata(start) -- -- if not a or (a == attr) then -- -- and even that one is probably not needed. However, we can handle interesting @@ -3327,7 +3329,7 @@ local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlm if char then local a -- happens often so no assignment is faster if attr then - a = getattr(start,0) + a = getglyphdata(start) end if not a or (a == attr) then local lookupmatch = lookupcache[char] @@ -3367,7 +3369,7 @@ local function t_run_single(start,stop,font,attr,lookupcache) if char then local a -- happens often so no assignment is faster if attr then - a = getattr(start,0) + a = getglyphdata(start) end local startnext = getnext(start) if not a or (a == attr) then @@ -3385,7 +3387,7 @@ local function t_run_single(start,stop,font,attr,lookupcache) -- how about post ... we can probably merge this into the while while getid(s) == disc_code do ss = getnext(s) - s = getfield(s,"replace") + s = getreplace(s) if not s then s = ss ss = nil @@ -3412,12 +3414,13 @@ local function t_run_single(start,stop,font,attr,lookupcache) end while getid(s) == disc_code do ss = getnext(s) - s = getfield(s,"replace") + s = getreplace(s) if not s then s = ss ss = nil end end +lookupmatch = lg else break end @@ -3451,7 +3454,7 @@ end local function k_run_single(sub,injection,last,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) local a -- happens often so no assignment is faster if attr then - a = getattr(sub,0) + a = getglyphdata(sub) end if not a or (a == attr) then for n in nextnode, sub do -- only gpos @@ -3487,7 +3490,7 @@ local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlm if char then local a -- happens often so no assignment is faster if attr then - a = getattr(start,0) + a = getglyphdata(start) end if not a or (a == attr) then for i=1,nofsteps do @@ -3535,7 +3538,7 @@ local function t_run_multiple(start,stop,font,attr,steps,nofsteps) if char then local a -- happens often so no assignment is faster if attr then - a = getattr(start,0) + a = getglyphdata(start) end local startnext = getnext(start) if not a or (a == attr) then @@ -3554,7 +3557,7 @@ local function t_run_multiple(start,stop,font,attr,steps,nofsteps) end while getid(s) == disc_code do ss = getnext(s) - s = getfield(s,"replace") + s = getreplace(s) if not s then s = ss ss = nil @@ -3581,12 +3584,13 @@ local function t_run_multiple(start,stop,font,attr,steps,nofsteps) end while getid(s) == disc_code do ss = getnext(s) - s = getfield(s,"replace") + s = getreplace(s) if not s then s = ss ss = nil end end +lookupmatch = lg else break end @@ -3616,7 +3620,7 @@ end local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) local a -- happens often so no assignment is faster if attr then - a = getattr(sub,0) + a = getglyphdata(sub) end if not a or (a == attr) then for n in nextnode, sub do -- only gpos @@ -3709,7 +3713,7 @@ do -- reference: -- - -- local a = attr and getattr(start,0) + -- local a = attr and getglyphdata(start) -- if a then -- a = (a == attr) and (not attribute or getprop(start,a_state) == attribute) -- else @@ -3720,7 +3724,7 @@ do -- -- local a -- happens often so no assignment is faster -- if attr then - -- if getattr(start,0) == attr and (not attribute or getprop(start,a_state) == attribute) then + -- if getglyphdata(start) == attr and (not attribute or getprop(start,a_state) == attribute) then -- a = true -- end -- elseif not attribute or getprop(start,a_state) == attribute then @@ -3801,7 +3805,7 @@ do local initialrl = 0 - if getid(head) == localpar_code and getsubtype(head) == 0 then + if getid(head) == localpar_code and start_of_par(head) then initialrl = pardirstate(head) elseif direction == 1 or direction == "TRT" then initialrl = -1 @@ -3860,7 +3864,7 @@ do if m then local a -- happens often so no assignment is faster if attr then - a = getattr(start,0) + a = getglyphdata(start) end if not a or (a == attr) then for i=m[1],m[2] do @@ -3907,7 +3911,7 @@ do if lookupmatch then local a -- happens often so no assignment is faster if attr then - if getattr(start,0) == attr and (not attribute or getprop(start,a_state) == attribute) then + if getglyphdata(start) == attr and (not attribute or getprop(start,a_state) == attribute) then a = true end elseif not attribute or getprop(start,a_state) == attribute then @@ -3955,7 +3959,7 @@ do elseif id == dir_code then topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode) start = getnext(start) - -- elseif id == localpar_code then + -- elseif id == localpar_code and start_of_par(start) then -- rlparmode, rlmode = pardirstate(start) -- start = getnext(start) else @@ -3974,7 +3978,7 @@ do if m then local a -- happens often so no assignment is faster if attr then - if getattr(start,0) == attr and (not attribute or getprop(start,a_state) == attribute) then + if getglyphdata(start) == attr and (not attribute or getprop(start,a_state) == attribute) then a = true end elseif not attribute or getprop(start,a_state) == attribute then @@ -4039,7 +4043,7 @@ do elseif id == dir_code then topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode) start = getnext(start) - -- elseif id == localpar_code then + -- elseif id == localpar_code and start_of_par(start) then -- rlparmode, rlmode = pardirstate(start) -- start = getnext(start) else @@ -4150,7 +4154,7 @@ do elseif id == dir_code then topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode) start = getnext(start) - -- elseif id == localpar_code then + -- elseif id == localpar_code and start_of_par(start) then -- rlparmode, rlmode = pardirstate(start) -- start = getnext(start) else @@ -4231,9 +4235,26 @@ registerotffeature { } } +-- Moved here (up) a bit. This doesn't really belong in generic so it will +-- move to a context module some day. + +local function markinitializer(tfmdata,value) + local properties = tfmdata.properties + properties.checkmarks = value +end + +registerotffeature { + name = "checkmarks", + description = "check mark widths", + default = true, + initializers = { + node = markinitializer, + }, +} + -- This can be used for extra handlers, but should be used with care! We implement one -- here but some more can be found in the osd (script devanagary) file. Now watch out: --- when a handlers has steps, it is called as the other ones, but when we have no steps, +-- when a handler has steps, it is called as the other ones, but when we have no steps, -- we use a different call: -- -- function(head,dataset,sequence,initialrl,font,attr) @@ -4244,22 +4265,28 @@ registerotffeature { otf.handlers = handlers +if context then + return +else + -- todo: move the following code someplace else +end + local setspacekerns = nodes.injections.setspacekerns if not setspacekerns then os.exit() end -local tag = "kern" -- maybe some day a merge +local tag = "kern" -if fontfeatures then +-- if fontfeatures then - function handlers.trigger_space_kerns(head,dataset,sequence,initialrl,font,attr) - local features = fontfeatures[font] - local enabled = features and features.spacekern and features[tag] - if enabled then - setspacekerns(font,sequence) - end - return head, enabled - end +-- function handlers.trigger_space_kerns(head,dataset,sequence,initialrl,font,attr) +-- local features = fontfeatures[font] +-- local enabled = features and features.spacekern and features[tag] +-- if enabled then +-- setspacekerns(font,sequence) +-- end +-- return head, enabled +-- end -else -- generic (no hashes) +-- else -- generic (no hashes) function handlers.trigger_space_kerns(head,dataset,sequence,initialrl,font,attr) local shared = fontdata[font].shared @@ -4271,7 +4298,7 @@ else -- generic (no hashes) return head, enabled end -end +-- end -- There are fonts out there that change the space but we don't do that kind of -- things in TeX. @@ -4389,7 +4416,7 @@ local function spaceinitializer(tfmdata,value) -- attr if rules then -- not now: analyze (simple) rules elseif not coverage then - -- nothng to do + -- nothing to do elseif kind == "gpos_single" then -- makes no sense in TeX elseif kind == "gpos_pair" then @@ -4473,17 +4500,3 @@ registerotffeature { node = spaceinitializer, }, } - -local function markinitializer(tfmdata,value) - local properties = tfmdata.properties - properties.checkmarks = value -end - -registerotffeature { - name = "checkmarks", - description = "check mark widths", - default = true, - initializers = { - node = markinitializer, - }, -} |