From 782b43e2fb4420cd950c8087222758e223df01bf Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Tue, 21 Feb 2012 00:51:00 +0100 Subject: beta 2012.02.21 00:51 --- tex/generic/context/luatex/luatex-fonts-merged.lua | 188 +++++++++++---------- 1 file changed, 101 insertions(+), 87 deletions(-) (limited to 'tex/generic') diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index d85a0f4a3..09cff0c18 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 : 02/18/12 10:50:58 +-- merge date : 02/21/12 00:51:07 do -- begin closure to overcome local limits and interference @@ -8111,6 +8111,7 @@ local cursbase = attributes.private('cursbase') local curscurs = attributes.private('curscurs') local cursdone = attributes.private('cursdone') local kernpair = attributes.private('kernpair') +local ligacomp = attributes.private('ligacomp') local fontkern = attributes.private('fontkern') if context then @@ -8129,20 +8130,19 @@ end -- This injector has been tested by Idris Samawi Hamid (several arabic fonts as well as -- the rather demanding Husayni font), Khaled Hosny (latin and arabic) and Kaj Eigner --- (arabic, hebrew and thai) and myself (whatever font I come across). +-- (arabic, hebrew and thai) and myself (whatever font I come across). I'm pretty sure +-- that this code is not 100% okay but examples are needed to figure things out. -local cursives = { } -local marks = { } -local kerns = { } -local markcount = { } +local cursives = { } +local marks = { } +local kerns = { } --- currently we do gpos/kern in a bit inofficial way but when we --- have the extra fields in glyphnodes to manipulate ht/dp/wd --- explicitly i will provide an alternative; also, we can share --- tables +-- Currently we do gpos/kern in a bit inofficial way but when we have the extra fields in +-- glyphnodes to manipulate ht/dp/wd explicitly I will provide an alternative; also, we +-- can share tables. --- for the moment we pass the r2l key ... volt/arabtype tests .. idris: this needs --- checking with husayni (volt and fontforge) +-- For the moment we pass the r2l key ... volt/arabtype tests .. idris: this needs +-- checking with husayni (volt and fontforge). function injections.setcursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmnext) local dx, dy = factor*(exit[1]-entry[1]), factor*(exit[2]-entry[2]) @@ -8186,12 +8186,14 @@ function injections.setkern(current,factor,rlmode,x,tfmchr) end function injections.setmark(start,base,factor,rlmode,ba,ma,index) -- ba=baseanchor, ma=markanchor - local dx, dy = factor*(ba[1]-ma[1]), factor*(ba[2]-ma[2]) -- index argument no longer used - local bound = has_attribute(base,markbase) + local dx, dy = factor*(ba[1]-ma[1]), factor*(ba[2]-ma[2]) -- the index argument is no longer used but when this + local bound = has_attribute(base,markbase) -- fails again we should pass it +local index = 1 if bound then local mb = marks[bound] if mb then - if not index then index = #mb + 1 end + -- if not index then index = #mb + 1 end +index = #mb + 1 mb[index] = { dx, dy, rlmode } set_attribute(start,markmark,bound) set_attribute(start,markdone,index) @@ -8200,6 +8202,7 @@ function injections.setmark(start,base,factor,rlmode,ba,ma,index) -- ba=baseanch report_injections("possible problem, U+%05X is base mark without data (id: %s)",base.char,bound) end end +-- index = index or 1 index = index or 1 bound = #marks + 1 set_attribute(base,markbase,bound) @@ -8264,8 +8267,8 @@ end -- todo: reuse tables (i.e. no collection), but will be extra fields anyway -- todo: check for attribute --- we can have a fast test on a font being processed, so we can check faster for marks etc --- but I'll make a context variant anyway +-- We can have a fast test on a font being processed, so we can check faster for marks etc +-- but I'll make a context variant anyway. function injections.handler(head,where,keep) local has_marks, has_cursives, has_kerns = next(marks), next(cursives), next(kerns) @@ -8403,6 +8406,7 @@ function injections.handler(head,where,keep) local p_markbase = has_attribute(p,markbase) if p_markbase then local mrks = marks[p_markbase] + local nofmarks = #mrks for n in traverse_id(glyph_code,p.next) do local n_markmark = has_attribute(n,markmark) if p_markbase == n_markmark then @@ -8439,20 +8443,20 @@ function injections.handler(head,where,keep) else n.yoffset = n.yoffset + p.yoffset + d[2] end --- markcount[n_markmark] = (markcount[n_markmark] or 0) + 1 --- if markcount[n_markmark] == #mrks then --- break -- KE --- end + if nofmarks == 1 then + break + else + nofmarks = nofmarks - 1 + end end - -- else - -- break -- KE: there can be sequences in ligatures + else + -- KE: there can be sequences in ligatures end end end end if not keep then marks = { } --- markcount = { } end end -- todo : combine @@ -8592,6 +8596,7 @@ if not modules then modules = { } end modules ['font-otn'] = { -- default features (per language, script) -- handle positions (we need example fonts) -- handle gpos_single (we might want an extra width field in glyph nodes because adding kerns might interfere) +-- mark (to mark) code is still not what it should be (too messy but we need some more extreem husayni tests) --[[ldx--

This module is a bit more split up that I'd like but since we also want to test @@ -8757,14 +8762,21 @@ local ligature_code = glyphcodes.ligature local privateattribute = attributes.private +-- Something is messed up: we have two mark / ligature indices, one at the injection +-- end and one here ... this is bases in KE's patches but there is something fishy +-- there as I'm pretty sure that for husayni we need some connection (as it's much +-- more complex than an average font) but I need proper examples of all cases, not +-- of only some. + local state = privateattribute('state') local markbase = privateattribute('markbase') local markmark = privateattribute('markmark') -local markdone = privateattribute('markdone') +local markdone = privateattribute('markdone') -- assigned at the injection end local cursbase = privateattribute('cursbase') local curscurs = privateattribute('curscurs') local cursdone = privateattribute('cursdone') local kernpair = privateattribute('kernpair') +local ligacomp = privateattribute('ligacomp') -- assigned here (ideally it should be combined) local injections = nodes.injections local setmark = injections.setmark @@ -8917,7 +8929,7 @@ local function toligature(kind,lookupname,start,stop,char,markflag,discfound) -- return lignode else -- start is the ligature - -- local deletemarks = markflag ~= "mark" + local deletemarks = markflag ~= "mark" local n = copy_node(start) local current current, start = insert_node_after(start,start,n) @@ -8932,48 +8944,38 @@ local function toligature(kind,lookupname,start,stop,char,markflag,discfound) -- current.subtype = ligature_code current.components = start local head = current - -- if deletemarks then -- KE: was wrong - -- if trace_marks then - -- while start do - -- if marks[start.char] then - -- logwarning("%s: remove mark %s",pref(kind,lookupname),gref(start.char)) - -- end - -- start = start.next - -- end - -- end - -- else - local i = 0 - while start do - if marks[start.char] then - set_attribute(start,markdone,i) - if trace_marks then - logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(start.char),i) - end - head, current = insert_node_after(head,current,copy_node(start)) - else - i = i + 1 - end - start = start.next - end - start = current.next - while start and start.id == glyph_code do - if marks[start.char] then - set_attribute(start,markdone,i) - if trace_marks then - logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(start.char),i) - end - else - break + -- this is messy ... we should get rid of the components eventually + local i = 0 -- is index of base + while start do + if not marks[start.char] then + i = i + 1 + elseif not deletemarks then -- quite fishy + set_attribute(start,ligacomp,i) + if trace_marks then + logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(start.char),i) + end + head, current = insert_node_after(head,current,copy_node(start)) + end + start = start.next + end + start = current.next + while start and start.id == glyph_code do + if marks[start.char] then + set_attribute(start,ligacomp,i) + if trace_marks then + logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(start.char),i) end - start = start.next + else + break end - -- end - -- - -- we do need components in funny kerning mode but maybe I can better reconstruct then - -- as we do have the font components info available; removing components makes the - -- previous code much simpler - -- - -- flush_node_list(head.components) + start = start.next + end + -- + -- we do need components in funny kerning mode but maybe I can better reconstruct then + -- as we do have the font components info available; removing components makes the + -- previous code much simpler + -- + -- flush_node_list(head.components) return head end end @@ -9225,18 +9227,14 @@ function handlers.gpos_mark2ligature(start,kind,lookupname,markanchors,sequence) local markchar = start.char if marks[markchar] then local base = start.prev -- [glyph] [optional marks] [start=mark] - local index = 1 if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then local basechar = base.char if marks[basechar] then - index = index + 1 while true do base = base.prev if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then basechar = base.char - if marks[basechar] then - index = index + 1 - else + if not marks[basechar] then break end else @@ -9247,9 +9245,7 @@ function handlers.gpos_mark2ligature(start,kind,lookupname,markanchors,sequence) end end end --- local i = has_attribute(start,markdone) --- if i then index = i end -- needed -local index = has_attribute(start,markdone) + local index = has_attribute(start,ligacomp) local baseanchors = descriptions[basechar] if baseanchors then baseanchors = baseanchors.anchors @@ -9263,7 +9259,7 @@ local index = has_attribute(start,markdone) if ma then ba = ba[index] if ba then - local dx, dy, bound = setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma) -- ,index) + local dx, dy, bound = setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma) -- index if trace_marks then logprocess("%s, anchor %s, index %s, bound %s: anchoring mark %s to baselig %s at index %s => (%s,%s)", pref(kind,lookupname),anchor,index,bound,gref(markchar),gref(basechar),index,dx,dy) @@ -9295,11 +9291,20 @@ function handlers.gpos_mark2mark(start,kind,lookupname,markanchors,sequence) local markchar = start.char if marks[markchar] then local base = start.prev -- [glyph] [basemark] [start=mark] - -- new - while base and has_attribute(base,markdone) and has_attribute(base,markdone) ~= has_attribute(start,markdone) do - base = base.prev -- KE: prevents mknk fo rmarks on different components of a ligature + -- while base and has_attribute(base,ligacomp) and has_attribute(base,ligacomp) ~= has_attribute(start,ligacomp) do + -- base = base.prev -- KE: prevents mkmk for marks on different components of a ligature + -- end + local slc = has_attribute(start,ligacomp) + if slc then -- a rather messy loop ... needs checking with husayni + while base do + local blc = has_attribute(base,ligacomp) + if blc and blc ~= slc then + base = base.prev + else + break + end + end end - -- if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then -- subtype test can go local basechar = base.char local baseanchors = descriptions[basechar] @@ -9859,18 +9864,14 @@ function chainprocs.gpos_mark2ligature(start,stop,kind,chainname,currentcontext, end if markanchors then local base = start.prev -- [glyph] [optional marks] [start=mark] - local index = 1 if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then local basechar = base.char if marks[basechar] then - index = index + 1 while true do base = base.prev if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then basechar = base.char - if marks[basechar] then - index = index + 1 - else + if not marks[basechar] then break end else @@ -9882,8 +9883,7 @@ function chainprocs.gpos_mark2ligature(start,stop,kind,chainname,currentcontext, end end -- todo: like marks a ligatures hash - local i = has_attribute(start,markdone) - if i then index = i end + local index = has_attribute(start,ligacomp) local baseanchors = descriptions[basechar].anchors if baseanchors then local baseanchors = baseanchors['baselig'] @@ -9895,7 +9895,7 @@ function chainprocs.gpos_mark2ligature(start,stop,kind,chainname,currentcontext, if ma then ba = ba[index] if ba then - local dx, dy, bound = setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma,index) + local dx, dy, bound = setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma) -- index if trace_marks then logprocess("%s, anchor %s, bound %s: anchoring mark %s to baselig %s at index %s => (%s,%s)", cref(kind,chainname,chainlookupname,lookupname),anchor,a or bound,gref(markchar),gref(basechar),index,dx,dy) @@ -9936,6 +9936,20 @@ function chainprocs.gpos_mark2mark(start,stop,kind,chainname,currentcontext,look end if markanchors then local base = start.prev -- [glyph] [basemark] [start=mark] + -- while (base and has_attribute(base,ligacomp) and has_attribute(base,ligacomp) ~= has_attribute(start,ligacomp)) do + -- base = base.prev -- KE: prevents mkmk for marks on different components of a ligature + -- end + local slc = has_attribute(start,ligacomp) + if slc then -- a rather messy loop ... needs checking with husayni + while base do + local blc = has_attribute(base,ligacomp) + if blc and blc ~= slc then + base = base.prev + else + break + end + end + end if base and base.id == glyph_code and base.subtype<256 and base.font == currentfont then -- subtype test can go local basechar = base.char local baseanchors = descriptions[basechar].anchors -- cgit v1.2.3