diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2015-06-13 00:40:45 +0200 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2015-06-13 00:40:45 +0200 |
commit | 90f398e1c9d2896b2d30d0b66f9c8a88255511a8 (patch) | |
tree | 88459ad0c6986a6648c969726081248cd5c8d74e /src/fontloader/misc/fontloader-fonts-cbk.lua | |
parent | c4c4901173b0f4284534db1b6a3cfe865b05e15c (diff) | |
parent | b271e253b40cd0af97f6d50f0461f87ad1ed5314 (diff) | |
download | luaotfload-90f398e1c9d2896b2d30d0b66f9c8a88255511a8.tar.gz |
Merge pull request #274 from phi-gamma/master
pull in current state of affairs
Diffstat (limited to 'src/fontloader/misc/fontloader-fonts-cbk.lua')
-rw-r--r-- | src/fontloader/misc/fontloader-fonts-cbk.lua | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/fontloader/misc/fontloader-fonts-cbk.lua b/src/fontloader/misc/fontloader-fonts-cbk.lua index ce19c88..81b5b6e 100644 --- a/src/fontloader/misc/fontloader-fonts-cbk.lua +++ b/src/fontloader/misc/fontloader-fonts-cbk.lua @@ -17,6 +17,9 @@ local nodes = nodes -- Fonts: (might move to node-gef.lua) local traverse_id = node.traverse_id +local free_node = node.free +local remove_node = node.remove + local glyph_code = nodes.nodecodes.glyph local disc_code = nodes.nodecodes.disc @@ -57,6 +60,8 @@ function nodes.handlers.nodepass(head) local basefonts = { } local prevfont = nil local basefont = nil + local variants = nil + local redundant = nil for n in traverse_id(glyph_code,head) do local font = n.font if font ~= prevfont then @@ -78,9 +83,46 @@ 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 + if not redundant then + redundant = { n } + else + redundant[#redundant+1] = n + end + end + end + end + end + end + end + if redundant then + for i=1,#redundant do + local n = redundant[i] + remove_node(head,n) + free_node(n) + end end for d in traverse_id(disc_code,head) do local r = d.replace |