summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua6
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua6
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko.lua390
-rw-r--r--Master/texmf-dist/tex/luatex/luatexko/luatexko.sty147
4 files changed, 299 insertions, 250 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua b/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
index ef8edbd5875..2dec726fb65 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-2020 Dohyun Kim <nomos at ktug org>
+-- Copyright (c) 2013-2021 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 = "2.9",
- date = "2020/07/27",
+ version = "3.0",
+ date = "2021/03/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 40c5748b6fa..e82bf2cdfe0 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-2020 Dohyun Kim <nomos at ktug org>
+-- Copyright (c) 2013-2021 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 = "2.9",
- date = "2020/07/27",
+ version = "3.0",
+ date = "2021/03/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 8b7f15b966a..22fcaf54cf1 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-2020 Dohyun Kim <nomos at ktug org>
+-- Copyright (c) 2013-2021 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 = '2020/07/27',
- version = '2.9',
+ date = '2021/03/01',
+ version = '3.0',
description = 'typesetting Korean with LuaTeX',
author = 'Dohyun Kim, Soojin Nam',
license = 'LPPL v1.3+',
@@ -41,6 +41,7 @@ local noderemove = node.remove
local nodeslide = node.slide
local nodewrite = node.write
local rangedimensions = node.rangedimensions
+local set_attribute = node.set_attribute
local setglue = node.setglue
local setproperty = node.setproperty
local unset_attribute = node.unset_attribute
@@ -69,12 +70,10 @@ local tableunpack = table.unpack
local add_to_callback = luatexbase.add_to_callback
local attributes = luatexbase.attributes
local call_callback = luatexbase.call_callback
-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 registernumber = luatexbase.registernumber
-local remove_from_callback = luatexbase.remove_from_callback
local function warning (...)
return module_warning("luatexko", stringformat(...))
@@ -141,21 +140,23 @@ local function option_in_font (fontdata, optionname)
if type(fontdata) == "number" then
fontdata = get_font_data(fontdata)
end
- if fontdata.specification then
- return fontdata.specification.features.normal[optionname]
+ if fontdata.shared then
+ return fontdata.shared.features[optionname]
end
end
local function font_opt_dim (fd, optname)
local dim = option_in_font(fd, optname)
if dim then
- local params
+ local params, m, u
if type(fd) == "number" then
params = getparameters(fd)
else
params = fd.parameters
end
- local m, u = dim:match"^(.+)(e[mx])%s*$"
+ if type(dim) == "string" then
+ m, u = dim:match"^(.+)(e[mx])%s*$"
+ end
if m and u and params then
if u == "em" then
dim = m * params.quad
@@ -473,20 +474,27 @@ end
local function hangul_space_skip (curr, newfont)
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)
- local oldwd, oldst, oldsh, oldsto, oldsho = getglue(n)
- if params
- and oldwd == params.space
- and oldst == params.space_stretch
- and oldsh == params.space_shrink
- and oldsto == 0
- and oldsho == 0 then -- not user's spaceskip
-
- local newwd = font_options.hangulspaceskip[newfont]
- if newwd then
- setglue(n, newwd[1], newwd[2], newwd[3])
+ -- fontloader's "node" mode sets space_stretch to zero
+ -- when the font is a monospaced font (fontspec's \setmonofont
+ -- command does the same thing), which we will bypass here
+ -- for alignment of CJK and Latin glyphs in verbatim environment.
+ -- See http://www.ktug.org/xe/index.php?document_srl=249772
+ if not font_options.monospaced[curr.font] then
+ local n = getnext(curr)
+ if n and n.id == glueid and n.subtype == spaceskip then
+ local params = getparameters(curr.font)
+ local oldwd, oldst, oldsh, oldsto, oldsho = getglue(n)
+ if params
+ and oldwd == params.space
+ and oldst == params.space_stretch
+ and oldsh == params.space_shrink
+ and oldsto == 0
+ and oldsho == 0 then -- not user's spaceskip
+
+ local newwd = font_options.hangulspaceskip[newfont]
+ if newwd then
+ setglue(n, newwd[1], newwd[2], newwd[3])
+ end
end
end
end
@@ -1290,6 +1298,7 @@ function luatexko.get_strike_out_down (box)
else
down = -0.5*ex
end
+
local raise = font_options.charraise[f] or 0
return down - raise
end
@@ -1729,12 +1738,21 @@ local function fontdata_warning(activename, ...)
end
end
+local dfltfntsize = get_font_param(fontcurrent(), "quad") or 655360
+
local function process_vertical_font (fontdata)
+ local fullname = fontdata.fullname
+
+ if fontdata.type == "virtual" then
+ fontdata_warning("vitrual."..fullname,
+ "Virtual font `%s' cannot be\nused for vertical writing.", fullname)
+ return
+ end
+
local subfont = fontdata.specification and fontdata.specification.sub
local tsb_tab = get_tsb_table(fontdata.filename, subfont)
if not tsb_tab then
- local fullname = fontdata.fullname
fontdata_warning("vertical."..fullname,
"Vertical metrics table (vmtx) not found in the font\n`%s'", fullname)
return
@@ -1745,12 +1763,13 @@ local function process_vertical_font (fontdata)
local parameters = fontdata.parameters or {}
local scale = parameters.factor or 655.36
local quad = parameters.quad or 655360
+ local xheight = parameters.x_height or quad/2
local ascender = parameters.ascender or quad*0.8
- local goffset = font_opt_dim(fontdata, "charraise") or
- (parameters.x_height or quad/2)/2
+ local goffset = xheight/2 * (dfltfntsize / quad) -- TODO?
+
-- declare shift amount of horizontal box inside vertical env.
- fontdata.horizboxmoverightamount = goffset
+ fontdata.vertcharraise = goffset
for i,v in pairs(fontdata.characters) do
local voff = goffset - (v.width or 0)/2
@@ -1780,6 +1799,8 @@ local function process_vertical_font (fontdata)
parameters.space_stretch = spacechar.width/2
parameters.space_shrink = spacechar.width/2
end
+ parameters.ascender = quad/2 + goffset
+ parameters.descender = quad/2 - goffset
local res = fontdata.resources or {}
local fea = shared.features or {}
@@ -1822,8 +1843,9 @@ function luatexko.gethorizboxmoveright ()
texattribute.luatexkohanjafontattr,
texattribute.luatexkofallbackfontattr } do
if v and v > 0 then
- local amount = get_font_data(v).horizboxmoverightamount
+ local amount = get_font_data(v).vertcharraise
if amount then
+ amount = amount + (font_options.charraise[v] or 0)
set_macro("luatexkohorizboxmoveright", texsp(amount).."sp")
break
end
@@ -1833,19 +1855,25 @@ end
-- charraise
+local raiseattr = luatexbase.new_attribute"luatexkoraiseattr"
+
local function process_charraise (head)
local curr = head
while curr do
- if curr.id == glyphid then
- local f = curr.font
- local raise = font_options.charraise[f]
- if raise and not option_in_font(f, "vertical") then
- local props = my_node_props(curr)
- if not props.charraised then
+ local id = curr.id
+ if id == glyphid then
+ if not has_attribute(curr,raiseattr) then
+ local f = curr.font
+ local raise = font_options.charraise[f]
+ if raise then
curr.yoffset = (curr.yoffset or 0) + raise
- props.charraised = true
end
+ set_attribute(curr, raiseattr, 1)
end
+ elseif id == discid then
+ process_charraise(curr.pre)
+ process_charraise(curr.post)
+ process_charraise(curr.replace)
end
curr = getnext(curr)
end
@@ -1899,19 +1927,15 @@ local function process_fake_slant_corr (head) -- for font fallback
return head
end
-local function process_fake_slant_font (fontdata)
- local fsl = fontdata.slant
+local function process_fake_slant_font (fontdata, fsl)
if fsl and fsl > 0 then
- fsl = fsl/1000
- local hb = is_harf(fontdata)
+ fontdata.slant = fsl*1000
local params = fontdata.parameters or {}
- if not hb then -- hb done by luaotfload
- params.slant = (params.slant or 0) + fsl*65536 -- slant per point
- end
+ params.slant = (params.slant or 0) + fsl*65536 -- slant per point
+ local hb = is_harf(fontdata)
local scale = hb and hb.scale or params.factor or 655.36
-
local shared = fontdata.shared or {}
local descrs = shared.rawdata and shared.rawdata.descriptions or {}
@@ -1945,9 +1969,7 @@ end
-- wrap up
local pass_fun = function(...) return ... end
-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)
@@ -1957,141 +1979,181 @@ function luatexko.process_atbegshi (box)
end
end
-add_to_callback("hpack_filter", function(h)
+add_to_callback("pre_shaping_filter", function(h, gc)
+ local par = gc == ""
+ or gc == "vbox"
+ or gc == "vtop"
+ or gc == "insert"
+ or gc == "vcenter"
h = process_fonts(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)
+ h = call_callback("luatexko_prelinebreak_first", h, par)
+ h = call_callback("luatexko_prelinebreak_second", h, par)
+ return process_linebreak(h, par)
+end, "luatexko.pre_shaping_filter")
-add_to_callback("pre_linebreak_filter", function(h)
- h = process_fonts(h)
- 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_hpack_first = process_remove_spaces,
- luatexko_prelinebreak_first = process_remove_spaces,
- },
- interhangul = {
- luatexko_hpack_second = process_interhangul,
- luatexko_prelinebreak_second = process_interhangul,
+local otfregister = fonts.constructors.features.otf.register
+
+local function activate_process (cbnam, cbfun, name)
+ if not active_processes[name] then
+ add_to_callback(cbnam, cbfun, "luatexko."..cbnam.."."..name)
+ active_processes[name] = true
+ end
+end
+
+otfregister {
+ name = "removeclassicspaces",
+ description = "remove spaces in classic typesetting",
+ default = false,
+ manipulators = {
+ node = function()
+ activate_process("luatexko_prelinebreak_first", process_remove_spaces, "removeclassicspaces")
+ end,
+ plug = function()
+ activate_process("luatexko_prelinebreak_first", process_remove_spaces, "removeclassicspaces")
+ end,
},
- interlatincjk = {
- luatexko_hpack_second = process_interlatincjk,
- luatexko_prelinebreak_second = process_interlatincjk,
+}
+
+otfregister {
+ name = "interhangul",
+ description = "insert more glue between Hangul chars",
+ default = false,
+ manipulators = {
+ node = function()
+ activate_process("luatexko_prelinebreak_second", process_interhangul, "interhangul")
+ end,
+ plug = function()
+ activate_process("luatexko_prelinebreak_second", process_interhangul, "interhangul")
+ end,
},
- charraise = {
- hpack_filter = process_charraise,
- pre_linebreak_filter = process_charraise,
+}
+
+otfregister {
+ name = "interlatincjk",
+ description = "insert glue between CJK and Latin",
+ default = false,
+ manipulators = {
+ node = function()
+ activate_process("luatexko_prelinebreak_second", process_interlatincjk, "interlatincjk")
+ end,
+ plug = function()
+ activate_process("luatexko_prelinebreak_second", process_interlatincjk, "interlatincjk")
+ end,
},
- compresspunctuations = {
- hpack_filter = process_glyph_width,
- pre_linebreak_filter = process_glyph_width,
+}
+
+otfregister {
+ name = "charraise",
+ description = "raise chars",
+ default = false,
+ manipulators = {
+ node = function(fontdata)
+ activate_process("post_shaping_filter", process_charraise, "charraise")
+ end,
+ plug = function(fontdata)
+ activate_process("post_shaping_filter", process_charraise, "charraise")
+ end,
},
- slant = {
- hpack_filter = process_fake_slant_corr,
- pre_linebreak_filter = process_fake_slant_corr,
+}
+
+otfregister {
+ name = "compresspunctuations",
+ description = "compress width of CJK punctuations",
+ default = false,
+ manipulators = {
+ node = function()
+ activate_process("post_shaping_filter", process_glyph_width, "compresspunctuations")
+ end,
+ plug = function()
+ activate_process("post_shaping_filter", process_glyph_width, "compresspunctuations")
+ end,
},
}
--- luaotfload expansion feature, committed at 2020.06.08
-luatexko.plug_expansion_loaded = false
-for _,v in next, fonts.handlers.otf.features.manipulators.plug do
- if v.name == "expansion" then
- luatexko.plug_expansion_loaded = true
- break
- end
-end
+otfregister {
+ name = "slant",
+ description = "fake slant fallback fonts",
+ default = false,
+ manipulators = {
+ node = function(fontdata, _, value)
+ process_fake_slant_font(fontdata, value)
+ activate_process("post_shaping_filter", process_fake_slant_corr, "slant")
+ end,
+ plug = function(fontdata, _, value)
+ process_fake_slant_font(fontdata, value)
+ activate_process("post_shaping_filter", process_fake_slant_corr, "slant")
+ end,
+ },
+}
-local font_opt_procs_single = {
- expansion = function(fontdata)
- if not luatexko.plug_expansion_loaded and is_harf(fontdata) then
- local val = option_in_font(fontdata, "expansion")
- local setup = fonts.expansions.setups[val] or {}
- fontdata.stretch = fontdata.stretch or (setup.stretch or 2)*10
- fontdata.shrink = fontdata.shrink or (setup.shrink or 2)*10
- fontdata.step = fontdata.step or (setup.step or .5)*10
- end
- if tex.adjustspacing == 0 then
- texset("global", "adjustspacing", 2)
- end
- end,
-
- protrusion = function(fontdata)
- if is_harf(fontdata) then -- for now, no support in harf mode
- local val = option_in_font(fontdata, "protrusion")
- local setup = fonts.protrusions.setups[val] or {}
- local quad = fontdata.parameters.quad
- for i, v in pairs(setup) do
- local chr = fontdata.characters[i]
- if chr then
- local wdq = chr.width/quad
- chr.left_protruding = chr.left_protruding or wdq*v[1]*1000
- chr.right_protruding = chr.right_protruding or wdq*v[2]*1000
- end
- end
- end
- if tex.protrudechars == 0 then
- texset("global", "protrudechars", 2)
- end
- if option_in_font(fontdata, "compresspunctuations") then
+otfregister {
+ name = "vertical",
+ description = "vertical typesetting",
+ default = false,
+ manipulators = {
+ node = process_vertical_font,
+ plug = function(fontdata)
local fullname = fontdata.fullname
- fontdata_warning("protrude."..fullname,
- "Both `compresspunctuations' and `protrusion' are\nenabled for `%s'.\n"..
- "Beware bad justifications.", fullname)
- 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,
+ end,
+ },
}
-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
+otfregister {
+ name = "expansion",
+ description = "glyph expansion",
+ default = false,
+ manipulators = {
+ node = function()
+ if tex.adjustspacing == 0 then
+ texset("global", "adjustspacing", 2)
end
- end
- end
+ end,
+ plug = function(fontdata, _, value)
+ local setup = fonts.expansions.setups[value] or {}
+ fontdata.stretch = fontdata.stretch or (setup.stretch or 2)*10
+ fontdata.shrink = fontdata.shrink or (setup.shrink or 2)*10
+ fontdata.step = fontdata.step or (setup.step or .5)*10
+ if tex.adjustspacing == 0 then
+ texset("global", "adjustspacing", 2)
+ end
+ end,
+ },
+}
- for name, func in pairs( font_opt_procs_single ) do
- if option_in_font(fontdata, name) then
- func(fontdata)
+local function process_protrusion (fontdata, _, value)
+ local setup = fonts.protrusions.setups[value] or {}
+ local quad = fontdata.parameters.quad
+ for i, v in pairs(setup) do
+ local chr = fontdata.characters[i]
+ if chr then
+ local wdq = chr.width/quad
+ chr.left_protruding = chr.left_protruding or wdq*v[1]*1000
+ chr.right_protruding = chr.right_protruding or wdq*v[2]*1000
end
end
+ if tex.protrudechars == 0 then
+ texset("global", "protrudechars", 2)
+ end
+ 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
-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")
+otfregister {
+ name = "protrusion",
+ description = "glyph protrusion",
+ default = false,
+ manipulators = {
+ node = process_protrusion,
+ plug = process_protrusion,
+ },
+}
local auxiliary_procs = {
dotemph = {
@@ -2105,11 +2167,9 @@ local auxiliary_procs = {
luatexko_do_atbegshi = process_ruby_post_linebreak,
},
autojosa = {
- luatexko_hpack_first = process_josa,
luatexko_prelinebreak_first = process_josa,
},
reorderTM = {
- luatexko_hpack_first = process_reorder_tonemarks,
luatexko_prelinebreak_first = process_reorder_tonemarks,
},
}
@@ -2151,16 +2211,16 @@ end,
function luatexko.deactivateall (str)
luatexko.deactivated = {}
- for _, name in ipairs{ "hpack_filter",
+ for _, name in ipairs{ "pre_shaping_filter",
+ "post_shaping_filter",
"pre_linebreak_filter",
"hyphenate",
"luatexko_do_atbegshi", -- might not work properly
- "luaotfload.patch_font_unsafe", -- added for harf
- "luaotfload.patch_font" } do
+ } do
local t = {}
- for i, v in ipairs( callback_descriptions(name) ) do
+ for i, v in ipairs( luatexbase.callback_descriptions(name) ) do
if v:find(str or "^luatexko%.") then
- local ff, dd = remove_from_callback(name, v)
+ local ff, dd = luatexbase.remove_from_callback(name, v)
tableinsert(t, { ff, dd, i })
end
end
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
index 958407dc819..f1e01791649 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-2020 Dohyun Kim <nomos at ktug org>
+% Copyright (c) 2013-2021 Dohyun Kim <nomos at ktug org>
% Soojin Nam <jsunam at gmail com>
%
% This work may be distributed and/or modified under the
@@ -13,11 +13,10 @@
\ifdefined\luatexkohangulfontattr \endinput\fi
\ifdefined\selectfont
- \NeedsTeXFormat{LaTeX2e}[2020/02/02]
- \ProvidesPackage{luatexko}[2020/07/27 v2.9 typesetting Korean with LuaTeX]
+ \NeedsTeXFormat{LaTeX2e}[2020/10/01]
+ \ProvidesPackage{luatexko}[2021/03/01 v3.0 typesetting Korean with LuaTeX]
\RequirePackage{luatexbase}
\RequirePackage{fontspec}[2020/02/03]
- \RequirePackage{atbegshi}
\else
\input luatexbase.sty
\input luaotfload.sty
@@ -360,11 +359,6 @@
\ifcase\count@ \directlua{ luatexko.uhc2utf8.stopconvert() }%
\else \directlua{ luatexko.uhc2utf8.startconvert() }%
\fi}
-% actualtext not provided
-\ifdefined\actualtext\else
- \protected\def\actualtext#1#{\luatexkoactualtext}
- \def\luatexkoactualtext#1{#1}
-\fi
% math hangul
\def\setmathhangulblock#1#2{%
\count@="#1
@@ -432,60 +426,60 @@
\catcode`\@=\luatexkoatcatcode
\endinput\fi
% latex
-\RequirePackage{everysel}
-\EverySelectfont{%
- \luatexkohangulselectfont
- \luatexkohanjaselectfont
- \luatexkofallbackselectfont
+\IfHookExistsTF{selectfont}{
+ \AddToHook{selectfont}{%
+ \luatexkohangulselectfont
+ \luatexkohanjaselectfont
+ \luatexkofallbackselectfont }
+}{
+ \RequirePackage{everysel}
+ \EverySelectfont{%
+ \luatexkohangulselectfont
+ \luatexkohanjaselectfont
+ \luatexkofallbackselectfont }
}
-\edef\@rmfamilyhook{\unexpanded\expandafter{\@rmfamilyhook
+\AddToHook{rmfamily}{%
\let\luatexkohangulfont \luatexkomainhangulfont
\let\luatexkohanjafont \luatexkomainhanjafont
\let\luatexkofallbackfont\luatexkomainfallbackfont
-}}
-\edef\@sffamilyhook{\unexpanded\expandafter{\@sffamilyhook
+}
+\AddToHook{sffamily}{%
\let\luatexkohangulfont \luatexkosanshangulfont
\let\luatexkohanjafont \luatexkosanshanjafont
\let\luatexkofallbackfont\luatexkosansfallbackfont
-}}
-\edef\@ttfamilyhook{\unexpanded\expandafter{\@ttfamilyhook
+}
+\AddToHook{ttfamily}{%
\let\luatexkohangulfont \luatexkomonohangulfont
\let\luatexkohanjafont \luatexkomonohanjafont
\let\luatexkofallbackfont\luatexkomonofallbackfont
-}}
-\edef\@defaultfamilyhook{\unexpanded\expandafter{\@defaultfamilyhook
+}
+\AddToHook{normalfont}{%
\let\luatexkohangulfont \luatexkodefaulthangulfont
\let\luatexkohanjafont \luatexkodefaulthanjafont
\let\luatexkofallbackfont\luatexkodefaultfallbackfont
-}}
+}
% fontspec-like
\ExplSyntaxOn
-\cs_new_nopar:Npn \l_luatexko_pacify_bfseries {
+\cs_new_nopar:Npn \l_luatexko_silent_upshape {
\tl_map_inline:nn { \mddefault \bfdefault }
{
\cs_if_exist:cF
{ \g_fontspec_encoding_tl/\l_fontspec_family_tl/##1/\updefault }
{
- \cs_set_eq:cc
- { \g_fontspec_encoding_tl/\l_fontspec_family_tl/##1/\updefault }
+ \cs_if_exist:cT
{ \g_fontspec_encoding_tl/\l_fontspec_family_tl/##1/\shapedefault }
- }
- }
- \tl_map_inline:nn { \shapedefault \updefault \itdefault \sldefault }
- {
- \cs_if_exist:cF
- { \g_fontspec_encoding_tl/\l_fontspec_family_tl/bx/##1 }
- {
- \cs_set_eq:cc
- { \g_fontspec_encoding_tl/\l_fontspec_family_tl/bx/##1 }
- { \g_fontspec_encoding_tl/\l_fontspec_family_tl/\bfdefault/##1 }
+ {
+ \cs_set_eq:cc
+ { \g_fontspec_encoding_tl/\l_fontspec_family_tl/##1/\updefault }
+ { \g_fontspec_encoding_tl/\l_fontspec_family_tl/##1/\shapedefault }
+ }
}
}
}
\DeclareDocumentCommand \setmainhangulfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomainhangulfamily { Ligatures=TeX, #1, #3 } { #2 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkomainhangulfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -502,7 +496,7 @@
\DeclareDocumentCommand \setsanshangulfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkosanshangulfamily { Ligatures=TeX, #1, #3 } { #2 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkosanshangulfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -519,7 +513,7 @@
\DeclareDocumentCommand \setmonohangulfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomonohangulfamily { #1, #3 } { #2 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkomonohangulfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -536,7 +530,7 @@
\DeclareDocumentCommand \newhangulfontfamily { m O{} m O{} }
{
\fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn #1
{
\cs_set_nopar:Npn \luatexkohangulfont
@@ -555,7 +549,7 @@
\DeclareDocumentCommand \hangulfontspec { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkohangulfontfamily { #1, #3 } { #2 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_nopar:Npn \luatexkohangulfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -567,7 +561,7 @@
\DeclareDocumentCommand \setmainhanjafont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomainhanjafamily { Ligatures=TeX, #1, #3 } { #2 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkomainhanjafont
{
\fontencoding \g_fontspec_encoding_tl
@@ -584,7 +578,7 @@
\DeclareDocumentCommand \setsanshanjafont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkosanshanjafamily { Ligatures=TeX, #1, #3 } { #2 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkosanshanjafont
{
\fontencoding \g_fontspec_encoding_tl
@@ -601,7 +595,7 @@
\DeclareDocumentCommand \setmonohanjafont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomonohanjafamily { #1, #3 } { #2 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkomonohanjafont
{
\fontencoding \g_fontspec_encoding_tl
@@ -618,7 +612,7 @@
\DeclareDocumentCommand \newhanjafontfamily { m O{} m O{} }
{
\fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn #1
{
\cs_set_nopar:Npn \luatexkohanjafont
@@ -637,7 +631,7 @@
\DeclareDocumentCommand \hanjafontspec { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkohanjafontfamily { #1, #3 } { #2 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_nopar:Npn \luatexkohanjafont
{
\fontencoding \g_fontspec_encoding_tl
@@ -650,7 +644,7 @@
\DeclareDocumentCommand \setmainfallbackfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomainfallbackfamily { Ligatures=TeX, #1, #3 } { #2 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkomainfallbackfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -667,7 +661,7 @@
\DeclareDocumentCommand \setsansfallbackfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkosansfallbackfamily { Ligatures=TeX, #1, #3 } { #2 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkosansfallbackfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -684,7 +678,7 @@
\DeclareDocumentCommand \setmonofallbackfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomonofallbackfamily { #1, #3 } { #2 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn \luatexkomonofallbackfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -701,7 +695,7 @@
\DeclareDocumentCommand \newfallbackfontfamily { m O{} m O{} }
{
\fontspec_set_family:cnn { luatexko_user_family_ \cs_to_str:N #1 } { #2, #4 } { #3 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_protected_nopar:Npn #1
{
\cs_set_nopar:Npn \luatexkofallbackfont
@@ -720,7 +714,7 @@
\DeclareDocumentCommand \fallbackfontspec { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkofallbackfontfamily { #1, #3 } { #2 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\cs_set_nopar:Npn \luatexkofallbackfont
{
\fontencoding \g_fontspec_encoding_tl
@@ -732,7 +726,7 @@
\DeclareDocumentCommand \setmathhangulfont { O{} m O{} }
{
\fontspec_set_family:Nnn \luatexkomathhangulfamily { #1, #3 } { #2 }
- \l_luatexko_pacify_bfseries
+ \l_luatexko_silent_upshape
\DeclareSymbolFont { mathhangul }
\g_fontspec_encoding_tl \luatexkomathhangulfamily \mddefault \updefault
\int_compare:nNnF { \Umathcharfam"AC00 } = { \symmathhangul }
@@ -746,20 +740,14 @@
\let\adhochanjafont\hanjafontspec
\let\adhocfallbackfont\fallbackfontspec
% interhangul, interlatincjk, charraise
-\def\luatexkopacifybfseries{%
+\def\luatexkosilentupshape{%
\@tfor \@tempa := \mddefault \bfdefault \do {%
\ifcsname \f@encoding/\f@family/\@tempa/\updefault\endcsname \else
+ \ifcsname \f@encoding/\f@family/\@tempa/\shapedefault\endcsname
\global \expandafter\let
\csname \f@encoding/\f@family/\@tempa/\updefault \expandafter\endcsname
\csname \f@encoding/\f@family/\@tempa/\shapedefault\endcsname
- \fi
- }%
- \@tfor \@tempa := \shapedefault \updefault \itdefault \sldefault \do {%
- \ifcsname \f@encoding/\f@family/bx/\@tempa\endcsname \else
- \global \expandafter\let
- \csname \f@encoding/\f@family/bx/\@tempa \expandafter\endcsname
- \csname \f@encoding/\f@family/\bfdefault/\@tempa\endcsname
- \fi
+ \fi\fi
}%
}
\protected\def\addhangulfontfeature#1{%
@@ -767,7 +755,7 @@
\ifdefined\luatexkohangulfont
\fontseries\mddefault\fontshape\shapedefault \luatexkohangulfont \fi
\addfontfeature{#1}%
- \luatexkopacifybfseries
+ \luatexkosilentupshape
\edef\x{\endgroup
\def\noexpand\luatexkohangulfont{%
\noexpand\fontencoding{\UTFencname}%
@@ -780,7 +768,7 @@
\ifdefined\luatexkohanjafont
\fontseries\mddefault\fontshape\shapedefault \luatexkohanjafont \fi
\addfontfeature{#1}%
- \luatexkopacifybfseries
+ \luatexkosilentupshape
\edef\x{\endgroup
\def\noexpand\luatexkohanjafont{%
\noexpand\fontencoding{\UTFencname}%
@@ -793,7 +781,7 @@
\ifdefined\luatexkofallbackfont
\fontseries\mddefault\fontshape\shapedefault \luatexkofallbackfont \fi
\addfontfeature{#1}%
- \luatexkopacifybfseries
+ \luatexkosilentupshape
\edef\x{\endgroup
\def\noexpand\luatexkofallbackfont{%
\noexpand\fontencoding{\UTFencname}%
@@ -806,21 +794,7 @@
\newfontfeature{CharRaise}{charraise=#1}
\newfontfeature{RemoveClassicSpaces}{+removeclassicspaces}
\newfontfeature{CompressPunctuations}{+compresspunctuations}
-% luaotfload expansion feature, committed at 2020.06.08
-\count@=\z@
-\directlua{ if luatexko.plug_expansion_loaded then tex.setcount(255,1) end }
-\ifnum\count@=\z@
- \newfontfeature{Expansion}{expansion=\ifx\empty#1\empty default\else #1\fi }
-\else
- \newfontfeature{Expansion}{expansion=\directlua{
- if "#1" == "" or "#1" == "default" then
- tex.sprint "20 20 5"
- else
- tex.sprint "#1"
- end
- }%
- }
-\fi
+\newfontfeature{Expansion}{expansion=\ifx\empty#1\empty default\else #1\fi }
\newfontfeature{Protrusion}{protrusion=\ifx\empty#1\empty default\else #1\fi }
\newfontfeature{InterCharacter}{intercharacter=#1}
\newfontfeature{InterCharStretch}{intercharstretch=#1}
@@ -854,7 +828,22 @@
\begingroup\ttfamily
\directlua{ luatexko.currenthashangulchars(255) }\expandafter\endgroup
\ifnum\count@=\z@
- \let\luatexkomonohangulfont\luatexkosanshangulfont
+ \def\@tempa{lmtt}\def\@tempb{LatinModernMono(0)}
+ \ifnum 0\ifx\ttdefault\@tempa 1\else\ifx\ttdefault\@tempb 1\fi\fi >\z@
+ \IfFontExistsTF{UnDotum.ttf}
+ {\setmonohangulfont{UnDotum}[
+ UprightFeatures={SizeFeatures={
+ {Size={-8.5}, FakeStretch=1.062},
+ {Size={8.5-11}, FakeStretch=1.05 },
+ {Size={11-}, FakeStretch=1.03 }}},
+ BoldFeatures={SizeFeatures={
+ {Size={-}, FakeStretch=1.05}}},
+ WordSpace={1.66667,0,0}]
+ }
+ {\let\luatexkomonohangulfont\luatexkosanshangulfont }
+ \else
+ \let\luatexkomonohangulfont\luatexkosanshangulfont
+ \fi
\fi
\fi
% just in case, reset luatexkodefault...font