summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-12-02 21:59:03 +0000
committerKarl Berry <karl@freefriends.org>2019-12-02 21:59:03 +0000
commite3ab92df447cf11f30d0c6e59d7877d938209c83 (patch)
tree93d078c0389b9ec1a0d22e9233ab44bfe4c21b73 /Master/texmf-dist/tex
parent5344a5f028fbeed57e885525fa06a1b168a6dd3b (diff)
luatexko (2dec19)
git-svn-id: svn://tug.org/texlive/trunk@53001 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua4
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua4
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko.lua499
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko.sty69
4 files changed, 372 insertions, 204 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
index 97c2b0ccf87..40e05687ec4 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
@@ -13,8 +13,8 @@
luatexbase.provides_module({
name = "luatexko-normalize",
- version = "2.4",
- date = "2019/08/01",
+ version = "2.5",
+ date = "2019/12/01",
author = "Dohyun Kim, Soojin Nam",
description = "Hangul normalization",
license = "LPPL v1.3+",
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua
index 82d11379cb5..b7156998295 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua
@@ -13,8 +13,8 @@
luatexbase.provides_module({
name = "luatexko-uhc2utf8",
- version = "2.4",
- date = "2019/08/01",
+ version = "2.5",
+ date = "2019/12/01",
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 3ab4f18961a..f7819aec89d 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 = '2019/08/01',
- version = '2.4',
+ date = '2019/12/01',
+ version = '2.5',
description = 'typesetting Korean with LuaTeX',
author = 'Dohyun Kim, Soojin Nam',
license = 'LPPL v1.3+',
@@ -59,9 +59,13 @@ local texsp = tex.sp
local set_macro = token.set_macro
+local mathmax = math.max
+
local stringformat = string.format
+local stringunpack = string.unpack
local tableconcat = table.concat
+local tableinsert = table.insert
local tableunpack = table.unpack
local add_to_callback = luatexbase.add_to_callback
@@ -230,8 +234,8 @@ local function option_in_font (fontdata, optionname)
if type(fontdata) == "number" then
fontdata = get_font_data(fontdata)
end
- if fontdata.shared then
- return fontdata.shared.features[optionname]
+ if fontdata.specification then
+ return fontdata.specification.features.normal[optionname]
end
end
@@ -245,6 +249,28 @@ local function my_node_props (n)
return t.luatexko
end
+local function is_harf (f)
+ if type(f) == "number" then
+ f = get_font_data(f)
+ end
+ return f.hb
+end
+
+local function is_not_harf (f)
+ if option_in_font(f, "mode") == "harf" then -- mode=harf with non-luahbtex
+ return false
+ end
+ return not is_harf(f)
+end
+
+local function harf_reordered_tonemark (curr)
+ if is_harf(curr.font) then
+ local props = getproperty(curr) or {}
+ local actualtext = props.luaotfload_startactualtext or ""
+ return actualtext:find"302[EF]$"
+ end
+end
+
-- font fallback
local force_hangul = {
@@ -283,6 +309,8 @@ luatexko.updateforcehangul = update_force_hangul
local active_processes = {}
local char_font_options = {
+ ascender = {},
+ charraise = {},
hangulspaceskip = {},
intercharacter = {},
intercharstretch = {},
@@ -292,7 +320,7 @@ local char_font_options = {
}
local function hangul_space_skip (curr, newfont)
- if curr.lang ~= nohyphen then
+ if curr.lang ~= nohyphen and curr.font ~= newfont then
local n = getnext(curr)
if n and n.id == glueid and n.subtype == spaceskip then
local params = getparameters(curr.font)
@@ -306,17 +334,24 @@ local function hangul_space_skip (curr, newfont)
local newwd = char_font_options.hangulspaceskip[newfont]
if newwd == nil then
- local newsp = nodecopy(curr)
- newsp.char, newsp.font = 32, newfont
- newsp = nodes.simple_font_handler(newsp)
- newwd = newsp and newsp.width or false
- if newwd then
- newwd = { texsp(newwd), texsp(newwd/2), texsp(newwd/3) }
+ if is_harf(newfont) then
+ newwd = getparameters(newfont) or false
+ if newwd then
+ newwd = { newwd.space, newwd.space_stretch, newwd.space_shrink }
+ end
+ else
+ local newsp = nodecopy(curr)
+ newsp.char, newsp.font = 32, newfont
+ newsp = nodes.simple_font_handler(newsp)
+ newwd = newsp and newsp.width or false
+ if newwd then
+ newwd = { texsp(newwd), texsp(newwd/2), texsp(newwd/3) }
+ end
+ if newsp then
+ nodefree(newsp)
+ end
end
char_font_options.hangulspaceskip[newfont] = newwd
- if newsp then
- nodefree(newsp)
- end
end
if newwd then
setglue(n, newwd[1], newwd[2], newwd[3])
@@ -345,6 +380,7 @@ local function process_fonts (head)
if not active_processes.reorderTM and
hangul_tonemark[c] and
+ is_not_harf(curr.font) and
option_in_font(curr.font, "script") == "hang" then
luatexko.activate("reorderTM") -- activate reorderTM here
active_processes.reorderTM = true
@@ -410,6 +446,7 @@ local intercharclass = { [0] =
{ [0] = {1,0}, {1,0}, nil, {1.5,.5},nil, {1,0}, {1,0} },
{ [0] = nil, {1,1}, nil, {.5,.5} },
{ [0] = {1,1}, {1,1}, nil, {.5,.5} },
+ { }, -- vertical colon
}
local charclass = setmetatable({
@@ -447,8 +484,8 @@ local SC_charclass = setmetatable({
}, { __index = charclass })
local vert_charclass = setmetatable({
- [0xFF1A] = 5, -- 0xFE13
- [0xFF1B] = 5, -- 0xFE14
+ [0xFF1A] = 7, -- 0xFE13
+ [0xFF1B] = 7, -- 0xFE14
}, { __index = charclass })
local function get_char_class (c, classic)
@@ -579,18 +616,17 @@ end
local function get_actualtext (curr)
local actual = my_node_props(curr).startactualtext
if type(actual) == "table" then
- return actual[0], actual[1], actual[#actual]
+ return actual.init, actual[1], actual[#actual]
end
end
local function goto_end_actualtext (curr)
local n = getnext(curr)
while n do
- if n.id == whatsitid
- and n.mode == directmode
- and my_node_props(n).endactualtext then
- curr = n
- break
+ if n.id == whatsitid and
+ n.mode == directmode and
+ my_node_props(n).endactualtext then
+ curr = n; break
end
n = getnext(n)
end
@@ -731,7 +767,8 @@ local function process_glyph_width (head)
if class >= 1 and class <= 4 and
(old or cc < 0x2000 or cc > 0x202F) then -- exclude general puncts
- local gpos = class == 1 and getprev(curr) or getnext(curr)
+ -- harf-node always puts kern after the glyph
+ local gpos = class == 1 and is_not_harf(curr.font) and getprev(curr) or getnext(curr)
gpos = gpos and gpos.id == kernid and gpos.subtype == fontkern
if not gpos then
@@ -898,7 +935,6 @@ local function process_interlatincjk (head, par)
head, pc, pf, pcl = do_interlatincjk_option(head, curr, pc, pf, pcl, c, glyf.font, par)
curr = goto_end_actualtext(curr)
end
-
elseif id == mathid then
if pc == 1 then
head = do_interlatincjk_option(head, curr, pc, pf, pcl, 0x30, pf, par)
@@ -962,7 +998,7 @@ local function process_remove_spaces (head)
end
if ok then
head = noderemove(head, curr)
- to_free[#to_free + 1] = curr
+ tableinsert(to_free, curr)
break
end
end
@@ -1048,9 +1084,9 @@ local function prevjosacode (n, parenlevel)
local id = n.id
if id == glyphid then
local c = my_node_props(n).unicode or n.char -- beware hlist/vlist
- if ignore_parens and c == 0x29 then
+ if ignore_parens and c == 0x29 then -- )
parenlevel = parenlevel + 1
- elseif ignore_parens and c == 0x28 then
+ elseif ignore_parens and c == 0x28 then -- (
parenlevel = parenlevel - 1
elseif parenlevel <= 0 then
josacode = josa_code[c]
@@ -1091,7 +1127,7 @@ local function process_josa (head)
curr.char = cc
else
head = noderemove(head, curr)
- tofree[#tofree + 1] = curr
+ tableinsert(tofree, curr)
end
end
unset_attribute(curr, autojosaattr)
@@ -1107,6 +1143,26 @@ end
-- dotemph
+local function shift_put_top (bot, top)
+ local shift = top.shift or 0
+
+ if bot.id == hlistid then
+ bot = has_glyph(bot.list) or {}
+ end
+ local bot_off = bot.yoffset or 0
+
+ if bot_off ~= 0 then
+ if top.id == hlistid then
+ top = has_glyph(top.list) or {}
+ end
+ local top_off = top.yoffset or 0
+
+ return shift + top_off - bot_off
+ end
+
+ return shift
+end
+
local dotemphbox = {}
luatexko.dotemphbox = dotemphbox
@@ -1123,6 +1179,12 @@ local function process_dotemph (head, tofree)
is_chosong(c) or
is_hanja(c) or
is_kana(c) then
+
+ -- harf font: skip reordered tone mark
+ if harf_reordered_tonemark(curr) then
+ curr = getnext(curr)
+ end
+
local currwd = curr.width
if currwd >= get_en_size(curr.font) then
local box = nodecopy(dotemphbox[dotattr])
@@ -1133,6 +1195,10 @@ local function process_dotemph (head, tofree)
k.kern = shift
box.list = insert_before(list, list, k)
end
+
+ -- consider charraise
+ box.shift = shift_put_top(curr, box)
+
box.width = 0
head = insert_before(head, curr, box)
tofree[dotattr] = true
@@ -1299,6 +1365,42 @@ local function process_ruby_pre_linebreak (head)
return head
end
+local os2tag = luaotfload.harfbuzz and luaotfload.harfbuzz.Tag.new"OS/2"
+
+-- luaharfbuzz's Font:get_h_extents() gets ascender value from hhea table;
+-- Node mode's parameters.ascender is gotten from OS/2 table.
+-- TypoAscender in OS/2 table seems to be more suitable for our purpose.
+local function get_font_ascender (f)
+ local ascender = char_font_options.ascender
+ local ascend = ascender[f]
+ if ascend == nil then
+ local hb = is_harf(f)
+ if hb and os2tag then
+ local hbface = hb.shared.face
+ local tags = hbface:get_table_tags()
+ local hasos2 = false
+ for _,v in ipairs(tags) do
+ if v == os2tag then
+ hasos2 = true
+ break
+ end
+ end
+ if hasos2 then
+ local os2 = hbface:get_table(os2tag)
+ local length = os2:get_length()
+ if length > 69 then -- sTypoAscender (int16)
+ local data = os2:get_data()
+ local typoascender = stringunpack(">h", data, 69)
+ ascend = typoascender * hb.scale
+ end
+ end
+ end
+ ascend = ascend or get_font_param(f, "ascender") or false
+ ascender[f] = ascend
+ end
+ return ascend
+end
+
local function process_ruby_post_linebreak (head)
local curr = head
while curr do
@@ -1316,9 +1418,13 @@ local function process_ruby_post_linebreak (head)
ruby.list = insert_before(list, list, k)
end
ruby.width = 0
+
+ -- consider charraise
+ local shift = shift_put_top(curr, ruby)
+
local _, f = ruby_char_font(curr)
- local ascender = get_font_param(f, "ascender") or curr.height
- ruby.shift = -ascender - ruby.depth - ruby_t[2] -- rubysep
+ local ascender = get_font_ascender(f) or curr.height
+ ruby.shift = shift - ascender - ruby.depth - ruby_t[2] -- rubysep
head = insert_before(head, curr, ruby)
end
ruby_t = nil
@@ -1387,72 +1493,68 @@ local function get_tonemark_width (curr, uni)
end
local function process_reorder_tonemarks (head)
- local curr = head
+ local curr, init = head
while curr do
local id = curr.id
- if id == glyphid and option_in_font(curr.font, "script") == "hang" then
+ if id == glyphid and
+ is_not_harf(curr.font) and
+ option_in_font(curr.font, "script") == "hang" then
+
local fontdata = get_font_data(curr.font)
local uni = my_node_props(curr).unicode or curr.char
if is_hangul(uni) or is_chosong(uni) or uni == 0x25CC then
-
- local syllable = { [0]=curr, uni }
-
- local n = getnext(curr)
- while n do
- local nid = n.id
- if nid == glyphid then
- local u = my_node_props(n).unicode or n.char
- if is_jungsong(u)
- or is_jongsong(u)
- or hangul_tonemark[u] then
- syllable[#syllable + 1] = u
- curr, uni = n, u
- else
- break
+ init = curr
+ elseif is_jungsong(uni) or is_jongsong(uni) then
+ elseif hangul_tonemark[uni] then
+ if init then
+ local n, syllable = init, { init = init }
+ while n do
+ if n.id == glyphid then
+ local u = my_node_props(n).unicode or n.char
+ if u then tableinsert(syllable, u) end
end
- elseif nid ~= kernid or n.subtype == userkern then
- break
+ if n == curr then break end
+ n = getnext(n)
end
- n = getnext(n)
- end
- if #syllable > 1
- and hangul_tonemark[uni]
- and get_tonemark_width(curr, uni) ~= 0 then
+ if #syllable > 1 and get_tonemark_width(curr, uni) ~= 0 then
+ local TM = curr
- local ini, fin = syllable[0], curr
- local actual = pdfliteral_direct_actual(syllable)
- local endactual = pdfliteral_direct_actual()
- head = insert_before(head, ini, actual)
- head, curr = insert_after(head, curr, endactual)
+ local actual = pdfliteral_direct_actual(syllable)
+ local endactual = pdfliteral_direct_actual()
+ head = insert_before(head, init, actual)
+ head, curr = insert_after(head, curr, endactual)
- head = noderemove(head, fin)
- head = insert_before(head, ini, fin)
- end
+ head = noderemove(head, TM)
+ head = insert_before(head, init, TM)
+ end
- elseif hangul_tonemark[uni] -- isolated tone mark
- and char_in_font(fontdata, 0x25CC) then
-
- local dotcircle = nodecopy(curr)
- dotcircle.char = 0x25CC
- if get_tonemark_width(curr, uni) ~= 0 then
- local actual = pdfliteral_direct_actual{ [0]=curr, uni }
- local endactual = pdfliteral_direct_actual()
- head = insert_before(head, curr, actual)
- head, curr = insert_after(head, curr, dotcircle)
- head, curr = insert_after(head, curr, endactual)
- else
- head = insert_before(head, curr, dotcircle)
+ init = nil
+ elseif char_in_font(fontdata, 0x25CC) then -- isolated tone mark
+ local dotcircle = nodecopy(curr)
+ dotcircle.char = 0x25CC
+ if get_tonemark_width(curr, uni) ~= 0 then
+ local actual = pdfliteral_direct_actual{ init = curr, uni }
+ local endactual = pdfliteral_direct_actual()
+ head = insert_before(head, curr, actual)
+ head, curr = insert_after(head, curr, dotcircle)
+ head, curr = insert_after(head, curr, endactual)
+ else
+ head = insert_before(head, curr, dotcircle)
+ end
end
- end
- elseif id == whatsitid
- and curr.mode == directmode
- and my_node_props(curr).startactualtext then
-
- curr = goto_end_actualtext(curr)
- elseif id == mathid then
- curr = end_of_math(curr)
+ else
+ init = nil
+ end
+ elseif id == kernid and curr.subtype ~= userkern then -- skip
+ elseif id == whatsitid then
+ if curr.mode == directmode and my_node_props(curr).startactualtext then
+ curr, init = goto_end_actualtext(curr), nil
+ end
+ else
+ init = nil
+ if id == mathid then curr = end_of_math(curr) end
end
curr = getnext(curr)
end
@@ -1587,12 +1689,21 @@ local function get_tsb_table (filename, subfont)
end
end
+local function fontdata_warning(activename, ...)
+ if not active_processes[activename] then
+ warning(...)
+ active_processes[activename] = true
+ end
+end
+
local function process_vertical_font (fontdata)
local subfont = fontdata.specification and fontdata.specification.sub
local tsb_tab = get_tsb_table(fontdata.filename, subfont)
+
if not tsb_tab then
- warning("Vertical metrics table (vmtx) not found in the font\n"..
- "`%s'", fontdata.fullname)
+ local fullname = fontdata.fullname
+ fontdata_warning("vertical."..fullname,
+ "Vertical metrics table (vmtx) not found in the font\n`%s'", fullname)
return
end
@@ -1690,24 +1801,23 @@ luatexko.gethorizboxmoveleft = get_horizbox_moveleft
-- charraise
-local function process_charriase_font (fontdata)
- local raise = fontdata_opt_dim(fontdata, "charraise")
- if raise then
- local shared = fontdata.shared or {}
- local descriptions = shared.rawdata and shared.rawdata.descriptions or {}
- local scale = fontdata.parameters.factor or 655.36
- for i, v in pairs( fontdata.characters ) do
- v.commands = {
- {"down", -raise },
- {"char", i},
- }
- local bbox = descriptions[i] and descriptions[i].boundingbox or {0,0,0,0}
- local ht = bbox[4] * scale + raise
- local dp = bbox[2] * scale + raise
- v.height = ht > 0 and ht or nil
- v.depth = dp < 0 and -dp or nil
+local function process_charraise (head)
+ local curr = head
+ while curr do
+ if curr.id == glyphid then
+ local f = curr.font
+ local raise = get_font_opt_dimen(f, "charraise")
+ if raise and not option_in_font(f, "vertical") then
+ local props = my_node_props(curr)
+ if not props.charraised then
+ curr.yoffset = (curr.yoffset or 0) + raise
+ props.charraised = true
+ end
+ end
end
+ curr = getnext(curr)
end
+ return head
end
-- fake italic correctioin
@@ -1718,28 +1828,34 @@ local function process_fake_slant_corr (head) -- for font fallback
local id = curr.id
if id == kernid then
if curr.subtype == italcorr and curr.kern == 0 then
- local p = getprev(curr)
- while p do -- skip jungsong/jongsong
- if p.id == glyphid and p.width < get_en_size(p.font) then
+ local p, t = getprev(curr), {}
+ while p do
+ if p.id == glyphid then
+ -- harf font: break before reordered tone mark
+ if harf_reordered_tonemark(p) then
+ break
+ end
+
+ local slant = option_in_font(p.font, "slant")
+ if slant and slant > 0 then
+ tableinsert(t, char_in_font(p.font, p.char).italic or 0)
+ end
+
local c = my_node_props(p).unicode or p.char
- if not is_jungsong(c) and not is_jongsong(c) then
+ if is_jungsong(c) or is_jongsong(c) or hangul_tonemark[c] then
+ else
break
end
- elseif p.id == whatsitid
- and p.mode == directmode
- and my_node_props(p).endactualtext then -- skip
else
break
end
p = getprev(p)
end
- if p.id == glyphid then
- local fontdata = get_font_data(p.font)
- if fontdata.slant and fontdata.slant > 0 then
- local italic = char_in_font(fontdata, p.char).italic
- if italic then
- curr.kern = italic
- end
+
+ if p.id == glyphid and #t > 0 then
+ local italic = mathmax(tableunpack(t))
+ if italic > 0 then
+ curr.kern = italic
end
end
end
@@ -1757,12 +1873,33 @@ local function process_fake_slant_font (fontdata)
fsl = fsl/1000
local params = fontdata.parameters or {}
params.slant = (params.slant or 0) + fsl*65536 -- slant per point
- local scale = params.factor or 655.36
+
+ local hb = is_harf(fontdata)
+ local scale = hb and hb.scale or params.factor or 655.36
+
local shared = fontdata.shared or {}
- local descriptions = shared.rawdata and shared.rawdata.descriptions or {}
+ local descrs = shared.rawdata and shared.rawdata.descriptions or {}
+
for i, v in pairs(fontdata.characters) do
- local bbox = descriptions[i] and descriptions[i].boundingbox or {0,0,0,0}
- local italic = (v.height or 0) * fsl - (v.width or 0) + bbox[3]*scale
+ local ht = v.height and v.height > 0 and v.height or 0
+ local wd = v.width and v.width > 0 and v.width or 0
+ local rbearing = 0
+
+ if wd > 0 then -- or, jong/jung italic could by very large value
+ if hb then
+ local extents = hb.shared.font:get_glyph_extents(v.index)
+ if extents then
+ rbearing = wd - (extents.x_bearing + extents.width)*scale
+ end
+ else
+ local bbox = descrs[i] and descrs[i].boundingbox
+ if bbox then
+ rbearing = wd - bbox[3]*scale
+ end
+ end
+ end
+
+ local italic = ht * fsl - rbearing
if italic > 0 then
v.italic = italic
end
@@ -1773,37 +1910,41 @@ end
-- wrap up
local pass_fun = function(...) return ... end
-create_callback("luatexko_pre_hpack", "data", pass_fun)
-create_callback("luatexko_pre_prelinebreak", "data", pass_fun)
-create_callback("luatexko_post_hpack", "data", pass_fun)
-create_callback("luatexko_post_prelinebreak", "data", pass_fun)
+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)
add_to_callback("hpack_filter", function(h)
h = process_fonts(h)
- h = call_callback("luatexko_pre_hpack", h)
- h = call_callback("luatexko_post_hpack", h)
+ h = call_callback("luatexko_hpack_first", h)
+ h = call_callback("luatexko_hpack_second", h)
return process_linebreak(h)
end, "luatexko.hpack_filter.pre_rendering", 1)
add_to_callback("pre_linebreak_filter", function(h)
h = process_fonts(h)
- h = call_callback("luatexko_pre_prelinebreak", h, true)
- h = call_callback("luatexko_post_prelinebreak", h, true)
+ h = call_callback("luatexko_prelinebreak_first", h, true)
+ h = call_callback("luatexko_prelinebreak_second", h, true)
return process_linebreak(h, true)
end, "luatexko.pre_linebreak_filter.pre_rendering", 1)
local font_opt_procs = {
removeclassicspaces = {
- luatexko_pre_hpack = process_remove_spaces,
- luatexko_pre_prelinebreak = process_remove_spaces,
+ luatexko_hpack_first = process_remove_spaces,
+ luatexko_prelinebreak_first = process_remove_spaces,
},
interhangul = {
- luatexko_post_hpack = process_interhangul,
- luatexko_post_prelinebreak = process_interhangul,
+ luatexko_hpack_second = process_interhangul,
+ luatexko_prelinebreak_second = process_interhangul,
},
interlatincjk = {
- luatexko_post_hpack = process_interlatincjk,
- luatexko_post_prelinebreak = process_interlatincjk,
+ luatexko_hpack_second = process_interlatincjk,
+ luatexko_prelinebreak_second = process_interlatincjk,
+ },
+ charraise = {
+ hpack_filter = process_charraise,
+ pre_linebreak_filter = process_charraise,
},
compresspunctuations = {
hpack_filter = process_glyph_width,
@@ -1815,50 +1956,73 @@ local font_opt_procs = {
},
}
-local function process_patch_font (fontdata)
- for name, procs in pairs( font_opt_procs ) do
- if not active_processes[name] and option_in_font(fontdata, name) then
- for cbnam, cbfun in pairs( procs ) do
- add_to_callback(cbnam, cbfun, "luatexko."..cbnam.."."..name)
- end
- active_processes[name] = true
+local font_opt_procs_single = {
+ expansion = function()
+ if not active_processes.expansion then
+ texset("global", "adjustspacing", 2)
+ active_processes.expansion = true
end
- end
+ end,
- if not active_processes.expansion
- and option_in_font(fontdata, "expansion") then
- texset("global", "adjustspacing", 2)
- active_processes.expansion = true
- end
-
- if option_in_font(fontdata, "protrusion") then
+ protrusion = function(fontdata)
if not active_processes.protrusion then
texset("global", "protrudechars", 2)
active_processes.protrusion = true
end
- if not active_processes[fontdata.fullname] and
- option_in_font(fontdata, "compresspunctuations") then
- warning("Both `compresspunctuations' and `protrusion' are\n"..
- "enabled for the font `%s'.\n"..
- "Beware that this could result in bad justifications.\n",
- fontdata.fullname)
- active_processes[fontdata.fullname] = true
+ if option_in_font(fontdata, "compresspunctuations") then
+ local fullname = fontdata.fullname
+ fontdata_warning("protrude."..fullname,
+ "Both `compresspunctuations' and `protrusion' are\nenabled for `%s'.\n"..
+ "Beware bad justifications.", fullname)
end
- end
+ end,
+
+ slant = process_fake_slant_font,
+
+ vertical = function(fontdata)
+ local fullname = fontdata.fullname
+ if is_harf(fontdata) then
+ fontdata_warning("vertical."..fullname,
+ "Currently, vertical writing is not supported\nby harf mode."..
+ "`Renderer=Node' option is needed for\n`%s'", fullname)
+ elseif fontdata.type == "virtual" then
+ fontdata_warning("vitrual."..fullname,
+ "Virtual font `%s' cannot be\nused for vertical writing.", fullname)
+ else
+ process_vertical_font(fontdata)
+ end
+ end,
+}
- if option_in_font(fontdata, "vertical") then
- process_vertical_font(fontdata)
- elseif option_in_font(fontdata, "charraise") then
- process_charriase_font(fontdata)
+local function process_patch_font (fontdata)
+ if type(fontdata) ~= "table" or
+ fontdata.format ~= "opentype" and fontdata.format ~= "truetype" then
+ return
+ end -- as we have called patch_font_unsafe for hb fonts
+
+ for name, procs in pairs( font_opt_procs ) do
+ if not active_processes[name] and option_in_font(fontdata, name) then
+ if name == "charraise" and option_in_font(fontdata, "vertical") then
+ else
+ for cbnam, cbfun in pairs( procs ) do
+ add_to_callback(cbnam, cbfun, "luatexko."..cbnam.."."..name)
+ end
+ active_processes[name] = true
+ end
+ end
end
- if option_in_font(fontdata, "slant") then
- process_fake_slant_font(fontdata)
+ for name, func in pairs( font_opt_procs_single ) do
+ if option_in_font(fontdata, name) then
+ func(fontdata)
+ end
end
end
add_to_callback("luaotfload.patch_font", process_patch_font,
"luatexko.patch_font")
+add_to_callback("luaotfload.patch_font_unsafe", process_patch_font,
+"luatexko.patch_font")
local auxiliary_procs = {
dotemph = {
@@ -1875,12 +2039,12 @@ local auxiliary_procs = {
vpack_filter = process_ruby_post_linebreak,
},
autojosa = {
- luatexko_pre_hpack = process_josa,
- luatexko_pre_prelinebreak = process_josa,
+ luatexko_hpack_first = process_josa,
+ luatexko_prelinebreak_first = process_josa,
},
reorderTM = {
- luatexko_pre_hpack = process_reorder_tonemarks,
- luatexko_pre_prelinebreak = process_reorder_tonemarks,
+ luatexko_hpack_first = process_reorder_tonemarks,
+ luatexko_prelinebreak_first = process_reorder_tonemarks,
},
}
@@ -1939,12 +2103,13 @@ local function deactivate_all (str)
"pre_linebreak_filter",
"vpack_filter",
"hyphenate",
+ "luaotfload.patch_font_unsafe", -- added for harf
"luaotfload.patch_font" } do
local t = {}
for i, v in ipairs( callback_descriptions(name) ) do
if v:find(str or "^luatexko%.") then
local ff, dd = remove_from_callback(name, v)
- t[#t + 1] = { ff, dd, i }
+ tableinsert(t, { ff, dd, i })
end
end
luatexko.deactivated[name] = t
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
index 7599a0977b7..76bb940fe89 100644
--- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
+++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
@@ -13,7 +13,7 @@
\ifdefined\luatexkohangulfontattr \endinput\fi
\ifdefined\selectfont
- \ProvidesPackage{luatexko}[2019/08/01 v2.4 typesetting Korean with LuaTeX]
+ \ProvidesPackage{luatexko}[2019/12/01 v2.5 typesetting Korean with LuaTeX]
\RequirePackage{luatexbase}
\RequirePackage{fontspec}
\else
@@ -149,7 +149,8 @@
\directlua{
if \the\luatexkoulinecount == 1 then luatexko.activate("uline") end
luatexko.ulboundary(\the\count@, tex.box[0].list, \luatexkoleaderstype)
- }#2\directlua{
+ }#2\relax
+ \directlua{
luatexko.ulboundary(\the\count@)
}\endgroup }
\protected\def\uline{\markoverwith{%
@@ -309,8 +310,10 @@
\else \directlua{ luatexko.uhc2utf8.startconvert() }%
\fi}
% actualtext not provided
-\protected\def\actualtext#1#{\luatexkoactualtext}
-\def\luatexkoactualtext#1{#1}
+\ifdefined\actualtext\else
+ \protected\def\actualtext#1#{\luatexkoactualtext}
+ \def\luatexkoactualtext#1{#1}
+\fi
% math hangul
\def\setmathhangulblock#1#2{%
\count@="#1
@@ -369,8 +372,8 @@
\afterassignment\luatexkosetmathhangulfonts\font\textmathhangul}
\def\luatexkosetmathhangulfonts{%
\toks@\expandafter{\directlua{
- local n = string.gsub("\fontname\textmathhangul", " at .+", "")
- tex.sprint(n) }}%
+ local n = tex.fontname(font.id"textmathhangul"):gsub(" at .+", "")
+ tex.sprint(string.unquoted(n)) }}%
\dimen@\fontdimen 6 \textmathhangul
\font\scriptmathhangul= {\the\toks@} at .7\dimen@
\font\scriptscriptmathhangul = {\the\toks@} at .5\dimen@
@@ -407,11 +410,11 @@
\DeclareDocumentCommand \setmainhangulfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomainhangulfamily { Ligatures=TeX, #1, #3 } { #2 }
- \DeclareRobustCommand \luatexkomainhangulfont
+ \cs_set_protected_nopar:Npn \luatexkomainhangulfont
{
\fontfamily \luatexkomainhangulfamily \selectfont
}
- \str_if_eq_x:nnT \familydefault \rmdefault
+ \str_if_eq:eeT \familydefault \rmdefault
{
\cs_set_eq:NN \luatexkohangulfont \luatexkomainhangulfont
\luatexkohangulselectfont
@@ -421,11 +424,11 @@
\DeclareDocumentCommand \setsanshangulfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkosanshangulfamily { Ligatures=TeX, #1, #3 } { #2 }
- \DeclareRobustCommand \luatexkosanshangulfont
+ \cs_set_protected_nopar:Npn \luatexkosanshangulfont
{
\fontfamily \luatexkosanshangulfamily \selectfont
}
- \str_if_eq_x:nnT \familydefault \sfdefault
+ \str_if_eq:eeT \familydefault \sfdefault
{
\cs_set_eq:NN \luatexkohangulfont \luatexkosanshangulfont
\luatexkohangulselectfont
@@ -435,11 +438,11 @@
\DeclareDocumentCommand \setmonohangulfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomonohangulfamily { #1, #3 } { #2 }
- \DeclareRobustCommand \luatexkomonohangulfont
+ \cs_set_protected_nopar:Npn \luatexkomonohangulfont
{
\fontfamily \luatexkomonohangulfamily \selectfont
}
- \str_if_eq_x:nnT \familydefault \ttdefault
+ \str_if_eq:eeT \familydefault \ttdefault
{
\cs_set_eq:NN \luatexkohangulfont \luatexkomonohangulfont
\luatexkohangulselectfont
@@ -449,9 +452,9 @@
\DeclareDocumentCommand \newhangulfontfamily { m O{} m O{} }
{
\fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
- \DeclareRobustCommand #1
+ \cs_set_protected_nopar:Npn #1
{
- \tl_set:Nn \luatexkohangulfont
+ \cs_set_nopar:Npn \luatexkohangulfont
{
\exp_args:Nc \fontfamily { luatexko_user_family_ \cs_to_str:N #1 } \selectfont
}
@@ -466,7 +469,7 @@
\DeclareDocumentCommand \hangulfontspec { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkohangulfontfamily { #1, #3 } { #2 }
- \tl_set:Nn \luatexkohangulfont
+ \cs_set_nopar:Npn \luatexkohangulfont
{
\fontfamily \luatexkohangulfontfamily \selectfont
}
@@ -476,11 +479,11 @@
\DeclareDocumentCommand \setmainhanjafont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomainhanjafamily { Ligatures=TeX, #1, #3 } { #2 }
- \DeclareRobustCommand \luatexkomainhanjafont
+ \cs_set_protected_nopar:Npn \luatexkomainhanjafont
{
\fontfamily \luatexkomainhanjafamily \selectfont
}
- \str_if_eq_x:nnT \familydefault \rmdefault
+ \str_if_eq:eeT \familydefault \rmdefault
{
\cs_set_eq:NN \luatexkohanjafont \luatexkomainhanjafont
\luatexkohanjaselectfont
@@ -490,11 +493,11 @@
\DeclareDocumentCommand \setsanshanjafont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkosanshanjafamily { Ligatures=TeX, #1, #3 } { #2 }
- \DeclareRobustCommand \luatexkosanshanjafont
+ \cs_set_protected_nopar:Npn \luatexkosanshanjafont
{
\fontfamily \luatexkosanshanjafamily \selectfont
}
- \str_if_eq_x:nnT \familydefault \sfdefault
+ \str_if_eq:eeT \familydefault \sfdefault
{
\cs_set_eq:NN \luatexkohanjafont \luatexkosanshanjafont
\luatexkohanjaselectfont
@@ -504,11 +507,11 @@
\DeclareDocumentCommand \setmonohanjafont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomonohanjafamily { #1, #3 } { #2 }
- \DeclareRobustCommand \luatexkomonohanjafont
+ \cs_set_protected_nopar:Npn \luatexkomonohanjafont
{
\fontfamily \luatexkomonohanjafamily \selectfont
}
- \str_if_eq_x:nnT \familydefault \ttdefault
+ \str_if_eq:eeT \familydefault \ttdefault
{
\cs_set_eq:NN \luatexkohanjafont \luatexkomonohanjafont
\luatexkohanjaselectfont
@@ -518,9 +521,9 @@
\DeclareDocumentCommand \newhanjafontfamily { m O{} m O{} }
{
\fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
- \DeclareRobustCommand #1
+ \cs_set_protected_nopar:Npn #1
{
- \tl_set:Nn \luatexkohanjafont
+ \cs_set_nopar:Npn \luatexkohanjafont
{
\exp_args:Nc \fontfamily { luatexko_user_family_ \cs_to_str:N #1 } \selectfont
}
@@ -535,7 +538,7 @@
\DeclareDocumentCommand \hanjafontspec { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkohanjafontfamily { #1, #3 } { #2 }
- \tl_set:Nn \luatexkohanjafont
+ \cs_set_nopar:Npn \luatexkohanjafont
{
\fontfamily \luatexkohanjafontfamily \selectfont
}
@@ -546,11 +549,11 @@
\DeclareDocumentCommand \setmainfallbackfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomainfallbackfamily { Ligatures=TeX, #1, #3 } { #2 }
- \DeclareRobustCommand \luatexkomainfallbackfont
+ \cs_set_protected_nopar:Npn \luatexkomainfallbackfont
{
\fontfamily \luatexkomainfallbackfamily \selectfont
}
- \str_if_eq_x:nnT \familydefault \rmdefault
+ \str_if_eq:eeT \familydefault \rmdefault
{
\cs_set_eq:NN \luatexkofallbackfont \luatexkomainfallbackfont
\luatexkofallbackselectfont
@@ -560,11 +563,11 @@
\DeclareDocumentCommand \setsansfallbackfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkosansfallbackfamily { Ligatures=TeX, #1, #3 } { #2 }
- \DeclareRobustCommand \luatexkosansfallbackfont
+ \cs_set_protected_nopar:Npn \luatexkosansfallbackfont
{
\fontfamily \luatexkosansfallbackfamily \selectfont
}
- \str_if_eq_x:nnT \familydefault \sfdefault
+ \str_if_eq:eeT \familydefault \sfdefault
{
\cs_set_eq:NN \luatexkofallbackfont \luatexkosansfallbackfont
\luatexkofallbackselectfont
@@ -574,11 +577,11 @@
\DeclareDocumentCommand \setmonofallbackfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomonofallbackfamily { #1, #3 } { #2 }
- \DeclareRobustCommand \luatexkomonofallbackfont
+ \cs_set_protected_nopar:Npn \luatexkomonofallbackfont
{
\fontfamily \luatexkomonofallbackfamily \selectfont
}
- \str_if_eq_x:nnT \familydefault \ttdefault
+ \str_if_eq:eeT \familydefault \ttdefault
{
\cs_set_eq:NN \luatexkofallbackfont \luatexkomonofallbackfont
\luatexkofallbackselectfont
@@ -588,9 +591,9 @@
\DeclareDocumentCommand \newfallbackfontfamily { m O{} m O{} }
{
\fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
- \DeclareRobustCommand #1
+ \cs_set_protected_nopar:Npn #1
{
- \tl_set:Nn \luatexkofallbackfont
+ \cs_set_nopar:Npn \luatexkofallbackfont
{
\exp_args:Nc \fontfamily { luatexko_user_family_ \cs_to_str:N #1 } \selectfont
}
@@ -605,7 +608,7 @@
\DeclareDocumentCommand \fallbackfontspec { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkofallbackfontfamily { #1, #3 } { #2 }
- \tl_set:Nn \luatexkofallbackfont
+ \cs_set_nopar:Npn \luatexkofallbackfont
{
\fontfamily \luatexkofallbackfontfamily \selectfont
}