From 84c9614c8d2e0a3beaa9fdf42530087f3df4b807 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Fri, 22 May 2015 20:15:05 +0200 Subject: 2015-05-22 19:27:00 --- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4178 -> 4181 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/font-hsh.lua | 19 ++++++ tex/context/base/font-mis.lua | 2 +- tex/context/base/font-otf.lua | 61 ++++++++++++----- tex/context/base/font-otn.lua | 4 ++ tex/context/base/font-syn.lua | 1 + tex/context/base/node-fnt.lua | 39 +++++++++++ tex/context/base/status-files.pdf | Bin 24514 -> 24527 bytes tex/context/base/status-lua.pdf | Bin 251206 -> 251253 bytes tex/generic/context/luatex/luatex-fonts-cbk.lua | 33 ++++++++++ tex/generic/context/luatex/luatex-fonts-merged.lua | 73 ++++++++++++++++++--- 13 files changed, 208 insertions(+), 28 deletions(-) (limited to 'tex') diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 95a707514..266d84cba 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2015.05.21 13:39} +\newcontextversion{2015.05.22 19:25} %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/context-version.pdf b/tex/context/base/context-version.pdf index 63deabdbb..824360cdf 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 029516ce4..70075043e 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.05.21 13:39} +\edef\contextversion{2015.05.22 19:25} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/font-hsh.lua b/tex/context/base/font-hsh.lua index 07acf2138..46d82d78f 100644 --- a/tex/context/base/font-hsh.lua +++ b/tex/context/base/font-hsh.lua @@ -37,6 +37,7 @@ local dynamics = hashes.dynamics or allocate() local unicodes = hashes.unicodes or allocate() local originals = hashes.originals or allocate() local modes = hashes.modes or allocate() +local variants = hashes.variants or allocate() hashes.characters = characters hashes.descriptions = descriptions @@ -56,6 +57,7 @@ hashes.dynamics = dynamics hashes.unicodes = unicodes hashes.originals = originals hashes.modes = modes +hashes.variants = variants local nodepool = nodes.pool local dummyglyph = nodepool.register(nodepool.glyph()) @@ -303,6 +305,23 @@ setmetatableindex(modes, function(t,k) end end) +setmetatableindex(variants, function(t,k) + if k == true then + return variants[currentfont()] + else + local resources = resources[k] + if resources then + local variants = resources.variants + if variants and next(variants) then + t[k] = variants + return variants + end + end + t[k] = false + return false + end +end) + function font.getfont(id) return identifiers[id] end diff --git a/tex/context/base/font-mis.lua b/tex/context/base/font-mis.lua index c7fb1da1b..7cdd346c2 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.810 +otf.version = otf.version or 2.811 otf.cache = otf.cache or containers.define("fonts", "otf", otf.version, true) local fontloader = fontloader diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua index dab7137f8..a91937039 100644 --- a/tex/context/base/font-otf.lua +++ b/tex/context/base/font-otf.lua @@ -54,7 +54,7 @@ local otf = fonts.handlers.otf otf.glists = { "gsub", "gpos" } -otf.version = 2.810 -- beware: also sync font-mis.lua +otf.version = 2.811 -- beware: also sync font-mis.lua otf.cache = containers.define("fonts", "otf", otf.version, true) local hashes = fonts.hashes @@ -819,6 +819,35 @@ actions["prepare glyphs"] = function(data,filename,raw) glyph = glyph, } descriptions[unicode] = description +local altuni = glyph.altuni +if altuni then + -- local d + for i=1,#altuni do + local a = altuni[i] + local u = a.unicode + if u ~= unicode then + local v = a.variant + if v then + -- tricky: no addition to d? needs checking but in practice such dups are either very simple + -- shapes or e.g cjk with not that many features + local vv = variants[v] + if vv then + vv[u] = unicode + else -- xits-math has some: + vv = { [u] = unicode } + variants[v] = vv + end + -- elseif d then + -- d[#d+1] = u + -- else + -- d = { u } + end + end + end + -- if d then + -- duplicates[unicode] = d -- is this needed ? + -- end +end end end else @@ -902,21 +931,23 @@ actions["prepare glyphs"] = function(data,filename,raw) for i=1,#altuni do local a = altuni[i] local u = a.unicode - local v = a.variant - if v then - -- tricky: no addition to d? needs checking but in practice such dups are either very simple - -- shapes or e.g cjk with not that many features - local vv = variants[v] - if vv then - vv[u] = unicode - else -- xits-math has some: - vv = { [u] = unicode } - variants[v] = vv + if u ~= unicode then + local v = a.variant + if v then + -- tricky: no addition to d? needs checking but in practice such dups are either very simple + -- shapes or e.g cjk with not that many features + local vv = variants[v] + if vv then + vv[u] = unicode + else -- xits-math has some: + vv = { [u] = unicode } + variants[v] = vv + end + -- elseif d then + -- d[#d+1] = u + -- else + -- d = { u } end - -- elseif d then - -- d[#d+1] = u - -- else - -- d = { u } end end -- if d then diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua index b1bd45304..b265dbbeb 100644 --- a/tex/context/base/font-otn.lua +++ b/tex/context/base/font-otn.lua @@ -3422,6 +3422,10 @@ local function prepare_lookups(tfmdata) -- much memory as it's only a reference to a table and the slot in the -- description hash is not freed anyway + -- we can delay this using metatables so that we don't make the hashes for + -- features we don't use but then we need to loop over the characters + -- many times so we gain nothing + for unicode, character in next, characters do -- we cannot loop over descriptions ! local description = descriptions[unicode] diff --git a/tex/context/base/font-syn.lua b/tex/context/base/font-syn.lua index bf46c8573..e625419ee 100644 --- a/tex/context/base/font-syn.lua +++ b/tex/context/base/font-syn.lua @@ -7,6 +7,7 @@ if not modules then modules = { } end modules ['font-syn'] = { } -- todo: subs in lookups requests +-- todo: see if the (experimental) lua reader (on my machine) be used (it's a bit slower so maybe wait till lua 5.3) local next, tonumber, type, tostring = next, tonumber, type, tostring local sub, gsub, lower, match, find, lower, upper = string.sub, string.gsub, string.lower, string.match, string.find, string.lower, string.upper diff --git a/tex/context/base/node-fnt.lua b/tex/context/base/node-fnt.lua index 774a68718..d818e4544 100644 --- a/tex/context/base/node-fnt.lua +++ b/tex/context/base/node-fnt.lua @@ -23,6 +23,7 @@ local report_fonts = logs.reporter("fonts","processing") local fonthashes = fonts.hashes local fontdata = fonthashes.identifiers +local fontvariants = fonthashes.variants local otf = fonts.handlers.otf @@ -44,8 +45,10 @@ local getchar = nuts.getchar local getnext = nuts.getnext local getprev = nuts.getprev local getfield = nuts.getfield +local setfield = nuts.setfield local traverse_id = nuts.traverse_id +local delete_node = nuts.delete local glyph_code = nodecodes.glyph local disc_code = nodecodes.disc @@ -135,6 +138,7 @@ function handlers.characters(head) local prevfont = nil local prevattr = 0 local done = false + local variants = false if trace_fontrun then run = run + 1 @@ -200,6 +204,23 @@ function handlers.characters(head) end prevfont = font prevattr = attr + variants = fontvariants[font] + end + if variants then + local char = getchar(n) + if char >= 0xFE00 and (char <= 0xFE0F or (char >= 0xE0100 and char <= 0xE01EF)) then + local hash = variants[char] + if hash then + local p = getprev(n) + if p and getid(p) == glyph_code then + local variant = hash[getchar(p)] + if variant then + setfield(p,"char",variant) + delete_node(nuthead,n) + end + end + end + end end end end @@ -499,6 +520,24 @@ end -- end -- prevfont = font -- prevattr = attr +-- variants = fontvariants[font] +-- end +-- if variants then +-- local char = getchar(n) +-- if char >= 0xFE00 and (char <= 0xFE0F or (char >= 0xE0100 and char <= 0xE01EF)) then +-- local hash = variants[char] +-- if hash then +-- local p = getprev(n) +-- if p and getid(p) == glyph_code then +-- local variant = hash[getchar(p)] +-- if variant then +-- setfield(p,"char",variant) +-- delete_node(nuthead,n) +-- end +-- end +-- end +-- end +-- end -- end -- -- end -- end diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 828eca6c8..45487ace4 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 91d2fdb2c..e4d0ca403 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/generic/context/luatex/luatex-fonts-cbk.lua b/tex/generic/context/luatex/luatex-fonts-cbk.lua index ce19c8811..58162b4af 100644 --- a/tex/generic/context/luatex/luatex-fonts-cbk.lua +++ b/tex/generic/context/luatex/luatex-fonts-cbk.lua @@ -17,6 +17,8 @@ local nodes = nodes -- Fonts: (might move to node-gef.lua) local traverse_id = node.traverse_id +local free_node = node.free + local glyph_code = nodes.nodecodes.glyph local disc_code = nodes.nodecodes.disc @@ -57,6 +59,7 @@ function nodes.handlers.nodepass(head) local basefonts = { } local prevfont = nil local basefont = nil + local variants = nil for n in traverse_id(glyph_code,head) do local font = n.font if font ~= prevfont then @@ -78,6 +81,36 @@ function nodes.handlers.nodepass(head) basefonts[#basefonts+1] = basefont end end + local resources = tfmdata.resources + variants = resources and resources.variants + variants = variants and next(variants) and variants or false + end + else + local tfmdata = fontdata[prevfont] + if tfmdata then + local resources = tfmdata.resources + variants = resources and resources.variants + variants = variants and next(variants) and variants or false + end + end + end + if variants then + local char = n.char + if char >= 0xFE00 and (char <= 0xFE0F or (char >= 0xE0100 and char <= 0xE01EF)) then + local hash = variants[char] + if hash then + local p = n.prev + if p and p.id == glyph_code then + local variant = hash[p.char] + if variant then + p.char = variant + p.next = n.next + if n.next then + n.next.prev = p + end + node.free(n) + end + end end end end diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index a3112d206..c060dc304 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 : 05/21/15 13:39:28 +-- merge date : 05/22/15 19:25:13 do -- begin closure to overcome local limits and interference @@ -7176,7 +7176,7 @@ local report_otf=logs.reporter("fonts","otf loading") local fonts=fonts local otf=fonts.handlers.otf otf.glists={ "gsub","gpos" } -otf.version=2.810 +otf.version=2.811 otf.cache=containers.define("fonts","otf",otf.version,true) local hashes=fonts.hashes local definers=fonts.definers @@ -7810,6 +7810,25 @@ actions["prepare glyphs"]=function(data,filename,raw) glyph=glyph, } descriptions[unicode]=description +local altuni=glyph.altuni +if altuni then + for i=1,#altuni do + local a=altuni[i] + local u=a.unicode + if u~=unicode then + local v=a.variant + if v then + local vv=variants[v] + if vv then + vv[u]=unicode + else + vv={ [u]=unicode } + variants[v]=vv + end + end + end + end +end end end else @@ -7880,14 +7899,16 @@ actions["prepare glyphs"]=function(data,filename,raw) for i=1,#altuni do local a=altuni[i] local u=a.unicode - local v=a.variant - if v then - local vv=variants[v] - if vv then - vv[u]=unicode - else - vv={ [u]=unicode } - variants[v]=vv + if u~=unicode then + local v=a.variant + if v then + local vv=variants[v] + if vv then + vv[u]=unicode + else + vv={ [u]=unicode } + variants[v]=vv + end end end end @@ -15189,6 +15210,7 @@ end local fonts=fonts local nodes=nodes local traverse_id=node.traverse_id +local free_node=node.free local glyph_code=nodes.nodecodes.glyph local disc_code=nodes.nodecodes.disc local ligaturing=node.ligaturing @@ -15218,6 +15240,7 @@ function nodes.handlers.nodepass(head) local basefonts={} local prevfont=nil local basefont=nil + local variants=nil for n in traverse_id(glyph_code,head) do local font=n.font if font~=prevfont then @@ -15239,6 +15262,36 @@ function nodes.handlers.nodepass(head) basefonts[#basefonts+1]=basefont end end + local resources=tfmdata.resources + variants=resources and resources.variants + variants=variants and next(variants) and variants or false + end + else + local tfmdata=fontdata[prevfont] + if tfmdata then + local resources=tfmdata.resources + variants=resources and resources.variants + variants=variants and next(variants) and variants or false + end + end + end + if variants then + local char=n.char + if char>=0xFE00 and (char<=0xFE0F or (char>=0xE0100 and char<=0xE01EF)) then + local hash=variants[char] + if hash then + local p=n.prev + if p and p.id==glyph_code then + local variant=hash[p.char] + if variant then + p.char=variant + p.next=n.next + if n.next then + n.next.prev=p + end + node.free(n) + end + end end end end -- cgit v1.2.3