From d14737e2ff267c851851d16406fd5e882e24df0a Mon Sep 17 00:00:00 2001 From: Hironori Kitagawa Date: Fri, 31 Mar 2023 11:58:33 +0900 Subject: [PATCH] obey \input@path in \[global]{j,t}font (#47723) --- src/luatexja-core.sty | 14 ++++++++++---- src/luatexja.lua | 25 +++++++++++++++++-------- src/patches/lltjfont.sty | 14 ++++++++++++++ 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/luatexja-core.sty b/src/luatexja-core.sty index 15d02be..f150faa 100644 --- a/src/luatexja-core.sty +++ b/src/luatexja-core.sty @@ -221,11 +221,15 @@ \luadef\ltj@@start@time@measure\ltj@@start@time@measure@inner \luadef\ltj@@stop@time@measure\ltj@@stop@time@measure@inner +\let\ltj@@convert@input@path@to@lua\relax % defined in LaTeX only (ltj-latex.sty) + %%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont \protected\def\jfont#1{% - \def\ltj@temp{#1}\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'yoko')}} + \ltj@@convert@input@path@to@lua\def\ltj@temp{#1}% + \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'yoko')}} \protected\def\globaljfont#1{% - \def\ltj@temp{#1}\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true, 'yoko')}} + \ltj@@convert@input@path@to@lua\def\ltj@temp{#1}% + \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true, 'yoko')}} \newluafunction\ltj@@jfont@inner \directlua{ (lua.get_functions_table())[\the\ltj@@jfont@inner] = luatexja.jfont.jfontdefY @@ -234,9 +238,11 @@ %%%%%%%% \tfont\CS={...:...;jfm=metric;...}, \globaltfont \protected\def\tfont#1{% - \def\ltj@temp{#1}\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'tate')}} + \ltj@@convert@input@path@to@lua\def\ltj@temp{#1}% + \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'tate')}} \protected\def\globaltfont#1{% - \def\ltj@temp{#1}\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true, 'tate')}} + \ltj@@convert@input@path@to@lua\def\ltj@temp{#1}% + \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true, 'tate')}} %%%%%%%% \zw, \zh \newluafunction\ltj@zw@inner diff --git a/src/luatexja.lua b/src/luatexja.lua index 31bd066..64bab4c 100644 --- a/src/luatexja.lua +++ b/src/luatexja.lua @@ -1,14 +1,23 @@ require 'lualibs' ------------------------------------------------------------------------ -local function load_lua(fn) - local found = kpse.find_file(fn, 'tex') - if not found then - tex.error("LuaTeX-ja error: File `" .. fn .. "' not found") - else - texio.write_nl('(' .. found .. ')'); dofile(found) - end +do + local ipath = {} + function luatexja.input_path_clear() for i in ipairs(ipath) do ipath[i]=nil end end + function luatexja.input_path_add(s) ipath[#ipath+1]=s end + function luatexja.load_lua(fn) + local found = kpse.find_file(fn, 'tex') + if not found then + for _,v in ipairs(ipath) do + found = kpse.find_file(v .. fn, 'tex'); if found then break end + end + end + if not found then + tex.error("LuaTeX-ja error: File `" .. fn .. "' not found") + else + texio.write_nl('(' .. found .. ')'); dofile(found) + end + end end -luatexja.load_lua = load_lua function luatexja.load_module(name) require('ltj-' .. name.. '.lua') end do diff --git a/src/patches/lltjfont.sty b/src/patches/lltjfont.sty index f1435f7..0241243 100644 --- a/src/patches/lltjfont.sty +++ b/src/patches/lltjfont.sty @@ -1433,4 +1433,18 @@ \ltj@@getjfontnumber#1% \directlua{luatexja.jfont.pickup_alt_font_b(\the\ltj@tempcntc,'\luatexluaescapestring{#2}')}% } + +%%%% send \input@path data to lua +\def\ltj@@convert@input@path@to@lua{% + \ltj@@cipath@clear + \ifdefined\input@path + \@tfor\ltj@temp:=\input@path\do{\ltj@@cipath@add{\ltj@temp}}% + \fi +} +\newluafunction\ltj@@cipath@clear@inner +\directlua{ + (lua.get_functions_table())[\the\ltj@@cipath@clear@inner] = luatexja.input_path_clear +} +\protected\luadef\ltj@@cipath@clear\ltj@@cipath@clear@inner +\def\ltj@@cipath@add#1{\directlua{luatexja.input_path_add('\luatexluaescapestring#1')}} \endinput -- 2.11.0