summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luatexko
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-05-08 22:29:17 +0000
committerKarl Berry <karl@freefriends.org>2016-05-08 22:29:17 +0000
commit67540d71d0313938c8c7a8012f8014802b7ea8f9 (patch)
tree4a759892e5497ec6f09ef5f32ad4a5e5edec914c /Master/texmf-dist/tex/luatex/luatexko
parent4a8bf7a112a3fe0c9e1ee259bfdd877f3bccf488 (diff)
luatexko (8may16)
git-svn-id: svn://tug.org/texlive/trunk@40956 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luatexko')
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty29
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko.lua91
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko.sty2
3 files changed, 71 insertions, 51 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty
index e34a222ef35..bec7d1206b2 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-core.sty
@@ -17,7 +17,7 @@
\ifcsname ifpdf\endcsname\else \input ifpdf.sty \fi
\catcode`@ = 11
\else
- \ProvidesPackage{luatexko-core}[2016/04/25 v1.13 Typesetting Korean with LuaTeX]
+ \ProvidesPackage{luatexko-core}[2016/05/08 v1.14 Typesetting Korean with LuaTeX]
\RequirePackage{luaotfload}[2016/04/21]
\RequirePackage{ifpdf}
\fi
@@ -271,27 +271,36 @@
\def\ulinedown {0.25em }
\newcount\luakoulineboxcnt\luakoulineboxcnt\z@
\protected\def\uline#1{%
+ \begingroup
\ifnum\luakoulineboxcnt > 65535 \luakoulineboxcnt\z@ \fi
\global\advance\luakoulineboxcnt\@ne
+ \edef\luako@temp@{\the\luakoulineboxcnt}%
+ \leavevmode
\dimen@\dimexpr\ulinedown+\ulinewidth\relax
\dimen@ii-\dimexpr\ulinedown\relax
- \setbox\z@\hbox{\vrule width\z@ height\dimen@ii depth\dimen@}%
- \directlua{luatexko.ulinebox[\the\luakoulineboxcnt]=node.copy_list(tex.box[0].head)}%
- \leavevmode\special{luako:ulinebegin=\the\luakoulineboxcnt}%
- #1\special{luako:ulineend}}
-% strike-out
+ \setbox\z@\hbox{\vrule width0pt height\dimen@ii depth\dimen@}%
+ \directlua{ luatexko.ulinebox[\luako@temp@]=node.copy_list(tex.box[0].head)
+ luatexko.uline_boundary(\luako@temp@,true) }%
+ #1%
+ \directlua{ luatexko.uline_boundary(\luako@temp@,false) }%
+ \endgroup}
\protected\def\sout#1{{\def\ulinedown{-0.5ex-\ulinewidth/2}\uline{#1}}}
% ulem with arbitray box
\protected\def\markoverwith#1#2{%
+ \begingroup
\ifnum\luakoulineboxcnt > 65535 \luakoulineboxcnt\z@ \fi
\global\advance\luakoulineboxcnt\@ne
+ \edef\luako@temp@{\the\luakoulineboxcnt}%
+ \leavevmode
\setbox\z@\hbox{#1}%
- \directlua{luatexko.ulinebox[\the\luakoulineboxcnt]=node.copy_list(tex.box[0])}%
- \leavevmode\special{luako:ulinebegin=\the\luakoulineboxcnt}%
- #2\special{luako:ulineend}}
+ \directlua{ luatexko.ulinebox[\luako@temp@]=node.copy_list(tex.box[0])
+ luatexko.uline_boundary(\luako@temp@,true) }%
+ #2%
+ \directlua{ luatexko.uline_boundary(\luako@temp@,false) }%
+ \endgroup}
\protected\def\uuline{\dimen@ii-\dimexpr\ulinedown\relax
\dimen@\dimexpr\ulinedown+\ulinewidth\relax
- \markoverwith{\vtop{\hrule width.2em height\dimen@ii depth\dimen@
+ \markoverwith{\vtop{\hrule width.1em height\dimen@ii depth\dimen@
\kern.1em\hrule height\dimen@ii depth\dimen@}}}
\protected\def\uwave {\ifx\ltxko@sixly\undefined \font\ltxko@sixly=lasy6 \fi
\markoverwith{\lower4\p@\hbox{\ltxko@sixly\char58}}}
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua
index a9ad5ab6229..0be96ddbd0d 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua
@@ -13,8 +13,8 @@
luatexbase.provides_module {
name = 'luatexko',
- date = '2016/04/25',
- version = '1.13',
+ date = '2016/05/08',
+ version = '1.14',
description = 'Korean linebreaking and font-switching',
author = 'Dohyun Kim, Soojin Nam',
license = 'LPPL v1.3+',
@@ -83,7 +83,7 @@ local kernnode = node.id("kern")
local penaltynode = node.id("penalty")
local rulenode = node.id("rule")
local whatsitnode = node.id("whatsit")
-local whatsitspecial = node.subtype("special")
+local user_whatsit = node.subtype("user_defined")
local nodedirect = node.direct
local d_todirect = nodedirect.todirect
@@ -121,6 +121,7 @@ local d_end_of_math = nodedirect.end_of_math
local d_nodetail = nodedirect.tail
local d_nodedimensions = nodedirect.dimensions
local d_nodefree = nodedirect.free
+local d_nodewrite = nodedirect.write
local emsize = 655360
@@ -1808,65 +1809,75 @@ end
---------------------
-- underline emphasis
---------------------
-local function draw_underline(head,curr,width,ubox,ulstart)
+
+local uline_start_id = luatexbase.new_whatsit("luako_uline_start")
+local uline_stop_id = luatexbase.new_whatsit("luako_uline_stop")
+local function uline_boundary (num, start)
+ local n = d_nodenew(whatsitnode, user_whatsit) -- todo: use node list
+ d_setfield(n, "user_id", start and uline_start_id or uline_stop_id)
+ d_setfield(n, "type", 100)
+ d_setfield(n, "value", num)
+ d_nodewrite(n)
+end
+luatexko.uline_boundary = uline_boundary
+
+local function draw_underline(head,curr,glueset,gluesign,glueorder,ubox,start)
+ if not start then
+ start = d_getid(head) == gluenode and d_getsubtype(head) < 100 and d_getnext(head) or head
+ end
+ local width = d_nodedimensions(glueset,gluesign,glueorder,start,curr)
if width and width > 0 then
local glue = d_get_gluenode(width)
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
- for _,nd in ipairs({ulstart,curr}) do
- if d_getid(nd) == whatsitnode and d_getsubtype(nd) == whatsitspecial then
- local nddata = d_getfield(nd,"data")
- if nddata and nddata:find("luako:uline") then
- head = d_remove_node(head,nd)
- d_nodefree(nd)
- end
- end
+ head = d_insert_before(head, start, glue)
+ head = d_insert_before(head, start, d_get_kernnode(-width))
end
return head
end
-local function after_linebreak_underline(head,glueorder,glueset,gluesign,ulinenum)
- local ulstart = ulinenum and head
- if ulstart and d_getid(ulstart) == gluenode then
- ulstart = d_getnext(ulstart)
- end
+local function after_linebreak_underline(head,glueorder,glueset,gluesign,ulstart,level)
+ ulstart, level = ulstart or {}, level or 0
+
for curr in d_traverse(head) do
local currid = d_getid(curr)
- if currid == hlistnode and not ulstart then -- skip nested hbox
+ if currid == hlistnode then
local newhead
- newhead,ulinenum = after_linebreak_underline(
+ newhead, ulstart = after_linebreak_underline(
d_getlist(curr),
d_getfield(curr,"glue_order"),
d_getfield(curr,"glue_set"),
d_getfield(curr,"glue_sign"),
- ulinenum)
+ ulstart,
+ level+1)
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+)"))
- 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)
+ elseif currid == whatsitnode and d_getsubtype(curr) == user_whatsit then
+ local user_id = d_getfield(curr, "user_id")
+ local whatsit_type = d_getfield(curr, "type")
+ local num = d_getfield(curr, "value")
+ if num and ulinebox[num] and whatsit_type == 100 then
+ if user_id == uline_start_id then
+ ulstart[num] = { start = curr, level = level }
+ elseif user_id == uline_stop_id and ulstart[num] then
+ local ubox = d_todirect(ulinebox[num])
+ head = draw_underline(head,curr,glueset,gluesign,glueorder,ubox,ulstart[num].start)
d_nodefree(ubox)
- ulinebox[ulinenum], ulinenum, ulstart = nil, nil, nil
+ ulinebox[num], ulstart[num] = nil, nil
end
end
end
- if ulstart and ulinenum and curr == d_nodetail(head) then
- local ubox = d_todirect(ulinebox[ulinenum])
- local wd = d_nodedimensions(glueset,gluesign,glueorder,ulstart,curr)
- head = draw_underline(head,curr,wd,ubox,ulstart)
+ end
+
+ local curr = d_nodetail(head)
+ for i, v in pairs(ulstart) do
+ local ubox = d_todirect(ulinebox[i])
+ if ubox and level == v.level then
+ head = draw_underline(head,curr,glueset,gluesign,glueorder,ubox,v.start)
+ ulstart[i].start = nil
end
end
- return head, ulinenum
+
+ return head, ulstart
end
-----------------------------------
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
index cdedc21db6d..9101bbe65ac 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
@@ -23,7 +23,7 @@
\expandafter\endinput
\fi
-\ProvidesPackage{luatexko}[2016/04/25 v1.13 Typesetting Korean with LuaLaTeX]
+\ProvidesPackage{luatexko}[2016/05/08 v1.14 Typesetting Korean with LuaLaTeX]
\ifdefined\adjustspacing\else % luatex < 0.87
\let\adjustspacing\pdfadjustspacing