diff options
author | Marius <mariausol@gmail.com> | 2013-11-04 15:20:14 +0200 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2013-11-04 15:20:14 +0200 |
commit | 0c91921644d2dafa66041f56be1e4c8e045128d6 (patch) | |
tree | b51cd2465ceebafb5da72822a6ddde47c0811d58 /tex/context/base/scrp-cjk.lua | |
parent | 176eb4a0fb38bc08a1b93b60d9d68f613e08411e (diff) | |
download | context-0c91921644d2dafa66041f56be1e4c8e045128d6.tar.gz |
beta 2013.11.04 14:10
Diffstat (limited to 'tex/context/base/scrp-cjk.lua')
-rw-r--r-- | tex/context/base/scrp-cjk.lua | 70 |
1 files changed, 67 insertions, 3 deletions
diff --git a/tex/context/base/scrp-cjk.lua b/tex/context/base/scrp-cjk.lua index f7167b45c..0ceaf4bd2 100644 --- a/tex/context/base/scrp-cjk.lua +++ b/tex/context/base/scrp-cjk.lua @@ -16,9 +16,11 @@ if not modules then modules = { } end modules ['scrp-cjk'] = { local utfchar = utf.char -local insert_node_after = node.insert_after -local insert_node_before = node.insert_before +local insert_node_after = nodes.insert_after +local insert_node_before = nodes.insert_before local remove_node = nodes.remove +local copy_node = nodes.copy +local traverse_id = nodes.traverse_id local nodepool = nodes.pool local new_glue = nodepool.glue @@ -44,6 +46,8 @@ local fontdata = fonthashes.identifiers local quaddata = fonthashes.quads local spacedata = fonthashes.spaces +local decomposed = characters.hangul.decomposed + local trace_details = false trackers.register("scripts.details", function(v) trace_details = v end) local report_details = logs.reporter("scripts","detail") @@ -490,6 +494,67 @@ scripts.installmethod { }, } +-- function scripts.decomposehangul(head) +-- local current = head +-- local done = false +-- while current do +-- local id = current.id +-- if id == glyph_code then -- local index = unicode - 0xAC00 if index >= 0 and index < 19 * 21 * 28 then ... end +-- local lead_consonant, medial_vowel, tail_consonant = decomposed(current.char) +-- if lead_consonant then +-- if not tail_consonant then +-- tail_consonant = 0x11A7 +-- end +-- current.char = lead_consonant +-- local m = copy_node(current) +-- local t = copy_node(current) +-- m.char = medial_vowel +-- t.char = tail_consonant +-- insert_node_after(head,current,m) +-- insert_node_after(head,current,t) +-- done = true +-- current = t +-- end +-- end +-- current = current.next +-- end +-- return head, done +-- end + +function scripts.decomposehangul(head) + local done = false + for current in traverse_id(glyph_code,head) do + local lead_consonant, medial_vowel, tail_consonant = decomposed(current.char) + if lead_consonant then + if not tail_consonant then + tail_consonant = 0x11A7 + end + current.char = tail_consonant + local l = copy_node(current) + local m = copy_node(current) + l.char = lead_consonant + m.char = medial_vowel + head, current = insert_node_before(head,current,m) + head, current = insert_node_before(head,current,l) + done = true + end + end + return head, done +end + +-- nodes.tasks.prependaction("processors","normalizers","scripts.decomposehangul") + +local otffeatures = fonts.constructors.newfeatures("otf") +local registerotffeature = otffeatures.register + +registerotffeature { + name = "decomposehangul", + description = "decompose hangul", + processors = { + -- position = 1, + node = scripts.decomposehangul, + } +} -- Chinese: hanzi local chinese_0 = { @@ -948,4 +1013,3 @@ scripts.installmethod { }, }, } - |