diff options
author | Norbert Preining <norbert@preining.info> | 2020-03-21 03:01:37 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-03-21 03:01:37 +0000 |
commit | 3e43bc594a14e8c4fc21d6a71f22a23dd78fe252 (patch) | |
tree | 19d1a8bb88da795b5317f91775f645e0b7bd9eb9 /macros/luatex/generic/luatexko | |
parent | c720a4409b388fa706f3eb1ce275f76f7d49d996 (diff) |
CTAN sync 202003210301
Diffstat (limited to 'macros/luatex/generic/luatexko')
-rw-r--r-- | macros/luatex/generic/luatexko/ChangeLog | 7 | ||||
-rw-r--r-- | macros/luatex/generic/luatexko/README | 2 | ||||
-rw-r--r-- | macros/luatex/generic/luatexko/luatexko-doc.pdf | bin | 324950 -> 325270 bytes | |||
-rw-r--r-- | macros/luatex/generic/luatexko/luatexko-doc.tex | 2 | ||||
-rw-r--r-- | macros/luatex/generic/luatexko/luatexko-normalize.lua | 4 | ||||
-rw-r--r-- | macros/luatex/generic/luatexko/luatexko-uhc2utf8.lua | 4 | ||||
-rw-r--r-- | macros/luatex/generic/luatexko/luatexko.lua | 236 | ||||
-rw-r--r-- | macros/luatex/generic/luatexko/luatexko.sty | 59 |
8 files changed, 180 insertions, 134 deletions
diff --git a/macros/luatex/generic/luatexko/ChangeLog b/macros/luatex/generic/luatexko/ChangeLog index 5ffa9cd5f2..2eb3dae8d6 100644 --- a/macros/luatex/generic/luatexko/ChangeLog +++ b/macros/luatex/generic/luatexko/ChangeLog @@ -1,3 +1,10 @@ +2020-03-20 Dohyun Kim <nomos at ktug org> + + Version 2.8 + + * luatexko.lua, luatexko.sty: + use atbegshi package for dotemph, uline, and ruby + 2020-03-14 Dohyun Kim <nomos at ktug org> Version 2.7 diff --git a/macros/luatex/generic/luatexko/README b/macros/luatex/generic/luatexko/README index 494b40edf9..1baf7bda2e 100644 --- a/macros/luatex/generic/luatexko/README +++ b/macros/luatex/generic/luatexko/README @@ -1,4 +1,4 @@ -LuaTeX-ko Package version 2.7 (2020/03/14) +LuaTeX-ko Package version 2.8 (2020/03/20) =========================================== This is a Lua(La)TeX macro package that supports typesetting Korean diff --git a/macros/luatex/generic/luatexko/luatexko-doc.pdf b/macros/luatex/generic/luatexko/luatexko-doc.pdf Binary files differindex b37128dcbb..aaee5aa145 100644 --- a/macros/luatex/generic/luatexko/luatexko-doc.pdf +++ b/macros/luatex/generic/luatexko/luatexko-doc.pdf diff --git a/macros/luatex/generic/luatexko/luatexko-doc.tex b/macros/luatex/generic/luatexko/luatexko-doc.tex index 7d57dee230..97bb5640a2 100644 --- a/macros/luatex/generic/luatexko/luatexko-doc.tex +++ b/macros/luatex/generic/luatexko/luatexko-doc.tex @@ -120,7 +120,7 @@ \author{Dohyun Kim \normalsize |<nomos at ktug org>| \and Soojin Nam \normalsize |<jsunam at gmail com>| \and \normalsize <\url{http://github.com/dohyunkim/luatexko}>} -\date{Version 2.7\quad 2020/03/14} +\date{Version 2.8\quad 2020/03/20} \maketitle \begin{quote}\small diff --git a/macros/luatex/generic/luatexko/luatexko-normalize.lua b/macros/luatex/generic/luatexko/luatexko-normalize.lua index 0b4553f18f..243762aa2f 100644 --- a/macros/luatex/generic/luatexko/luatexko-normalize.lua +++ b/macros/luatex/generic/luatexko/luatexko-normalize.lua @@ -13,8 +13,8 @@ luatexbase.provides_module({ name = "luatexko-normalize", - version = "2.7", - date = "2020/03/14", + version = "2.8", + date = "2020/03/20", author = "Dohyun Kim, Soojin Nam", description = "Hangul normalization", license = "LPPL v1.3+", diff --git a/macros/luatex/generic/luatexko/luatexko-uhc2utf8.lua b/macros/luatex/generic/luatexko/luatexko-uhc2utf8.lua index 70b30b96e3..10ef613a94 100644 --- a/macros/luatex/generic/luatexko/luatexko-uhc2utf8.lua +++ b/macros/luatex/generic/luatexko/luatexko-uhc2utf8.lua @@ -13,8 +13,8 @@ luatexbase.provides_module({ name = "luatexko-uhc2utf8", - version = "2.7", - date = "2020/03/14", + version = "2.8", + date = "2020/03/20", author = "Dohyun Kim, Soojin Nam", description = "UHC (CP949) input encoding", license = "LPPL v1.3+", diff --git a/macros/luatex/generic/luatexko/luatexko.lua b/macros/luatex/generic/luatexko/luatexko.lua index 0720a4ecd9..95d8fc1a84 100644 --- a/macros/luatex/generic/luatexko/luatexko.lua +++ b/macros/luatex/generic/luatexko/luatexko.lua @@ -13,8 +13,8 @@ luatexbase.provides_module { name = 'luatexko', - date = '2020/03/14', - version = '2.7', + date = '2020/03/20', + version = '2.8', description = 'typesetting Korean with LuaTeX', author = 'Dohyun Kim, Soojin Nam', license = 'LPPL v1.3+', @@ -73,7 +73,6 @@ local callback_descriptions = luatexbase.callback_descriptions local create_callback = luatexbase.create_callback local module_warning = luatexbase.module_warning local new_user_whatsit = luatexbase.new_user_whatsit -local new_user_whatsit_id = luatexbase.new_user_whatsit_id local registernumber = luatexbase.registernumber local remove_from_callback = luatexbase.remove_from_callback @@ -93,7 +92,6 @@ local ruleid = node.id"rule" local vlistid = node.id"vlist" local whatsitid = node.id"whatsit" local literal_whatsit = node.subtype"pdf_literal" -local user_whatsit = node.subtype"user_defined" local directmode = 2 local fontkern = 0 local userkern = 1 @@ -110,6 +108,7 @@ local fallbackfontattr = attributes.luatexkofallbackfontattr local autojosaattr = attributes.luatexkoautojosaattr local classicattr = attributes.luatexkoclassicattr local dotemphattr = attributes.luatexkodotemphattr +local ulineattr = attributes.luatexkoulineattr local rubyattr = attributes.luatexkorubyattr local hangulbyhangulattr = attributes.luatexkohangulbyhangulattr local hanjabyhanjaattr = attributes.luatexkohanjabyhanjaattr @@ -465,13 +464,12 @@ luatexko.forcehangulchars = force_hangul local forcehf_f, forcehf_id = new_user_whatsit("forcehf","luatexko") -local function update_force_hangul (value) +function luatexko.updateforcehangul (value) local what = forcehf_f() what.type = lua_value -- function what.value = value nodewrite(what) end -luatexko.updateforcehangul = update_force_hangul local function hangul_space_skip (curr, newfont) if curr.lang ~= nohyphen and curr.font ~= newfont then @@ -517,7 +515,6 @@ local function process_fonts (head) is_not_harf(curr.font) and option_in_font(curr.font, "script") == "hang" then luatexko.activate("reorderTM") -- activate reorderTM here - active_processes.reorderTM = true end else @@ -556,10 +553,9 @@ local function process_fonts (head) curr.replace = process_fonts(curr.replace) elseif id == mathid then curr = end_of_math(curr) - elseif id == whatsitid - and curr.subtype == user_whatsit - and curr.user_id == forcehf_id - and curr.type == lua_value then + elseif id == whatsitid and + curr.user_id == forcehf_id and + curr.type == lua_value then local value = curr.value if type(value) == "function" then @@ -901,9 +897,7 @@ local function process_interhangul (head, par) if c and not is_unicode_var_sel(c) then head, pc = do_interhangul_option(head, curr, pc, c, curr.font, par) - if is_chosong(c) then - pc = 0 - elseif is_jungsong(c) or is_jongsong(c) or hangul_tonemark[c] then + if is_jungsong(c) or is_jongsong(c) or hangul_tonemark[c] then pc = 1 end end @@ -1210,11 +1204,22 @@ end local dotemphbox = {} luatexko.dotemphbox = dotemphbox -local function process_dotemph (head, tofree) - local curr, outer, tofree = head, not tofree, tofree or {} +local dotemph_f, dotemph_id = new_user_whatsit("dotemph","luatexko") + +function luatexko.dotemphboundary (i) + local what = dotemph_f() + what.type = lua_number + what.value = i + nodewrite(what) +end + +local function process_dotemph (head) + local curr = head while curr do - local id = curr.id - if id == glyphid then + if curr.list then + curr.list = process_dotemph(curr.list) + + elseif curr.id == glyphid then local dotattr = has_attribute(curr, dotemphattr) if dotattr then local c = my_node_props(curr).unicode or curr.char @@ -1231,7 +1236,13 @@ local function process_dotemph (head, tofree) local currwd = curr.width if currwd >= font_options.en_size[curr.font] then - local box = nodecopy(dotemphbox[dotattr]) + local box = nodecopy(dotemphbox[dotattr]).list + -- bypass unwanted nodes injected by some other packages + while box.id ~= hlistid do + warning[[\dotemph should be an hbox]] + box = getnext(box) + end + local shift = (currwd - box.width)/2 if shift ~= 0 then local list = box.list @@ -1245,28 +1256,26 @@ local function process_dotemph (head, tofree) box.width = 0 head = insert_before(head, curr, box) - tofree[dotattr] = true end end - unset_attribute(curr, dotemphattr) - end - elseif id == hlistid then - local list = curr.list - if list then - curr.list, tofree = process_dotemph(list, tofree) end + + elseif curr.id == whatsitid and + curr.user_id == dotemph_id and + curr.type == lua_number then + + local val = curr.value + nodefree(dotemphbox[val]) + dotemphbox[val] = nil end curr = getnext(curr) end - if outer then - for k in pairs(tofree) do nodefree(dotemphbox[k]) end - end - return head, tofree + return head end -- uline -local function get_strike_out_down (box) +function luatexko.get_strike_out_down (box) local c, f = hbox_char_font(box, true, true) -- ignore blocking nodes if c and f then local down @@ -1286,14 +1295,16 @@ local function get_strike_out_down (box) end return -texsp"0.5ex" end -luatexko.get_strike_out_down = get_strike_out_down local uline_f, uline_id = new_user_whatsit("uline","luatexko") -local no_uline_id = new_user_whatsit_id("no_uline","luatexko") -local function ulboundary (i, n, subtype) +function luatexko.ulboundary (i, n, subtype) local what = uline_f() if n then + while n.id ~= ruleid and n.id ~= hlistid and n.id ~= vlistid do + warning[[\markoverwith should be a rule or a box]] + n = getnext(n) + end what.type = lua_value -- table what.value = { i, nodecopy(n), subtype } else @@ -1302,7 +1313,6 @@ local function ulboundary (i, n, subtype) end nodewrite(what) end -luatexko.ulboundary = ulboundary local white_nodes = { [glueid] = true, @@ -1311,7 +1321,7 @@ local white_nodes = { [whatsitid] = true, } -function skip_white_nodes (n, ltr) +local function skip_white_nodes (n, ltr) local nextnode = ltr and getnext or getprev while n do if not white_nodes[n.id] then break end @@ -1323,66 +1333,78 @@ end local function draw_uline (head, curr, parent, t, final) local start, list, subtype = t.start or head, t.list, t.subtype start = skip_white_nodes(start, true) - if final then + if final and start then nodeslide(start) -- to get correct getprev. end curr = skip_white_nodes(curr) - curr = getnext(curr) or curr - local len = parent and rangedimensions(parent, start, curr) - or dimensions(start, curr) -- it works?! - if len and len ~= 0 then - local g = nodenew(glueid) - setglue(g, len) - g.subtype = subtype - g.leader = final and list or nodecopy(list) - local k = nodenew(kernid) - k.kern = -len - head = insert_before(head, start, g) - head = insert_before(head, start, k) + if start and curr then + curr = getnext(curr) or curr + local len = parent and rangedimensions(parent, start, curr) + or dimensions(start, curr) + if len and len ~= 0 then + local g = nodenew(glueid) + setglue(g, len) + g.subtype = subtype + g.leader = final and list or nodecopy(list) + local k = nodenew(kernid) + k.kern = -len + head = insert_before(head, start, g) + head = insert_before(head, start, k) + end end return head end -local function process_uline (head, parent, items, level) - local curr, items, level = head, items or {}, level or 0 +local ulitems = {} + +local function process_uline (head, parent, level) + local curr, level, attr = head, level or 0 while curr do - local id = curr.id - if id == whatsitid - and curr.subtype == user_whatsit - and curr.user_id == uline_id then + if curr.list then + curr.list = process_uline(curr.list, curr, level+1) + + elseif curr.id == whatsitid and curr.user_id == uline_id then local value = curr.value if curr.type == lua_value then local count, list, subtype = tableunpack(value) - items[count] = { - start = curr, + ulitems[count] = { list = list, subtype = subtype, level = level, } - elseif items[value] then - head = draw_uline(head, curr, parent, items[value], true) - items[value] = nil + else + local item = ulitems[value] + if item then + head = draw_uline(head, curr, parent, item, true) + ulitems[value] = nil + attr = nil + end end - curr.user_id = no_uline_id -- avoid multiple run - elseif id == hlistid then - local list = curr.list - if list then - curr.list, items = process_uline(list, curr, items, level+1) + else + local currattr = has_attribute(curr, ulineattr) + if currattr then + local item = ulitems[currattr] + if item and not item.start then + item.start = curr + attr = currattr + end end + end curr = getnext(curr) end - curr = nodeslide(head) - for i, t in pairs(items) do - if level == t.level then - head = draw_uline(head, curr, parent, t) - t.start = nil + if attr then + local item = ulitems[attr] + if item and item.level == level then + head = draw_uline(head, nodeslide(head), parent, item) + item.start = nil end end - return head, items + + return head end -- ruby @@ -1390,7 +1412,7 @@ end local rubybox = {} luatexko.rubybox = rubybox -local function getrubystretchfactor (box) +function luatexko.getrubystretchfactor (box) local _, fid = hbox_char_font(box, true, true) local str = font_options.intercharstretch[fid] if str then @@ -1398,7 +1420,6 @@ local function getrubystretchfactor (box) set_macro("luatexkostretchfactor", stringformat("%.4f", str/em/2)) end end -luatexko.getrubystretchfactor = getrubystretchfactor local function process_ruby_pre_linebreak (head) local curr = head @@ -1458,13 +1479,11 @@ local function process_ruby_post_linebreak (head) head = insert_before(head, curr, ruby) end ruby_t = nil - unset_attribute(curr, rubyattr) - else - local list = curr.list - if list then - curr.list = process_ruby_post_linebreak(list) - end + elseif curr.list then + curr.list = process_ruby_post_linebreak(curr.list) end + elseif curr.list then + curr.list = process_ruby_post_linebreak(curr.list) end curr = getnext(curr) end @@ -1797,7 +1816,7 @@ local function process_vertical_font (fontdata) end end -local function get_horizbox_moveleft () +function luatexko.gethorizboxmoveleft () for _, v in ipairs{ fontcurrent(), texattribute.luatexkohangulfontattr, texattribute.luatexkohanjafontattr, @@ -1811,7 +1830,6 @@ local function get_horizbox_moveleft () end end end -luatexko.gethorizboxmoveleft = get_horizbox_moveleft -- charraise @@ -1885,10 +1903,13 @@ local function process_fake_slant_font (fontdata) local fsl = fontdata.slant if fsl and fsl > 0 then fsl = fsl/1000 + local hb = is_harf(fontdata) + local params = fontdata.parameters or {} - params.slant = (params.slant or 0) + fsl*65536 -- slant per point + if not hb then -- hb done by luaotfload + params.slant = (params.slant or 0) + fsl*65536 -- slant per point + end - local hb = is_harf(fontdata) local scale = hb and hb.scale or params.factor or 655.36 local shared = fontdata.shared or {} @@ -1928,6 +1949,13 @@ create_callback("luatexko_hpack_first", "data", pass_fun) create_callback("luatexko_prelinebreak_first", "data", pass_fun) create_callback("luatexko_hpack_second", "data", pass_fun) create_callback("luatexko_prelinebreak_second", "data", pass_fun) +create_callback("luatexko_do_atbegshi", "data", pass_fun) + +function luatexko.process_atbegshi (box) + if box and box.list then + box.list = call_callback("luatexko_do_atbegshi", box.list) + end +end add_to_callback("hpack_filter", function(h) h = process_fonts(h) @@ -2058,17 +2086,14 @@ add_to_callback("luaotfload.patch_font_unsafe", process_patch_font, local auxiliary_procs = { dotemph = { - hpack_filter = process_dotemph, - post_linebreak_filter = process_dotemph, + luatexko_do_atbegshi = process_dotemph, }, uline = { - hpack_filter = process_uline, - post_linebreak_filter = process_uline, + luatexko_do_atbegshi = process_uline, }, ruby = { - pre_linebreak_filter = process_ruby_pre_linebreak, - hpack_filter = process_ruby_post_linebreak, - post_linebreak_filter = process_ruby_post_linebreak, + pre_linebreak_filter = process_ruby_pre_linebreak, + luatexko_do_atbegshi = process_ruby_post_linebreak, }, autojosa = { luatexko_hpack_first = process_josa, @@ -2080,26 +2105,12 @@ local auxiliary_procs = { }, } -local function activate (name) +function luatexko.activate (name) for cbnam, cbfun in pairs( auxiliary_procs[name] ) do - local fun - if cbnam == "hpack_filter" then - fun = function(h, gc) - if gc == "hbox" or gc == "adjusted_hbox" or gc == "align_set" then - h = cbfun(h) - end - return h - end - else - fun = function(h) - h = cbfun(h) - return h - end - end - add_to_callback(cbnam, fun, "luatexko."..cbnam.."."..name) + add_to_callback(cbnam, cbfun, "luatexko."..cbnam.."."..name) end + active_processes[name] = true end -luatexko.activate = activate add_to_callback ("hyphenate", function(head) @@ -2129,12 +2140,12 @@ end, -- aux functions -local function deactivate_all (str) +function luatexko.deactivateall (str) luatexko.deactivated = {} for _, name in ipairs{ "hpack_filter", "pre_linebreak_filter", - "post_linebreak_filter", "hyphenate", + "luatexko_do_atbegshi", -- might not work properly "luaotfload.patch_font_unsafe", -- added for harf "luaotfload.patch_font" } do local t = {} @@ -2147,9 +2158,8 @@ local function deactivate_all (str) luatexko.deactivated[name] = t end end -luatexko.deactivateall = deactivate_all -local function reactivate_all () +function luatexko.reactivateall () for name, v in pairs(luatexko.deactivated or {}) do for _, vv in ipairs(v) do add_to_callback(name, tableunpack(vv)) @@ -2157,10 +2167,8 @@ local function reactivate_all () end luatexko.deactivated = nil end -luatexko.reactivateall = reactivate_all -local function current_has_hangul_chars (cnt) +function luatexko.currenthashangulchars (cnt) texcount[cnt] = char_in_font(fontcurrent(), 0xAC00) and 1 or 0 end -luatexko.currenthashangulchars = current_has_hangul_chars diff --git a/macros/luatex/generic/luatexko/luatexko.sty b/macros/luatex/generic/luatexko/luatexko.sty index dd25d17b77..f96b228a2c 100644 --- a/macros/luatex/generic/luatexko/luatexko.sty +++ b/macros/luatex/generic/luatexko/luatexko.sty @@ -14,12 +14,14 @@ \ifdefined\luatexkohangulfontattr \endinput\fi \ifdefined\selectfont \NeedsTeXFormat{LaTeX2e}[2020/02/02] - \ProvidesPackage{luatexko}[2020/03/14 v2.7 typesetting Korean with LuaTeX] + \ProvidesPackage{luatexko}[2020/03/20 v2.8 typesetting Korean with LuaTeX] \RequirePackage{luatexbase} \RequirePackage{fontspec}[2020/02/03] + \RequirePackage{atbegshi} \else \input luatexbase.sty \input luaotfload.sty + \input atbegshi.sty \chardef\luatexkoatcatcode=\catcode`\@ \catcode`\@=11 \fi @@ -31,10 +33,21 @@ \newattribute\luatexkoautojosaattr \newattribute\luatexkoclassicattr \newattribute\luatexkodotemphattr +\newattribute\luatexkoulineattr \newattribute\luatexkorubyattr \chardef\luatexkorubyalloc\allocationnumber \newattribute\luatexkohangulbyhangulattr \newattribute\luatexkohanjabyhanjaattr \directlua{ require"luatexko" } +\edef\AtBegShi@Hook{% occupy the first position + \unexpanded{% + \AtBegShi@Item{% + \directlua{% + luatexko.process_atbegshi(tex.getbox(\the\AtBeginShipoutBox)) + }% + }% + }% + \unexpanded\expandafter{\AtBegShi@Hook}% +} % classic \protected\def\typesetclassic{\luatexkoclassicattr\z@\parindent1em } \protected\def\typesetvertical{\luatexkoclassicattr\@ne\parindent1em } @@ -133,8 +146,11 @@ \setbox\z@\hbox{\raise\dotemphraise\hbox{\dotemphchar}}% \directlua{ if \the\luatexkodotemphcount == 1 then luatexko.activate("dotemph") end - luatexko.dotemphbox[\the\luatexkodotemphcount] = node.copy(tex.box[0].list) + luatexko.dotemphbox[\the\luatexkodotemphcount] = node.copy(tex.box[0]) }\luatexkodotemphattr\luatexkodotemphcount #1% + \directlua{ + luatexko.dotemphboundary(\the\luatexkodotemphattr) + }% \endgroup } % uline \newcount\luatexkoulinecount @@ -149,18 +165,17 @@ \def\luatexkomarkoverwith#1#2{% \global\advance\luatexkoulinecount\@ne \begingroup - \count@\luatexkoulinecount - \ifx\luatexkoulinerunning\relax - \edef\ulinedown{\the\dimexpr\ulinedown+\ulinewidth+.15ex\relax}\fi - \let\luatexkoulinerunning\relax \leavevmode \setbox\z@\hbox{#1}% \directlua{ if \the\luatexkoulinecount == 1 then luatexko.activate("uline") end - luatexko.ulboundary(\the\count@, tex.box[0].list, \luatexkoleaderstype) - }#2\relax + luatexko.ulboundary(\the\luatexkoulinecount, + tex.box[0].list, + \luatexkoleaderstype) + }% + \luatexkoulineattr\luatexkoulinecount #2\relax \directlua{ - luatexko.ulboundary(\the\count@) + luatexko.ulboundary(\the\luatexkoulineattr) }\endgroup } \protected\def\uline{\markoverwith{% \vrule width\z@ height-\ulinedown depth\dimexpr\ulinedown+\ulinewidth\relax }} @@ -170,13 +185,29 @@ \kern.125em }}} \protected\def\dotuline{\markoverwith*{% \lower\dimexpr\ulinedown+.2ex\relax\hbox{\kern.07em .\kern.07em }}} -\protected\def\uuline#1{\uline{\uline{#1}}} -\protected\def\sout#1{\begingroup +\protected\def\uuline{\markoverwith{% + \lower\ulinedown\vtop{% + \hrule width .2em height\z@ depth\ulinewidth + \kern .15ex + \hrule width .2em height\z@ depth\ulinewidth + }% +}} +\protected\def\sout#1{% + \begingroup \setbox\z@\hbox{#1}% - \edef\ulinedown{\the\dimexpr + \edef\soutdown{% + \the\dimexpr \directlua{ tex.sprint(luatexko.get_strike_out_down(tex.box[0])) }sp - -.5\dimexpr\ulinewidth\relax \relax }% - \uline{#1}\endgroup} + -.5\dimexpr\ulinewidth\relax \relax + }% + \markoverwith{% + \vrule width \z@ + height-\soutdown + depth \dimexpr\soutdown+\ulinewidth\relax + }% + {#1}% + \endgroup +} \protected\def\xout{\markoverwith{\hbox to.4em{\hss/\hss}}} \protected\def\uwave{\font\luatexkofontsixly=lasy6\relax \markoverwith{\lower4\p@\hbox{\luatexkofontsixly\char58}}} |