From 5b41cee71daeaa60f4c92246d87f2d4f191d4733 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Mon, 4 Nov 2013 14:10:00 +0100 Subject: beta 2013.11.04 14:10 --- tex/context/base/scrp-cjk.lua | 70 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) (limited to 'tex/context/base/scrp-cjk.lua') 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 { }, }, } - -- cgit v1.2.3