diff options
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luatexko/luatexko.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luatexko/luatexko.lua | 89 |
1 files changed, 52 insertions, 37 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua index 9a076f151c0..b84f7521af7 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua @@ -11,18 +11,20 @@ -- and version 1.3c or later is part of all distributions of LaTeX -- version 2006/05/20 or later. -local err,warn,info,log = luatexbase.provides_module({ +luatexbase.provides_module { name = 'luatexko', - date = '2015/07/02', - version = 1.9, + date = '2015/10/02', + version = '1.10', description = 'Korean linebreaking and font-switching', author = 'Dohyun Kim, Soojin Nam', license = 'LPPL v1.3+', -}) +} luatexko = luatexko or {} local luatexko = luatexko +local warn = function(...) return luatexbase.module_warning("luatexko", format(...)) end + local dotemphnode,rubynode,ulinebox = {},{},{} luatexko.dotemphnode = dotemphnode luatexko.rubynode = rubynode @@ -261,6 +263,7 @@ local postbreakpenalty = { [0xFF40] = 10000, [0xFF5B] = 10000, [0xFE37] = 10000, + [0xFF62] = 10000, -- 「 } local prebreakpenalty = { @@ -351,6 +354,7 @@ local prebreakpenalty = { [0xFE48] = 10000, [0xFF5D] = 10000, [0xFE38] = 10000, + [0xFF63] = 10000, -- 」 } local xspcode = { @@ -944,6 +948,31 @@ end ---------------------------------- -- compress fullwidth punctuations ---------------------------------- +local function check_next_halt_kern (head, curr) + -- glyph halt_kern glue -> glyph halt_kern rule glue + local nn = d_nodenext(curr) + if nn and d_getid(nn) == kernnode and d_nodenext(nn) then + d_insert_after(head, nn, d_get_rulenode(0)) + end +end + +local function check_prev_halt_kern (head, curr) + local pn = d_nodeprev(curr) + if pn and d_getid(pn) == kernnode and d_nodeprev(pn) then + -- glue halt_kern glyph -> glue rule halt_kern glyph + head = d_insert_before(head, pn, d_get_rulenode(0)) + elseif pn and d_getid(pn) == gluenode and d_has_attribute(pn, luakoglueattr) then + -- halt_kern ko_glue glyph -> ko_glue rule halt_kern glyph + local ppn = d_nodeprev(pn) + if d_getid(ppn) == kernnode then + head = d_remove_node(head, ppn) + head = d_insert_before(head, curr, ppn) + head = d_insert_before(head, ppn, d_get_rulenode(0)) + end + end + return head +end + local function compress_fullwidth_punctuations (head) for curr in d_traverse_id(glyphnode,head) do local currfont, currchar = d_getfont(curr), d_getchar(curr) @@ -974,14 +1003,10 @@ local function compress_fullwidth_punctuations (head) end else if halt_on then - -- gluph halt_kern glue -> glyph halt_kern rule glue (kern is a breakpoint if followed by a glue) - local nn = d_nodenext(curr) - if nn and d_getid(nn) == kernnode then - wd = 0 - curr = nn - end + check_next_halt_kern(head, curr) + else + d_insert_after(head, curr, d_get_rulenode(wd)) end - d_insert_after(head, curr, d_get_rulenode(wd)) end elseif class == 1 then local wd @@ -997,22 +1022,10 @@ local function compress_fullwidth_punctuations (head) end else if halt_on then - local pn = d_nodeprev(curr) - if pn and d_getid(pn) == kernnode then - -- glue halt_kern glyph -> glue rule halt_kern glyph - wd = 0 - curr = pn - elseif pn and d_getid(pn) == gluenode and d_getfield(d_getfield(pn,"spec"),"width") == 0 then - -- halt_kern glue glyph -> glue rule halt_kern glyph - local ppn = d_nodeprev(pn) - if ppn and d_getid(ppn) == kernnode then - wd = 0 - head = d_remove_node(head, ppn) - head, curr = d_insert_before(head, curr, ppn) - end - end + head = check_prev_halt_kern(head, curr) + else + head = d_insert_before(head, curr, d_get_rulenode(wd)) end - head = d_insert_before(head, curr, d_get_rulenode(wd)) end elseif class == 3 then local lwd, rwd @@ -1029,8 +1042,11 @@ local function compress_fullwidth_punctuations (head) head = d_insert_before(head, curr, d_get_kernnode(lwd)) end else - if halt_on then lwd = 0 end -- there's already penalty 10000 - head = d_insert_before(head, curr, d_get_rulenode(lwd)) + if halt_on then -- there's already penalty 10000 + head = check_prev_halt_kern(head, curr) + else + head = d_insert_before(head, curr, d_get_rulenode(lwd)) + end end if chr.right_protruding then if not halt_on then @@ -1038,13 +1054,10 @@ local function compress_fullwidth_punctuations (head) end else if halt_on then - local nn = d_nodenext(curr) - if nn and d_getid(nn) == kernnode then - rwd = 0 - curr = nn - end + check_next_halt_kern(head, curr) + else + d_insert_after (head, curr, d_get_rulenode(rwd)) end - d_insert_after (head, curr, d_get_rulenode(rwd)) end end end @@ -1644,6 +1657,7 @@ local function reorderTM (head) if pc == 9 then elseif pc == 7 or pc == 8 then head = d_remove_node(head,curr) + d_setfield(curr, "prev", nil) -- prev might survive! head, curr = d_insert_before(head,p,curr) done = true break @@ -1668,14 +1682,15 @@ end ---------------------------------- -- add to callback : pre-linebreak ---------------------------------- -add_to_callback('hpack_filter', function(head) + +add_to_callback("hpack_filter", function(head) head = d_todirect(head) assign_unicode_codevalue(head) korean_autojosa(head) remove_cj_spaceskip(head) font_substitute(head) return d_tonode(head) -end, 'luatexko.hpack_filter_first',1) +end, 'luatexko.hpack_filter_first', 1) add_to_callback('hpack_filter', function(head) head = d_todirect(head) @@ -1695,7 +1710,7 @@ add_to_callback('pre_linebreak_filter', function(head) remove_cj_spaceskip(head) font_substitute(head) return d_tonode(head) -end, 'luatexko.pre_linebreak_filter_first',1) +end, 'luatexko.pre_linebreak_filter_first', 1) add_to_callback('pre_linebreak_filter', function(head) head = d_todirect(head) |