diff options
author | Karl Berry <karl@freefriends.org> | 2016-04-22 21:24:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-04-22 21:24:14 +0000 |
commit | 600ff15b73f6b7f626f95033638b9b0aeede59e5 (patch) | |
tree | 943c305fe6e5bdfa323993ade53d7a713be91b11 /Master/texmf-dist/tex | |
parent | d5b7f5827c0c4e7c044ee67da597887e83409051 (diff) |
luatexko (22apr16)
git-svn-id: svn://tug.org/texlive/trunk@40688 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
5 files changed, 231 insertions, 250 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty index 9caf53e9c5e..12ba335eee1 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty @@ -1,6 +1,6 @@ % luatexko-core.sty % -% Copyright (c) 2013-2015 Dohyun Kim <nomos at ktug org> +% Copyright (c) 2013-2016 Dohyun Kim <nomos at ktug org> % Soojin Nam <jsunam at gmail com> % % This work may be distributed and/or modified under the @@ -17,21 +17,23 @@ \ifcsname ifpdf\endcsname\else \input ifpdf.sty \fi \catcode`@ = 11 \else - \ProvidesPackage{luatexko-core}[2015/12/10 v1.11 Typesetting Korean with LuaTeX] - \RequirePackage{luaotfload}[2013/05/23] + \ProvidesPackage{luatexko-core}[2016/04/22 v1.12 Typesetting Korean with LuaTeX] + \RequirePackage{luaotfload}[2016/04/21] \RequirePackage{ifpdf} \fi -\ifdefined\luatexfontid\else - \let\luatexfontid\fontid % latex 2015/10/01 +\ifdefined\fontid\else + \let\fontid\luatexfontid % latex 2015/10/01 \fi -\ifdefined\newluatexattribute\else % luaotfload 2.6 - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname RequirePackage\endcsname\relax - \input luatexbase.sty - \else - \RequirePackage{luatexbase} - \fi +\ifdefined\newattribute\else % luaotfload 2.6 + \let\newattribute\newluatexattribute + \let\unsetattribute\unsetluatexattribute + \let\scantextokens\luatexscantextokens + \let\luaescapestring\luatexluaescapestring +\fi +\ifdefined\pdffontsize\else % luatex 0.87 + \def\pdffontsize{\pdffeedback fontsize} + \protected\def\pdfliteral{\pdfextension literal} \fi %% make hangul catcode 12 @@ -49,18 +51,18 @@ \ifnum\count@<"D7A3 \advance\count@\@ne \repeat %% attributes -\newluatexattribute\finemathattr \finemathattr\tw@ % finemath on by default -\newluatexattribute\cjtypesetattr -\newluatexattribute\dotemphattr -\newluatexattribute\autojosaattr -\newluatexattribute\luakorubyattr \chardef\luakorubyattrnum\the\allocationnumber -\newluatexattribute\hangulfntattr -\newluatexattribute\hanjafntattr -\newluatexattribute\fallbackfntattr -\newluatexattribute\hangulpunctsattr +\newattribute\finemathattr \finemathattr\tw@ % finemath on by default +\newattribute\cjtypesetattr +\newattribute\dotemphattr +\newattribute\autojosaattr +\newattribute\luakorubyattr \chardef\luakorubyattrnum\the\allocationnumber +\newattribute\hangulfntattr +\newattribute\hanjafntattr +\newattribute\fallbackfntattr +\newattribute\hangulpunctsattr %% load lua modules -\RequireLuaModule{luatexko} +\directlua{require "luatexko"} %% japanese/chinese/pre-modern \protected\def\japanese{\frenchspacing\cjtypesetattr\@ne \parindent1em } @@ -68,10 +70,10 @@ \protected\def\Tchinese{\frenchspacing\cjtypesetattr\thr@@\parindent2em } \let\chinese\Schinese % korean in japanese/chinese env. -\protected\def\korean{\unsetluatexattribute\cjtypesetattr} +\protected\def\korean{\unsetattribute\cjtypesetattr} % inhibitglue -\protected\def\inhibitglue{{\unsetluatexattribute\cjtypesetattr\hskip\z@skip}} +\protected\def\inhibitglue{{\unsetattribute\cjtypesetattr\hskip\z@skip}} %% auto josa \def\josaignoreparens{\afterassignment\josa@ignore@parens\count@} @@ -233,7 +235,7 @@ \protected\def\horizontal#1{% \setbox\z@\vbox\bgroup \ifnum\cjtypesetattr<\@ne - \unsetluatexattribute\cjtypesetattr + \unsetattribute\cjtypesetattr \spaceskip\fontdimen2\font plus\fontdimen3\font minus\fontdimen4\font @@ -309,7 +311,7 @@ \hangul@font \expandafter\expandafter\expandafter \endgroup - \expandafter\hangulfntattr\luatexfontid\font\relax + \expandafter\hangulfntattr\fontid\font\relax \fi } \def\luatexko@hanja@selectfont{% @@ -321,7 +323,7 @@ \hanja@font \expandafter\expandafter\expandafter \endgroup - \expandafter\hanjafntattr\luatexfontid\font\relax + \expandafter\hanjafntattr\fontid\font\relax \fi } \def\luatexko@fallback@selectfont{% @@ -333,7 +335,7 @@ \fallback@font \expandafter\expandafter\expandafter \endgroup - \expandafter\fallbackfntattr\luatexfontid\font\relax + \expandafter\fallbackfntattr\fontid\font\relax \fi } @@ -368,7 +370,7 @@ \fi %% hangul normalization -\def\luatexhangulnormalize{\RequireLuaModule{luatexko-normalize}% +\def\luatexhangulnormalize{\directlua{require "luatexko-normalize"}% \afterassignment\luatexh@ngulnorm@lize\count@} \def\luatexh@ngulnorm@lize{% \ifcase\count@ % 0: none @@ -380,7 +382,7 @@ \fi} %% uhc to utf8 -\def\luatexuhcinputencoding{\RequireLuaModule{luatexko-uhc2utf8}% +\def\luatexuhcinputencoding{\directlua{require "luatexko-uhc2utf8"}% \afterassignment\luatexuhcinput@ncoding\count@} \def\luatexuhcinput@ncoding{% \ifcase\count@ @@ -390,7 +392,7 @@ \fi} %% uhc file names -\def\luatexuhcfilenames{\RequireLuaModule{luatexko-uhc2utf8}% +\def\luatexuhcfilenames{\directlua{require "luatexko-uhc2utf8"}% \afterassignment\luatexuhcfilen@mes\count@} \def\luatexuhcfilen@mes{% \ifcase\count@ @@ -413,7 +415,7 @@ \def\hangulpunctuations{\afterassignment\h@ngulpunctu@tions\count@} \def\h@ngulpunctu@tions{% \ifcase\count@ - \unsetluatexattribute\hangulpunctsattr + \unsetattribute\hangulpunctsattr \else \hangulpunctsattr\@ne \fi @@ -455,9 +457,9 @@ \def\actualtext@@#1#2{% \endgroup \luatexko@pdfspecial{/Span<</ActualText\directlua{ - luatexko.actualtext("\luatexluaescapestring{\detokenize{#2}}") + luatexko.actualtext("\luaescapestring{\detokenize{#2}}") }>>BDC}% - \luatexscantextokens{#2}% + \scantextokens{#2}% \ifx*#1% \begingroup \ifdefined\actualtext@spacefont\else diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua index f2f7704c02c..6afb6d6738c 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua @@ -1,6 +1,6 @@ -- luatexko-normalize.lua -- --- Copyright (c) 2013-2015 Dohyun Kim <nomos at ktug org> +-- Copyright (c) 2013-2016 Dohyun Kim <nomos at ktug org> -- Soojin Nam <jsunam at gmail com> -- -- This work may be distributed and/or modified under the @@ -13,8 +13,8 @@ luatexbase.provides_module({ name = "luatexko-normalize", - version = "1.11", - date = "2015/12/10", + version = "1.12", + date = "2016/04/22", author = "Dohyun Kim, Soojin Nam", description = "Hangul normalization", license = "LPPL v1.3+", @@ -411,7 +411,6 @@ local concat = table.concat local floor = math.floor local add_to_callback = luatexbase.add_to_callback local remove_from_callback = luatexbase.remove_from_callback -local priority_in_callback = luatexbase.priority_in_callback local jamo2syllable = function(l,v,t) if find(t,ojong) then return end @@ -468,9 +467,12 @@ local hangulcompose = function(buffer) return buffer end +local loaded = false + local function unload() - if priority_in_callback('process_input_buffer', 'luatexko-hangul-normalize') then + if loaded then remove_from_callback('process_input_buffer', 'luatexko-hangul-normalize') + loaded = false end end luatexkonormalize.unload = unload @@ -478,11 +480,13 @@ luatexkonormalize.unload = unload local function compose() unload() add_to_callback('process_input_buffer', hangulcompose, 'luatexko-hangul-normalize') + loaded = true end luatexkonormalize.compose = compose local function decompose() unload() add_to_callback('process_input_buffer', hanguldecompose, 'luatexko-hangul-normalize') + loaded = true end luatexkonormalize.decompose = decompose diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua index aed942c7dc6..bea568bd27a 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua @@ -1,6 +1,6 @@ -- luatexko-uhc2utf8.lua -- --- Copyright (c) 2013-2015 Dohyun Kim <nomos at ktug org> +-- Copyright (c) 2013-2016 Dohyun Kim <nomos at ktug org> -- Soojin Nam <jsunam at gmail com> -- -- This work may be distributed and/or modified under the @@ -13,8 +13,8 @@ luatexbase.provides_module({ name = "luatexko-uhc2utf8", - version = "1.11", - date = "2015/12/10", + version = "1.12", + date = "2016/04/22", author = "Dohyun Kim, Soojin Nam", description = "UHC (CP949) input encoding", license = "LPPL v1.3+", diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua index c2a27f8e70b..fa16225f023 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua @@ -1,6 +1,6 @@ -- luatexko.lua -- --- Copyright (c) 2013-2015 Dohyun Kim <nomos at ktug org> +-- Copyright (c) 2013-2016 Dohyun Kim <nomos at ktug org> -- Soojin Nam <jsunam at gmail com> -- -- This work may be distributed and/or modified under the @@ -13,8 +13,8 @@ luatexbase.provides_module { name = 'luatexko', - date = '2015/12/10', - version = '1.11', + date = '2016/04/22', + version = '1.12', description = 'Korean linebreaking and font-switching', author = 'Dohyun Kim, Soojin Nam', license = 'LPPL v1.3+', @@ -23,8 +23,6 @@ luatexbase.provides_module { 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 @@ -55,10 +53,28 @@ local hangulpunctsattr = luatexbase.attributes.hangulpunctsattr local luakoglueattr = luatexbase.new_attribute("luakoglueattr") local luakounicodeattr = luatexbase.new_attribute("luakounicodeattr") -local add_to_callback = luatexbase.add_to_callback +local function warn (...) + return luatexbase.module_warning("luatexko", stringformat(...)) +end + +local function add_to_callback (name, func, desc, pos) + local t = {{func, desc}} + if pos then + for i,v in ipairs(luatexbase.callback_descriptions(name)) do + if i >= pos then + t[#t+1] = {luatexbase.remove_from_callback(name, v)} + end + end + end + for i,v in ipairs(t) do + luatexbase.add_to_callback(name, v[1], v[2]) + end +end + +local glue_type_space = 13 +local kern_type_itlc = 3 local gluenode = node.id("glue") -local gluespecnode = node.id("glue_spec") local glyphnode = node.id("glyph") local mathnode = node.id("math") local hlistnode = node.id("hlist") @@ -72,15 +88,25 @@ local whatsitspecial = node.subtype("special") local nodedirect = node.direct local d_todirect = nodedirect.todirect local d_tonode = nodedirect.tonode +local d_has_field = nodedirect.has_field +local d_copy_node = nodedirect.copy local d_getid = nodedirect.getid +local d_getfield = nodedirect.getfield +local d_setfield = nodedirect.setfield local d_getsubtype = nodedirect.getsubtype +local d_setsubtype = nodedirect.setsubtype local d_getchar = nodedirect.getchar +local d_setchar = nodedirect.setchar local d_getfont = nodedirect.getfont local d_getlist = nodedirect.getlist -local d_getfield = nodedirect.getfield -local d_setfield = nodedirect.setfield -local d_nodeprev = nodedirect.getprev -local d_nodenext = nodedirect.getnext +local d_setlist = nodedirect.setlist +local d_getnext = nodedirect.getnext +local d_setnext = nodedirect.setnext +local d_getprev = nodedirect.getprev +local d_setprev = nodedirect.setprev +local d_setleader = nodedirect.setleader +local d_getglue = nodedirect.getglue +local d_setglue = nodedirect.setglue local d_has_attribute = nodedirect.has_attribute local d_set_attribute = nodedirect.set_attribute local d_unset_attribute = nodedirect.unset_attribute @@ -88,7 +114,6 @@ local d_traverse = nodedirect.traverse local d_traverse_id = nodedirect.traverse_id local d_insert_before = nodedirect.insert_before local d_insert_after = nodedirect.insert_after -local d_copy_node = nodedirect.copy local d_remove_node = nodedirect.remove local d_nodenew = nodedirect.new local d_nodecount = nodedirect.count @@ -147,9 +172,9 @@ local cjkclass = { [0x00B7] = 3, -- · [0x30FB] = 3, -- ・ [0xFF1A] = 3, -- : - [0xFE13] = 3, -- : vert +-- [0xFE13] = 3, -- : vert [0xFF1B] = 3, -- ; - [0xFE14] = 3, -- ; vert +-- [0xFE14] = 3, -- ; vert [0x3002] = 4, -- 。 [0xFE12] = 4, -- 。 vert [0xFF0E] = 4, -- . @@ -158,8 +183,11 @@ local cjkclass = { [0xFE19] = 5, -- … vert [0x2025] = 5, -- ‥ [0xFE30] = 5, -- ‥ vert + [0xFE31] = 5, -- ︱ vert [0xFF1F] = 6, -- ? [0xFF01] = 6, -- ! + [0xFE16] = 6, -- ︖ vert + [0xFE15] = 6, -- ︕ vert } local inhibitxspcode = { @@ -468,18 +496,9 @@ local josa_code = { -- else 2 } -local function d_get_gluespec (w, st, sh) - local s = d_nodenew(gluespecnode) - d_setfield(s, "width", w or 0) - d_setfield(s, "stretch", st or 0) - d_setfield(s, "shrink", sh or 0) - return s -end - local function d_get_gluenode (...) local g = d_nodenew(gluenode) - local s = d_get_gluespec(...) - d_setfield(g, "spec", s) + d_setglue(g, ...) return g end @@ -613,7 +632,7 @@ local function get_char_boundingbox(fid, chr) end local function d_get_unicode_char(curr) - local uni = d_getchar(curr) + local uni = d_getchar(curr) or 0 if (uni > 0xFF and uni < 0xE000) or (uni > 0xF8FF and uni < 0xF0000) then return uni -- no pua. no nanumgtm end @@ -639,10 +658,9 @@ local function d_get_hlist_char_first (hlist) local c,f = d_get_hlist_char_first(curr) if c then return c,f end elseif currid == gluenode then - local currspec = d_getfield(curr,"spec") - if currspec and d_getfield(currspec,"width") ~= 0 then return end + if d_getglue(curr) ~= 0 then return end end - curr = d_nodenext(curr) + curr = d_getnext(curr) end end @@ -657,10 +675,9 @@ local function d_get_hlist_char_last (hlist,prevchar,prevfont) local c,f = d_get_hlist_char_last(curr) if c then return c,f end elseif currid == gluenode then - local currspec = d_getfield(curr,"spec") - if currspec and d_getfield(currspec,"width") ~= 0 then return end + if d_getglue(curr) ~= 0 then return end end - curr = d_nodeprev(curr) + curr = d_getprev(curr) end return prevchar, prevfont end @@ -722,7 +739,7 @@ local function cjk_insert_nodes(head,curr,currchar,currfont,prevchar,prevfont,wa local c = get_cjk_class(currchar, currentcjtype) ---[[raise latin puncts if d_getid(curr) == glyphnode and (d_has_attribute(curr,finemathattr) or 0) > 0 and c < 10 then -- not ttfamily - local nn, raise = d_nodenext(curr), nil + local nn, raise = d_getnext(curr), nil while nn do local nnid = d_getid(nn) if nnid == glyphnode and latin_fullstop[d_getchar(nn)] then @@ -734,9 +751,9 @@ local function cjk_insert_nodes(head,curr,currchar,currfont,prevchar,prevfont,wa local yoff = d_getfield(nn,"yoffset") or 0 d_setfield(nn,"yoffset", yoff + raise) end - nn = d_nodenext(nn) + nn = d_getnext(nn) elseif nnid == kernnode then - nn = d_nodenext(nn) + nn = d_getnext(nn) else break end @@ -872,7 +889,7 @@ local function cjk_spacing_linebreak (head) end prevchar,prevfont,prevfine = 0,nil,nil -- treat \verb as latin character. end - curr = d_nodenext(curr) + curr = d_getnext(curr) end end @@ -885,9 +902,9 @@ local function remove_cj_spaceskip (head) local currid,currsubtype = d_getid(curr), d_getsubtype(curr) if currid == mathnode and currsubtype == 0 then curr = d_end_of_math(curr) - elseif currid == gluenode then + elseif currid == gluenode and currsubtype == glue_type_space then -- do not touch on xspaceskip for now local cjattr = d_has_attribute(curr,cjtypesetattr) - local prv, nxt = d_nodeprev(curr), d_nodenext(curr) + local prv, nxt = d_getprev(curr), d_getnext(curr) if cjattr and cjattr > 0 and prv and nxt then local prevclass, prevchar, nextclass local prvid, nxtid = d_getid(prv), d_getid(nxt) @@ -896,11 +913,11 @@ local function remove_cj_spaceskip (head) else -- what is this strange kern before \text?? if prvid == kernnode and d_getfield(prv,"kern") == 0 then - prv = d_nodeprev(prv) + prv = d_getprev(prv) end if prvid == glyphnode then prevchar, prevfont = d_getchar(prv), d_getfont(prv) - if is_unicode_vs(prevchar) then prv = d_nodeprev(prv) end -- bypass VS + if is_unicode_vs(prevchar) then prv = d_getprev(prv) end -- bypass VS prevclass = get_cjk_class(d_get_unicode_char(prv), cjattr) end end @@ -910,38 +927,13 @@ local function remove_cj_spaceskip (head) nextclass = get_cjk_class(d_get_hlist_char_first(nxt), cjattr) end if (prevclass and prevclass < 10) or (nextclass and nextclass < 10) then - local subtype = currsubtype - if subtype == 13 then -- do not touch on xspaceskip for now - d_remove_node(head,curr) - d_nodefree(curr) - curr = nxt - elseif subtype == 0 then -- before \text?? spaceskip is replaced by glue type 0 - local spec = d_getfield(curr,"spec") - local csp = spec and d_getfield(spec,"width") - local cst = spec and d_getfield(spec,"stretch") - local csh = spec and d_getfield(spec,"shrink") - local fp = get_font_table(prevfont) - fp = fp and fp.parameters - local sp = fp and fp.space - local st = fp and fp.space_stretch - local sh = fp and fp.space_shrink - sp = sp and tex_round(sp) - st = st and tex_round(st) - sh = sh and tex_round(sh) - if prevchar and prevchar >= 65 and prevchar <= 90 then - st = st and mathfloor(st*(999/1000)) - sh = sh and mathfloor(sh*(1001/1000)) - end - if sp == csp and st == cst and sh == csh then - d_remove_node(head,curr) - d_nodefree(curr) - curr = nxt - end - end + d_remove_node(head,curr) + d_nodefree(curr) + curr = nxt end end end - curr = d_nodenext(curr) + curr = d_getnext(curr) end end @@ -950,20 +942,20 @@ end ---------------------------------- 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 + local nn = d_getnext(curr) + if nn and d_getid(nn) == kernnode and d_getnext(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 + local pn = d_getprev(curr) + if pn and d_getid(pn) == kernnode and d_getprev(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) + local ppn = d_getprev(pn) if d_getid(ppn) == kernnode then head = d_remove_node(head, ppn) head = d_insert_before(head, curr, ppn) @@ -1071,16 +1063,13 @@ end local function spread_ruby_box(head,extrawidth) local to_free = {} for curr in d_traverse_id(gluenode,head) do - local currspec = d_getfield(curr,"spec") - if currspec then - local wd = d_getfield(currspec,"width") or 0 - if d_has_attribute(curr,luakoglueattr) then - d_setfield(currspec,"width", wd + extrawidth) - else - head = d_insert_before(head,curr,d_get_kernnode(wd+extrawidth)) - head = d_remove_node(head,curr) - to_free[#to_free + 1] = curr - end + local wd = d_getglue(curr) or 0 + if d_has_attribute(curr,luakoglueattr) then + d_setglue(curr, wd + extrawidth) + else + head = d_insert_before(head,curr,d_get_kernnode(wd+extrawidth)) + head = d_remove_node(head,curr) + to_free[#to_free + 1] = curr end end if #to_free > 0 then @@ -1105,8 +1094,8 @@ local function spread_ruby_base_box (head) end local leading = d_get_kernnode(extrawidth/2) d_setfield(curr,"width", rubywidth) - d_setfield(leading,"next", basehead) - d_setfield(curr,"head", leading) + d_setnext(leading, basehead) + d_setlist(curr, leading) end end end @@ -1118,7 +1107,7 @@ local function get_ruby_side_width (basewidth,rubywidth,adjacent) if d_getid(adjacent) == glyphnode then local uni = d_get_unicode_char(adjacent) if is_unicode_vs(uni) then -- bypass VS - uni = d_get_unicode_char(d_nodeprev(adjacent)) + uni = d_get_unicode_char(d_getprev(adjacent)) end if not is_hanja(uni) then width = (rubywidth-basewidth-emsize)/2 @@ -1145,7 +1134,7 @@ local function get_ruby_side_kern (head) if currwidth < rubywidth then local _,fid = d_get_hlist_char_first(curr) emsize = get_font_emsize(fid) - local leftwidth,leftmargin = get_ruby_side_width(basewidth,rubywidth,d_nodeprev(curr)) + local leftwidth,leftmargin = get_ruby_side_width(basewidth,rubywidth,d_getprev(curr)) if leftwidth > 0 then currwidth = currwidth + leftwidth d_setfield(curr,"width", currwidth) @@ -1153,7 +1142,7 @@ local function get_ruby_side_kern (head) if leftmargin > 0 then rubynode[attr].leftmargin = leftmargin end - local rightwidth,rightmargin = get_ruby_side_width(basewidth,rubywidth,d_nodenext(curr)) + local rightwidth,rightmargin = get_ruby_side_width(basewidth,rubywidth,d_getnext(curr)) if rightwidth > 0 then currwidth = currwidth + rightwidth d_setfield(curr,"width", currwidth) @@ -1171,8 +1160,8 @@ local function get_ruby_side_kern (head) currhead = spread_ruby_box(currhead,extrawidth) end local leading = d_get_kernnode(extrawidth*(leftwidth/totalspace)) - d_setfield(leading,"next", currhead) - d_setfield(curr,"head", leading) + d_setnext(leading, currhead) + d_setlist(curr, leading) end end end @@ -1202,7 +1191,7 @@ local function no_ruby_at_margin(head) end margin = rubynode[attr].rightmargin if margin then - local nn = d_nodenext(curr) + local nn = d_getnext(curr) if nn then local nnid = d_getid(nn) if nnid == gluenode then @@ -1229,12 +1218,12 @@ local function inject_char_widow_penalty (head,curr,uni,cjattr) local class = get_cjk_class(uni, cjattr) if class and class < 9 then local pv = cjattr and 500 or 5000 - local np = d_nodeprev(curr) + local np = d_getprev(curr) if np and d_getid(np) == rulenode then - curr = np; np = d_nodeprev(curr) + curr = np; np = d_getprev(curr) end if np and d_getid(np) == gluenode then - curr = np; np = d_nodeprev(curr) + curr = np; np = d_getprev(curr) end if np and d_getid(np) == penaltynode then curr = np @@ -1269,7 +1258,7 @@ local function discourage_char_widow (head,curr) local cjattr = d_has_attribute(curr,cjtypesetattr) curr = inject_char_widow_penalty(head,curr,uni,cjattr) end - curr = d_nodeprev(curr) + curr = d_getprev(curr) end end @@ -1435,7 +1424,7 @@ local function get_josaprevs(curr,josaprev,ignoreparens,halt) josaprev = get_josaprevs(d_nodetail(d_getlist(curr)),josaprev,ignoreparens,halt) end if #josaprev == 3 then break end - curr = d_nodeprev(curr) + curr = d_getprev(curr) end return josaprev end @@ -1447,18 +1436,21 @@ local function korean_autojosa (head) if josaattr and d_has_attribute(curr,finemathattr) then local ignoreparens = josaattr > 1 and true or false local josaprev = {} - josaprev = get_josaprevs(d_nodeprev(curr),josaprev,ignoreparens) + josaprev = get_josaprevs(d_getprev(curr),josaprev,ignoreparens) local josacode = get_josacode(josaprev) local thischar = d_get_unicode_char(curr) if thischar == 0xC774 then - local nn = d_nodenext(curr) - if nn and d_getid(nn) == glyphnode and d_get_unicode_char(nn) == 0xB77C then - d_setfield(curr,"char", josa_list[0xC774][josacode]) + local nn, nc = d_getnext(curr) + if nn and d_getid(nn) == glyphnode then + nc = d_get_unicode_char(nn) + end + if nc and nc >= 0xAC00 and nc <= 0xD7A3 then + d_setchar(curr, josa_list[0xC774][josacode]) else - d_setfield(curr,"char", josa_list[0xAC00][josacode]) + d_setchar(curr, josa_list[0xAC00][josacode]) end elseif thischar and josa_list[thischar] then - d_setfield(curr,"char", josa_list[thischar][josacode]) + d_setchar(curr, josa_list[thischar][josacode]) end end if d_getchar(curr) < 0 then @@ -1474,24 +1466,19 @@ end ------------------------------ -- switch to hangul/hanja font ------------------------------ -local function hangulspaceskip (engfont, hfontid, spec) +local function hangulspaceskip (engfont, hfontid, glue) local eng = engfont.parameters if not eng then return end - if not spec then return end - if d_getfield(spec,"stretch_order") ~= 0 or d_getfield(spec,"shrink_order") ~= 0 then return end - local gsp, gst, gsh = d_getfield(spec,"width"), d_getfield(spec,"stretch"), d_getfield(spec,"shrink") + local gsp, gst, gsh, gsto, gsho = d_getglue(glue) + if gsto ~= 0 or gsho ~= 0 then return end local esp, est, esh = eng.space, eng.space_stretch, eng.space_shrink esp = esp and tex_round(esp) est = est and tex_round(est) esh = esh and tex_round(esh) if esp == gsp and est == gst and esh == gsh then else return end local hf = get_font_table(hfontid) - if not hf then return end - local hp = hf.parameters - if not hp then return end - local hsp,hst,hsh = hp.space,hp.space_stretch,hp.space_shrink - if hsp and hst and hsh then else return end - return tex_round(hsp), tex_round(hst), tex_round(hsh) + if hf and hf.encodingbytes == 2 then else return end + return gsp, hf end local type1fonts = {} -- due to too verbose log @@ -1500,7 +1487,10 @@ local function nanumtype1font(curr) if currchar > 0xFFFF then return end local fnt_t = get_font_table(currfont) local family = (d_has_attribute(curr,finemathattr) or 0) > 1 and not is_hanja(currchar) and "nanummj" or "nanumgt" - local series = fnt_t.shared and fnt_t.shared.rawdata.metadata.pfminfo.weight + local series = fnt_t.shared and + fnt_t.shared.rawdata and + fnt_t.shared.rawdata.metadata and + fnt_t.shared.rawdata.metadata.pfmweight if series then series = series > 500 and "b" or "m" else @@ -1515,8 +1505,8 @@ local function nanumtype1font(curr) local newchr = currchar % 256 local function ital_corr (curr,chr_t) if shape ~= "o" then return end - local nxt = d_nodenext(curr) - if nxt and d_getid(nxt) == kernnode and d_getsubtype(nxt) == 1 and d_getfield(nxt,"kern") == 0 then + local nxt = d_getnext(curr) + if nxt and d_getid(nxt) == kernnode and d_getsubtype(nxt) == kern_type_itlc and d_getfield(nxt,"kern") == 0 then d_setfield(nxt,"kern", chr_t.italic or 0) end end @@ -1524,7 +1514,7 @@ local function nanumtype1font(curr) local fntchr = get_font_char(newfnt,newchr) if fntchr then d_setfield(curr,"font", newfnt) - d_setfield(curr,"char", newchr) + d_setchar(curr, newchr) ital_corr(curr,fntchr) end elseif kpse_find_file(subfnt,"tfm") then @@ -1533,7 +1523,7 @@ local function nanumtype1font(curr) if id and fntchr then type1fonts[fspec] = id d_setfield(curr,"font", id) - d_setfield(curr,"char", newchr) + d_setchar(curr, newchr) ital_corr(curr,fntchr) end else @@ -1551,7 +1541,7 @@ local function font_substitute(head) local currchar, currfont = d_getchar(curr), d_getfont(curr) if currchar then if is_unicode_vs(currchar) then -- ideograph variation selectors - local prev = d_nodeprev(curr) + local prev = d_getprev(curr) local prevfont = d_getid(prev) == glyphnode and d_getfont(prev) if prevfont ~= currfont then d_setfield(curr, "font", prevfont) -- sync font @@ -1589,27 +1579,33 @@ local function font_substitute(head) d_setfield(curr,"yoffset", charraise + curryoffset) end --- - local nxt = d_nodenext(curr) + local nxt = d_getnext(curr) local nxtid = nxt and d_getid(nxt) if nxtid == glyphnode and is_unicode_vs(d_getchar(nxt)) then - nxt = d_nodenext(nxt) + nxt = d_getnext(nxt) nxtid = nxt and d_getid(nxt) end if eng and nxtid then local nxtsubtype = d_getsubtype(nxt) -- adjust next glue by hangul font space - if nxtid == gluenode and nxtsubtype and nxtsubtype == 0 then - local nxtspec = d_getfield(nxt,"spec") - if nxtspec and d_getfield(nxtspec,"writable") and get_font_char(fid,32) then - local sp,st,sh = hangulspaceskip(eng, fid, nxtspec) - if sp and st and sh then - local s = d_get_gluespec(sp, st, sh) - d_setfield(nxt, "spec", s) - d_nodefree(nxtspec) + if nxtid == gluenode and nxtsubtype == glue_type_space and get_font_char(fid,32) then + local oldwd, ft = hangulspaceskip(eng, fid, nxt) + if oldwd and ft then + local newwd = ft.space_char_width + if not newwd then + local newsp = d_tonode(d_copy_node(curr)) + newsp.char = 32 + newsp = nodes.simple_font_handler(newsp) + newwd = newsp and newsp.width + ft.space_char_width = newwd + node.free(newsp) + end + if newwd and oldwd ~= newwd then + d_setglue(nxt, newwd, newwd/2, newwd/3) end end -- adjust next italic correction kern - elseif nxtid == kernnode and nxtsubtype == 1 and d_getfield(nxt,"kern") == 0 then + elseif nxtid == kernnode and nxtsubtype == kern_type_itlc and d_getfield(nxt,"kern") == 0 then local ksl = get_font_table(fid).parameters.slant if ksl and ksl > 0 then d_setfield(nxt,"kern", myfontchar.italic or 0) @@ -1626,7 +1622,7 @@ local function font_substitute(head) end end end - curr = d_nodenext(curr) + curr = d_getnext(curr) end end @@ -1651,30 +1647,30 @@ local function reorderTM (head) local done = false local unichar = get_font_char(d_getfont(curr), uni) if unichar and unichar.width > 0 then - local p = d_nodeprev(curr) + local p = d_getprev(curr) while p and d_getid(p) == glyphnode do local pc = get_cjk_class(d_get_unicode_char(p)) 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! + d_setprev(curr, nil) -- prev might survive! head, curr = d_insert_before(head,p,curr) done = true break else break end - p = d_nodeprev(p) + p = d_getprev(p) end end if not done and get_font_char(d_getfont(curr), 0x25CC) then local u_25CC = d_copy_node(curr) - d_setfield(u_25CC, "char", 0x25CC) + d_setchar(u_25CC, 0x25CC) d_insert_after(head, curr, u_25CC) end end end - curr = d_nodeprev(curr) + curr = d_getprev(curr) end return head end @@ -1734,7 +1730,7 @@ local function after_linebreak_dotemph (head, to_free) for curr in d_traverse(head) do local currid = d_getid(curr) if currid == hlistnode then -- hlist may be nested!!! - d_setfield(curr,"head", after_linebreak_dotemph(d_getlist(curr), to_free)) + d_setlist(curr, after_linebreak_dotemph(d_getlist(curr), to_free)) elseif currid == glyphnode then local attr = d_has_attribute(curr,dotemphattr) if attr and attr > 0 then @@ -1742,7 +1738,7 @@ local function after_linebreak_dotemph (head, to_free) if cc and (cc == 0 or cc == 7 or cc == 8) then local basewd = d_getfield(curr,"width") or 0 if cc == 8 then -- check next char for old hangul jung/jongseong - local nn = d_nodenext(curr) + local nn = d_getnext(curr) while nn do if d_getid(nn) ~= glyphnode then break end local uni = d_get_unicode_char(nn) @@ -1752,15 +1748,15 @@ local function after_linebreak_dotemph (head, to_free) else break end - nn = d_nodenext(nn) + nn = d_getnext(nn) end end local dbox = d_todirect(dotemphnode[attr]) local d = d_copy_node(dbox) local dwidth = d_getfield(d,"width") local dot = d_get_kernnode(basewd/2-dwidth/2) - d_setfield(dot,"next", d_getlist(d)) - d_setfield(d,"head", dot) + d_setnext(dot, d_getlist(d)) + d_setlist(d, dot) d_setfield(d,"width", 0) head = d_insert_before(head,curr,d) to_free[dbox] = true @@ -1793,7 +1789,7 @@ local function after_linebreak_ruby (head) local extrawidth = (currwidth - rubywidth)/(numofglues + 1) d_setfield(ruby,"width", currwidth - extrawidth/2) if numofglues > 0 then - d_setfield(ruby,"head", spread_ruby_box(rubyhead,extrawidth)) + d_setlist(ruby, spread_ruby_box(rubyhead,extrawidth)) end else local right = rubynode[attr].rightshift or 0 @@ -1815,8 +1811,8 @@ end local function draw_underline(head,curr,width,ubox,ulstart) if width and width > 0 then local glue = d_get_gluenode(width) - d_setfield(glue,"subtype", 101) -- cleaders - d_setfield(glue,"leader", d_copy_node(ubox)) + d_setsubtype(glue, 101) -- cleaders + d_setleader(glue, d_copy_node(ubox)) head = d_insert_before(head, ulstart, glue) head = d_insert_before(head, ulstart, d_get_kernnode(-width)) end @@ -1833,13 +1829,13 @@ local function draw_underline(head,curr,width,ubox,ulstart) end local function after_linebreak_underline(head,glueorder,glueset,gluesign,ulinenum) - local ulstart = ulinenum and head or false + local ulstart = ulinenum and head if ulstart and d_getid(ulstart) == gluenode then - ulstart = d_nodenext(ulstart) + ulstart = d_getnext(ulstart) end for curr in d_traverse(head) do local currid = d_getid(curr) - if currid == hlistnode then + if currid == hlistnode and not ulstart then -- skip nested hbox local newhead newhead,ulinenum = after_linebreak_underline( d_getlist(curr), @@ -1847,20 +1843,20 @@ local function after_linebreak_underline(head,glueorder,glueset,gluesign,ulinenu d_getfield(curr,"glue_set"), d_getfield(curr,"glue_sign"), ulinenum) - d_setfield(curr,"head", newhead) + d_setlist(curr, newhead) elseif currid == whatsitnode and d_getsubtype(curr) == whatsitspecial then local currdata = d_getfield(curr,"data") if currdata then if currdata:find("luako:ulinebegin=") then ulinenum = tonumber(currdata:match("(%d+)")) - ulstart = curr + ulinenum = ulinebox[ulinenum] and ulinenum + ulstart = ulinenum and curr elseif ulstart and ulinenum and currdata:find('luako:ulineend') then local ubox = d_todirect(ulinebox[ulinenum]) local wd = d_nodedimensions(glueset,gluesign,glueorder,ulstart,curr) head = draw_underline(head,curr,wd,ubox,ulstart) d_nodefree(ubox) - ulinebox[ulinenum] = nil - ulinenum = nil + ulinebox[ulinenum], ulinenum, ulstart = nil, nil, nil end end end @@ -1917,12 +1913,7 @@ local function get_vwidth_tsb_table (filename,fontname) for _,subfont in ipairs(subfonts) do local glyphs = subfont.glyphs or {} for i, gl in pairs(glyphs) do - local id = gl.orig_pos or i - local name = gl.name - if name then - glyph_t[id] = { ht = gl.vwidth, tsb = gl.tsidebearing, vk = gl.vkerns } - glyph_t[name] = id - end + glyph_t[i] = { ht = gl.vwidth, tsb = gl.tsidebearing } end end if lfstouch then @@ -1957,7 +1948,6 @@ local function cjk_vertical_font (vf) local xheight = params.x_height or quad/2 local goffset = xheight/2 - quad/2 local descriptions = shared.rawdata and shared.rawdata.descriptions - local vkrn_tab, id2uni_tab = {}, {} for i,v in pairs(vf.characters) do local dsc = descriptions[i] local gl = v.index @@ -1982,21 +1972,6 @@ local function cjk_vertical_font (vf) v.height = vh v.depth = vh v.italic = nil - -- for vkrn - local t = id2uni_tab[gl] or {} - t[#t + 1] = i - id2uni_tab[gl] = t - local vk = tsb_gl.vk - if vk then - for _,vv in ipairs(vk) do - local index, off = vv.char, vv.off - index = index and tsbtable and tsbtable[index] - if index and off then - vkrn_tab[i] = vkrn_tab[i] or {} - vkrn_tab[i][index] = off - end - end - end end --- vertical gpos local res = vf.resources or {} @@ -2006,41 +1981,33 @@ local function cjk_vertical_font (vf) local fea = shared.features or {} fea.kern = nil -- only for horizontal typesetting fea.vert = true -- should be activated by default - local vposkeys = {} local seq = res.sequences or {} for _,v in ipairs(seq) do - if (v.type == "gpos_single" or v.type == "gpos_pair") and v.subtables then - local feature = v.features or {} - if feature.vhal or feature.vkrn or feature.valt or feature.vpal or feature.vert then - for _,vv in ipairs(v.subtables) do - vposkeys[#vposkeys+1] = vv - end - end - end - end - local lookups = res.lookuphash or {} - for _,v in ipairs(vposkeys) do - local vp = lookups[v] - if vp then - for i,vv in pairs(vp) do - if #vv == 4 then - vp[i] = { -vv[2], vv[1], vv[4], vv[3] } + local fea = v.features or {} + if fea.vhal or fea.vkrn or fea.valt or fea.vpal or fea.vert then + if v.type == "gpos_single" then + for _,vv in pairs(v.steps or{}) do + local cover = vv.coverage or {} + for iii,vvv in pairs(cover) do + if type(vvv) == "table" and #vvv == 4 then + cover[iii] = { -vvv[2], vvv[1], vvv[4], vvv[3], 0 } + end + end end - end - else -- vkrn - local t = {} - for first,idofftab in pairs(vkrn_tab) do - for id,off in pairs(idofftab) do - local unis = id2uni_tab[id] - if unis then - for _,second in ipairs(unis) do - t[first] = t[first] or {} - t[first][second] = off + elseif v.type == "gpos_pair" then + for _,vv in pairs(v.steps or {}) do + for _,vvv in pairs(vv.coverage or {}) do + for _,vvvv in pairs(vvv) do + for iiiii,vvvvv in pairs(vvvv) do + if type(vvvvv) == "table" and #vvvvv == 4 then + -- last 0 to avoid multiple round + vvvv[iiiii] = { -vvvvv[2], vvvvv[1], vvvvv[4], vvvvv[3], 0 } + end + end end end end end - lookups[v] = t end end res.verticalgposhack = true @@ -2095,14 +2062,17 @@ otffeatures.register { -- italic correction for fake-slant font ------------------------------------ local function fakeslant_itlc (tfmdata) + --[[ should be removed + if tfmdata.format == "unknown" then + tfmdata.name = tfmdata.name:gsub("^\"(.-)\"$","%1") + end + --]] local slfactor = tfmdata.parameters.slantfactor if slfactor and slfactor > 0 then else return end tfmdata.parameters.slant = slfactor * 65536 - local factor = tfmdata.parameters.factor or 655.36 - local itlcoff = (tfmdata.shared.rawdata.metadata.uwidth or 40)/2 * factor local chrs = tfmdata.characters for i,v in pairs(chrs) do - local italic = v.height * slfactor - itlcoff + local italic = v.height * slfactor if italic > 0 then chrs[i].italic = italic end diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty index d62e0d8ec75..4957ad3a99a 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty @@ -1,6 +1,6 @@ % luatexko.sty % -% Copyright (c) 2013-2015 Dohyun Kim <nomos at ktug org> +% Copyright (c) 2013-2016 Dohyun Kim <nomos at ktug org> % Soojin Nam <jsunam at gmail com> % % This work may be distributed and/or modified under the @@ -23,7 +23,12 @@ \expandafter\endinput \fi -\ProvidesPackage{luatexko}[2015/12/10 v1.11 Typesetting Korean with LuaLaTeX] +\ProvidesPackage{luatexko}[2016/04/22 v1.12 Typesetting Korean with LuaLaTeX] + +\ifdefined\adjustspacing\else % luatex < 0.87 + \let\adjustspacing\pdfadjustspacing + \let\protrudechars\pdfprotrudechars +\fi %% package options \newif\if@hangul @@ -68,9 +73,9 @@ } } \newhangulfontfeature{Protrusion}{protrusion}{default} - {\aftergroup\pdfprotrudechars\aftergroup\tw@} + {\aftergroup\protrudechars\aftergroup\tw@} \newhangulfontfeature{Expansion}{expansion}{default} - {\aftergroup\pdfadjustspacing\aftergroup\tw@} + {\aftergroup\adjustspacing\aftergroup\tw@} %% default font features \cs_set_eq:NN \defaulthangulfontfeatures \defaultfontfeatures \cs_set_eq:NN \defaulthanjafontfeatures \defaultfontfeatures @@ -389,7 +394,7 @@ \protected\edef\ttfamily{% \unexpanded{\luatexko@mono@fonts}\unexpanded\expandafter{\ttfamily}} \edef\verbatim@font{\unexpanded\expandafter{\verbatim@font - \unsetluatexattribute\finemathattr}} + \unsetattribute\finemathattr}} \AtBeginDocument{ \unless\ifdefined\serifhangul@font\let\serifhangul@font\sanshangul@font\fi |