summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/luatexko/luatexko.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/generic/luatexko/luatexko.lua')
-rw-r--r--macros/luatex/generic/luatexko/luatexko.lua83
1 files changed, 49 insertions, 34 deletions
diff --git a/macros/luatex/generic/luatexko/luatexko.lua b/macros/luatex/generic/luatexko/luatexko.lua
index 3f21e7c970..0720a4ecd9 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/02/17',
- version = '2.6',
+ date = '2020/03/14',
+ version = '2.7',
description = 'typesetting Korean with LuaTeX',
author = 'Dohyun Kim, Soojin Nam',
license = 'LPPL v1.3+',
@@ -36,11 +36,9 @@ local insert_before = node.insert_before
local nodecopy = node.copy
local nodecount = node.count
local nodefree = node.free
-local nodeid = node.id
local nodenew = node.new
local noderemove = node.remove
local nodeslide = node.slide
-local nodesubtype = node.subtype
local nodewrite = node.write
local rangedimensions = node.rangedimensions
local setglue = node.setglue
@@ -83,19 +81,19 @@ local function warning (...)
return module_warning("luatexko", stringformat(...))
end
-local dirid = nodeid"dir"
-local discid = nodeid"disc"
-local glueid = nodeid"glue"
-local glyphid = nodeid"glyph"
-local hlistid = nodeid"hlist"
-local kernid = nodeid"kern"
-local mathid = nodeid"math"
-local penaltyid = nodeid"penalty"
-local ruleid = nodeid"rule"
-local vlistid = nodeid"vlist"
-local whatsitid = nodeid"whatsit"
-local literal_whatsit = nodesubtype"pdf_literal"
-local user_whatsit = nodesubtype"user_defined"
+local dirid = node.id"dir"
+local discid = node.id"disc"
+local glueid = node.id"glue"
+local glyphid = node.id"glyph"
+local hlistid = node.id"hlist"
+local kernid = node.id"kern"
+local mathid = node.id"math"
+local penaltyid = node.id"penalty"
+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
@@ -1125,10 +1123,8 @@ local josa_code = setmetatable({
end
end })
-local ignore_parens = false
-
-local function prevjosacode (n, parenlevel)
- local parenlevel, josacode = parenlevel or 0
+local function prevjosacode (n, parenlevel, ignore_parens)
+ local josacode
while n do
local id = n.id
if id == glyphid then
@@ -1144,7 +1140,7 @@ local function prevjosacode (n, parenlevel)
elseif id == hlistid or id == vlistid then
local list = n.list
if list then
- josacode, parenlevel = prevjosacode(nodeslide(list), parenlevel)
+ josacode, parenlevel = prevjosacode(nodeslide(list), parenlevel, ignore_parens)
if josacode then break end
end
end
@@ -1170,8 +1166,7 @@ local function process_josa (head)
end
local t = josa_table[cc]
if t then
- ignore_parens = autojosaattr > 0
- cc = t[prevjosacode(getprev(curr)) or 3]
+ cc = t[prevjosacode(getprev(curr), 0, autojosaattr > 0) or 3]
if cc then
curr.char = cc
else
@@ -1976,13 +1971,33 @@ local font_opt_procs = {
}
local font_opt_procs_single = {
- expansion = function()
+ expansion = function(fontdata)
+ if is_harf(fontdata) then -- for now, no support in harf mode
+ 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
@@ -2043,17 +2058,17 @@ add_to_callback("luaotfload.patch_font_unsafe", process_patch_font,
local auxiliary_procs = {
dotemph = {
- hpack_filter = process_dotemph,
- vpack_filter = process_dotemph,
+ hpack_filter = process_dotemph,
+ post_linebreak_filter = process_dotemph,
},
uline = {
- hpack_filter = process_uline,
- vpack_filter = process_uline,
+ hpack_filter = process_uline,
+ post_linebreak_filter = process_uline,
},
ruby = {
- pre_linebreak_filter = process_ruby_pre_linebreak,
- hpack_filter = process_ruby_post_linebreak,
- vpack_filter = process_ruby_post_linebreak,
+ pre_linebreak_filter = process_ruby_pre_linebreak,
+ hpack_filter = process_ruby_post_linebreak,
+ post_linebreak_filter = process_ruby_post_linebreak,
},
autojosa = {
luatexko_hpack_first = process_josa,
@@ -2070,7 +2085,7 @@ local function activate (name)
local fun
if cbnam == "hpack_filter" then
fun = function(h, gc)
- if gc == "align_set" then
+ if gc == "hbox" or gc == "adjusted_hbox" or gc == "align_set" then
h = cbfun(h)
end
return h
@@ -2118,7 +2133,7 @@ local function deactivate_all (str)
luatexko.deactivated = {}
for _, name in ipairs{ "hpack_filter",
"pre_linebreak_filter",
- "vpack_filter",
+ "post_linebreak_filter",
"hyphenate",
"luaotfload.patch_font_unsafe", -- added for harf
"luaotfload.patch_font" } do